Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp4865014ybv; Mon, 17 Feb 2020 07:23:45 -0800 (PST) X-Google-Smtp-Source: APXvYqyRN18StCwJQLyk2NJdS7gWq23EZXBfcM9s05nvuvHjdxbilGTxno4nx0ubW49P8+vRM4KM X-Received: by 2002:a9d:7559:: with SMTP id b25mr12168214otl.189.1581953025272; Mon, 17 Feb 2020 07:23:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581953025; cv=none; d=google.com; s=arc-20160816; b=JSAX+l/3nSV/D4SMtvBMUBfoI6vW3La/dBtcL9YYbTaInk/gEh6l9hQT3BTHmZssZf XIAgM0HYr+ISUA9l2VAOosgUUejTT2iIr6/YQRLr/qZpCTXeRaFg+p+Q4SGLluhr50ge CAeLg4+nxFLRjXZAhDDFgymQQzZRDQ5gJLK7TTBQ4gL3WsI+aF1xoezinUtozoUKjs26 3i43Ao8RV6mD2C8ZeFda94Fr0Ym2XcR+5ywhEiNp1ESVReLfGnnKsZM40HOFFfEDdjD7 8iFK8cJN8UthGHT5Mfp5HjB75Lht+qd6Xe+N+wfeSeFiQZhZmY7DJWbK1iT4s1PM0/9o 1GDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=f+3OGTXOU6Agins356Z5AqkAfZFQT+Vwt5LSeJBahwY=; b=uRMv4rkA+zOWmH5r9AFq96Wbsv7KPqnFiuZLIkC8jWKqelQk6vsm3eShJNpZ4p3UwD D1FF2V6k0cPreyBFO8zTdkjMrZLootBc1WOpioRj0slOS95pBrAF5PI3lybHSkh9zTX7 F7dDNbO1p42cEv2AvVnl0ZP+8XzrflP5QIN4G1Ji1G0wGLEXQo6HL1LrFzZoyN5UhQpT 8hr7C3KYgPr8g49t+Av446LNHREzElVaceusk7uglbJ+Bc9FZtW+oEOpt2HuJe6T02nM c+AfEbt17XBUwCBCR93Rw5BcNR9FPFq/BNM+kF3GGgaQBan4bDIoIKfGoEqspOoLY8p2 eK5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=Yhzn7389; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g9si324222otq.68.2020.02.17.07.23.33; Mon, 17 Feb 2020 07:23:45 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=Yhzn7389; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728650AbgBQPMw (ORCPT + 99 others); Mon, 17 Feb 2020 10:12:52 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:41898 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727976AbgBQPMv (ORCPT ); Mon, 17 Feb 2020 10:12:51 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=f+3OGTXOU6Agins356Z5AqkAfZFQT+Vwt5LSeJBahwY=; b=Yhzn7389uoyG2+7V8Fg9PmlgDb 5bYbLZ/YhuQkPbtChlCW9wTPERlwg3vWvvg1jtDb+bt2j66rhlb4ufs7Gjri/eY031IdSgjJcal+f qqsAVPoj1+HJlTuPgNagW5d8nfIatiUiKzzKoUpGKhnCLFhIUuB+QwR39vFKUXKIywH4yMXqAauBi kle3ZaZDoDbvzy/N7U69zqKn0ZXGkpV2EinV+sTF0qKeFNMACG9rdpCqwRRet55sCmCJ+5TboAv7G EBk0cuKHtDcYPh0NettgFQxFVGR+kJgX5GHYl3NmnXJaUHhueLo9wvyw/j9RH/dWZ+7yU59CmmH6b r2OLORXA==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1j3i4m-0004bd-1D; Mon, 17 Feb 2020 15:12:48 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 93254304D2C; Mon, 17 Feb 2020 16:10:54 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 147682B910502; Mon, 17 Feb 2020 16:12:46 +0100 (CET) Date: Mon, 17 Feb 2020 16:12:46 +0100 From: Peter Zijlstra To: Amol Grover Cc: Ingo Molnar , Will Deacon , linux-kernel@vger.kernel.org, linux-kernel-mentees@lists.linuxfoundation.org, Joel Fernandes , Madhuparna Bhowmik , "Paul E . McKenney" Subject: Re: [PATCH RESEND] lockdep: Pass lockdep expression to RCU lists Message-ID: <20200217151246.GS14897@hirez.programming.kicks-ass.net> References: <20200216074636.GB14025@workstation-portable> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200216074636.GB14025@workstation-portable> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Feb 16, 2020 at 01:16:36PM +0530, Amol Grover wrote: > Data is traversed using hlist_for_each_entry_rcu outside an > RCU read-side critical section but under the protection > of either lockdep_lock or with irqs disabled. > > Hence, add corresponding lockdep expression to silence false-positive > lockdep warnings, and harden RCU lists. Also add macro for > corresponding lockdep expression. > > Two things to note: > - RCU traversals protected under both, irqs disabled and > graph lock, have both the checks in the lockdep expression. > - RCU traversals under the protection of just disabled irqs > don't have a corresponding lockdep expression as it is implicitly > checked for. > > Signed-off-by: Amol Grover > --- > kernel/locking/lockdep.c | 21 +++++++++++++-------- > 1 file changed, 13 insertions(+), 8 deletions(-) > > diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c > index 32282e7112d3..696ad5d4daed 100644 > --- a/kernel/locking/lockdep.c > +++ b/kernel/locking/lockdep.c > @@ -85,6 +85,8 @@ module_param(lock_stat, int, 0644); > * code to recurse back into the lockdep code... > */ > static arch_spinlock_t lockdep_lock = (arch_spinlock_t)__ARCH_SPIN_LOCK_UNLOCKED; > +#define graph_lock_held() \ > + arch_spin_is_locked(&lockdep_lock) > static struct task_struct *lockdep_selftest_task_struct; > > static int graph_lock(void) > @@ -1009,7 +1011,7 @@ static bool __check_data_structures(void) > /* Check the chain_key of all lock chains. */ > for (i = 0; i < ARRAY_SIZE(chainhash_table); i++) { > head = chainhash_table + i; > - hlist_for_each_entry_rcu(chain, head, entry) { > + hlist_for_each_entry_rcu(chain, head, entry, graph_lock_held()) { > if (!check_lock_chain_key(chain)) > return false; > } URGH.. this patch combines two horribles to create a horrific :/ - spin_is_locked() is an abomination - this RCU list stuff is just plain annoying I'm tempted to do something like: #define STFU (true) hlist_for_each_entry_rcu(chain, head, entry, STFU) { Paul, are we going a little over-board with this stuff? Do we really have to annotate all of this?