Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp248114ybl; Thu, 5 Dec 2019 19:13:47 -0800 (PST) X-Google-Smtp-Source: APXvYqygb/QYJT08BRs7M5bXKQzTleR2EAlom+EeF+51Y8rGI1wh0kymeu3B0towTgOeBXJ0LDhN X-Received: by 2002:a9d:24a6:: with SMTP id z35mr9076858ota.343.1575602027788; Thu, 05 Dec 2019 19:13:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575602027; cv=none; d=google.com; s=arc-20160816; b=U2ZaBEPy7PTNfXpA2l2bmpstY0Vo5kkEU3y16n0UxhVOmEo1QDIKKQm7sFMYXwZ+i8 KZJVRgDU1A5r5rEkU6Bp0vh0cCm2YH1xV/6F3jgeiujHg9Mm1kLVY8H9AdXjg1fOC8Pq VSq1I4To8Uh+sYV4ZZU7g0roT75tFwnKG97A8cJ5ETXxzwstB1bvgsZmN0R8HuoafLxT ngpZ872+Kvkl28g7/fJT6zr4qWfrZTzqeLCqiK0hbp0Xb6/0J3A8rVHe8BCbK+hi5wDs vnSLfLlMF6lPy+tRBd6SWXJZoRHbIF4oB07X2jR9QPF+ubACO1ZY805AKjCd/YoCGK89 bVeQ== 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:reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=TVdte0d4UvuPVzYyD2kwhtNTBRTEUzmy4vdReCk/9IQ=; b=GD2U0x+7z1wI4gbc5t6uisYYy082elVwB7W0+CBJm6mSHfwBqM1caDe7ke3Tpx8w0K ABBtp+kFGe8NwzWOCgGczckuQZMhAPgqIRGNmWd/FWGchNG2HY588Mpo4jkdTDZsqa5r 19LrWY6kp04m8Ilo5Om+tnSq1JWrZNEV/6hv6s4UHBzbbg+M7YEmAM9HZ3Auim2KlUbQ 30j/70shJ8jKktjIcx3CsBfAAmHJdOupXa6ZsZUhUmslS5+D4AyNlNWGxrF1LKy9cWMm bIq0ryMwUPeXfa6wcMsnZizqcSJXhKk6TJCRtKKvEUSZ10RX0peYOygY8XmAoVSMAH28 Mudw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=mZkV+FO1; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 50si6512256otv.177.2019.12.05.19.13.35; Thu, 05 Dec 2019 19:13:47 -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=pass header.i=@kernel.org header.s=default header.b=mZkV+FO1; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726374AbfLFDLx (ORCPT + 99 others); Thu, 5 Dec 2019 22:11:53 -0500 Received: from mail.kernel.org ([198.145.29.99]:32996 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726160AbfLFDLx (ORCPT ); Thu, 5 Dec 2019 22:11:53 -0500 Received: from paulmck-ThinkPad-P72.home (50-39-105-78.bvtn.or.frontiernet.net [50.39.105.78]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D214E22525; Fri, 6 Dec 2019 03:11:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1575601911; bh=ygisAbywNNJp+p3FW0CP0VYzP7nARfH6UtkN6FtRDHg=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=mZkV+FO1I33/YSDut2aEfBwRscQ9rLY/yoZ+dCXwUFdZ43/ofZohFbOzUBFlIwfQq jAiSa3MDBQgZijLH0gfg+nTIbQ18wjBEfKS7yilNHKkP5/sj4c8dNKjW9EoK6JMnn1 diLcoxHU2yGnmt0jLJiURRcazar2Q7SX1yNhGlhE= Received: by paulmck-ThinkPad-P72.home (Postfix, from userid 1000) id A18573522782; Thu, 5 Dec 2019 19:11:51 -0800 (PST) Date: Thu, 5 Dec 2019 19:11:51 -0800 From: "Paul E. McKenney" To: Joel Fernandes Cc: Ingo Molnar , Peter Zijlstra , Masami Hiramatsu , Anders Roxell , "Naveen N . Rao" , Anil S Keshavamurthy , David Miller , Linux Kernel Mailing List Subject: Re: [PATCH -tip] kprobes: Lock rcu_read_lock() while searching kprobe Message-ID: <20191206031151.GY2889@paulmck-ThinkPad-P72> Reply-To: paulmck@kernel.org References: <157527193358.11113.14859628506665612104.stgit@devnote2> <20191202210854.GD17234@google.com> <20191203071329.GC115767@gmail.com> <20191203175712.GI2889@paulmck-ThinkPad-P72> <20191204100549.GB114697@gmail.com> <20191204161239.GL2889@paulmck-ThinkPad-P72> <20191206011137.GB142442@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191206011137.GB142442@google.com> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Dec 05, 2019 at 08:11:37PM -0500, Joel Fernandes wrote: > On Wed, Dec 04, 2019 at 08:12:39AM -0800, Paul E. McKenney wrote: > > On Wed, Dec 04, 2019 at 11:05:50AM +0100, Ingo Molnar wrote: > > > > > > * Paul E. McKenney wrote: > > > > > > > > * This list-traversal primitive may safely run concurrently with > > > > > * the _rcu list-mutation primitives such as hlist_add_head_rcu() > > > > > * as long as the traversal is guarded by rcu_read_lock(). > > > > > */ > > > > > #define hlist_for_each_entry_rcu(pos, head, member, cond...) \ > > > > > > > > > > is actively harmful. Why is it there? > > > > > > > > For cases where common code might be invoked both from the reader > > > > (with RCU protection) and from the updater (protected by some > > > > lock). This common code can then use the optional argument to > > > > hlist_for_each_entry_rcu() to truthfully tell lockdep that it might be > > > > called with either form of protection in place. > > > > > > > > This also combines with the __rcu tag used to mark RCU-protected > > > > pointers, in which case sparse complains when a non-RCU API is applied > > > > to these pointers, to get back to your earlier question about use of > > > > hlist_for_each_entry_rcu() within the update-side lock. > > > > > > > > But what are you seeing as actively harmful about all of this? > > > > What should we be doing instead? > > > > > > Yeah, so basically in the write-locked path hlist_for_each_entry() > > > generates (slightly) more efficient code than hlist_for_each_entry_rcu(), > > > correct? > > > > Potentially yes, if the READ_ONCE() constrains the compiler. Or not, > > depending of course on the compiler and the surrounding code. > > > > > Also, the principle of passing warning flags around is problematic - but > > > I can see the point in this specific case. > > > > Would it help to add an hlist_for_each_entry_protected() that expected > > RCU-protected pointers and write-side protection, analogous to > > rcu_dereference_protected()? Or would that expansion of the RCU API > > outweigh any benefits? > > Personally, I like keeping the same API and using the optional argument like > we did thus preventing too many APIs / new APIs. Would you be willing to put together a prototype patch so that people can see exactly how it would look? Thanx, Paul