Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp10008243rwp; Thu, 20 Jul 2023 13:08:29 -0700 (PDT) X-Google-Smtp-Source: APBJJlFGSgt+P3h4o58FL9XsBYiWOA8j1Sgpt3O9TWv7mvT4M9228tKDYEXigk5hYhMA60dtTxiN X-Received: by 2002:a05:6402:3551:b0:51e:85d7:2c79 with SMTP id f17-20020a056402355100b0051e85d72c79mr6957608edd.7.1689883709452; Thu, 20 Jul 2023 13:08:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689883709; cv=none; d=google.com; s=arc-20160816; b=YI2ZfnlwH2bcd1HEng95Yyjy1HUzH4frt0NLoDH0tzFQSm6oGiSKX2eJfFe7WIOXdH fyhNKkN61FGgwkKvLbXOpK3n7A+1LQPasLIAp5o3NVZif/J7MwGSmM4slWzP2hM8fts7 QCo3QaT2fME0UPzh/ZPoDCbBMbGGtmt6Dvw3ZdIha0fr4Ve5YZECU9fcsM4Ha/OTSqPV j0+TdNQHQBbmQsId3wkIYIX11xJORjnx7W3TJziOAtVTVBthTH3/AedxFkewbgCP3ION ax1t2eKDTSHvGFKggB4Wsmuel6zXFCUxFHFazxkwkUsSSP1FXfysjwtOXJcJf3U1JSrl dG5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=pQViyyW2A9qnQiuDGwYLIHQxPps77PgHkAeVtchb9Y8=; fh=IedS5I5vclAhV+CoXLhoqdm3pnuhPDKn/0v8laTcVII=; b=s/LgluG4rZlJnv0TQlcU7pOOT0F5bw7VRfm8KST9sTUzNOp0tFq5UI8Owy6Ipect8J BzB2EnCFL77Q/yDu5LTZyr6bpZwRVoRarWBN9Gjrjxl+mp7cmm5v6ePqANhmESG2emzK lOjuHG5g4iP7Sn70FbL7tpkuhi/2bElQ4UGNOt3SxvEEG8upCx4pPwzOpWx+gH3ZhuWb qiSwGxcAkhw3hszOLL8SDXqskRCM3tT4Sawr9t/gkOHjw9y+dIekNUIyAxfXgY+SyGZW +Q1KyaLEAVpYCpmyEABzMGMhiMzr73m6diDCgaljcU0JQAUKUyTJeCFKJDpbdPeYD7Mu P6Og== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=bjDTli1p; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a11-20020aa7cf0b000000b005184a8f7212si1293874edy.493.2023.07.20.13.08.04; Thu, 20 Jul 2023 13:08:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=bjDTli1p; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S231142AbjGTToA (ORCPT + 99 others); Thu, 20 Jul 2023 15:44:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47176 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230034AbjGTTn7 (ORCPT ); Thu, 20 Jul 2023 15:43:59 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 650301733; Thu, 20 Jul 2023 12:43:57 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id DFC1861C31; Thu, 20 Jul 2023 19:43:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 429B5C433C7; Thu, 20 Jul 2023 19:43:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1689882236; bh=sCvPv521BIeMl03mgPnQ7eOaGG0Jr/Tf/dwmgsz/KEQ=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=bjDTli1prjox2jYYrPOJyqppo33kBj9TXnixuVuyNr7JdpI9zhtl2bLp5D8oHnfz+ s4RONI8jHDfV0ZTIqZsHpoi7OE0G21digr1n6hES4Q4m4ernCsPkrjdtpTMq1xhh3d VJNsioF4JMdOFUWynItwGXdSCtNybfwzyE4fbbQPvsAXl3Vgfdcg9sqxsdspwAfed3 tAkKUPVQP6JDQHrO4PlKDdjyZYHxgW7VcHs8FVxkt4ZRUpYq8D0nZg78PJf/x6JZIZ SG65jQjM8VO2T0xHJqkdaQ1xHebrGUhBoML2srO4ks2nQVZNPvrfOQMKPdNShC0EjE nBS3MWcELRRYA== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id C536ACE03CF; Thu, 20 Jul 2023 12:43:55 -0700 (PDT) Date: Thu, 20 Jul 2023 12:43:55 -0700 From: "Paul E. McKenney" To: Joe Perches Cc: rcu@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-team@meta.com, rostedt@goodmis.org, Andy Whitcroft , Dwaipayan Ray , Lukas Bulwahn , Alexei Starovoitov , Daniel Borkmann , John Fastabend , bpf@vger.kernel.org Subject: Re: [PATCH rcu 5/5] checkpatch: Complain about unexpected uses of RCU Tasks Trace Message-ID: <798959b0-b107-44c4-8262-075930ebfeaa@paulmck-laptop> Reply-To: paulmck@kernel.org References: <20230717180454.1097714-5-paulmck@kernel.org> <04e74fd214a01bee0fb5ac690730cb386536cced.camel@perches.com> <8477fd32-38a5-4d66-8deb-a61b0e290df5@paulmck-laptop> <589412dd594b7efc618728fe68ad6c86f3c60878.camel@perches.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <589412dd594b7efc618728fe68ad6c86f3c60878.camel@perches.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jul 20, 2023 at 12:29:42AM -0700, Joe Perches wrote: > On Mon, 2023-07-17 at 16:34 -0700, Paul E. McKenney wrote: > > On Mon, Jul 17, 2023 at 03:34:14PM -0700, Joe Perches wrote: > > > On Mon, 2023-07-17 at 11:04 -0700, Paul E. McKenney wrote: > > > > RCU Tasks Trace is quite specialized, having been created specifically > > > > for sleepable BPF programs. Because it allows general blocking within > > > > readers, any new use of RCU Tasks Trace must take current use cases into > > > > account. Therefore, update checkpatch.pl to complain about use of any of > > > > the RCU Tasks Trace API members outside of BPF and outside of RCU itself. > > > > > > > > Cc: Andy Whitcroft (maintainer:CHECKPATCH) > > > > Cc: Joe Perches (maintainer:CHECKPATCH) > > > > Cc: Dwaipayan Ray (reviewer:CHECKPATCH) > > > > Cc: Lukas Bulwahn > > > > Cc: Alexei Starovoitov > > > > Cc: Daniel Borkmann > > > > Cc: John Fastabend > > > > Cc: > > > > Signed-off-by: Paul E. McKenney > > > > --- > > > > scripts/checkpatch.pl | 18 ++++++++++++++++++ > > > > 1 file changed, 18 insertions(+) > > > > > > > > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl > > > [] > > > > @@ -7457,6 +7457,24 @@ sub process { > > > > } > > > > } > > > > > > > > +# Complain about RCU Tasks Trace used outside of BPF (and of course, RCU). > > > > + if ($line =~ /\brcu_read_lock_trace\s*\(/ || > > > > + $line =~ /\brcu_read_lock_trace_held\s*\(/ || > > > > + $line =~ /\brcu_read_unlock_trace\s*\(/ || > > > > + $line =~ /\bcall_rcu_tasks_trace\s*\(/ || > > > > + $line =~ /\bsynchronize_rcu_tasks_trace\s*\(/ || > > > > + $line =~ /\brcu_barrier_tasks_trace\s*\(/ || > > > > + $line =~ /\brcu_request_urgent_qs_task\s*\(/) { > > > > + if ($realfile !~ m@^kernel/bpf@ && > > > > + $realfile !~ m@^include/linux/bpf@ && > > > > + $realfile !~ m@^net/bpf@ && > > > > + $realfile !~ m@^kernel/rcu@ && > > > > + $realfile !~ m@^include/linux/rcu@) { > > > > > > Functions and paths like these tend to be accreted. > > > > > > Please use a variable or 2 like: > > > > > > our $rcu_trace_funcs = qr{(?x: > > > rcu_read_lock_trace | > > > rcu_read_lock_trace_held | > > > rcu_read_unlock_trace | > > > call_rcu_tasks_trace | > > > synchronize_rcu_tasks_trace | > > > rcu_barrier_tasks_trace | > > > rcu_request_urgent_qs_task > > > )}; > > > our $rcu_trace_paths = qr{(?x: > > > kernel/bfp/ | > ^^ > kernel/bfp/ | > > (umm, oops...) > I think my original suggestion works better when I don't typo the path. Color me blind! ;-) That works much better, thank you! I will update the patch on my next rebase. Thanx, Paul > > > include/linux/bpf | > > > net/bpf/ | > > > kernel/rcu/ | > > > include/linux/rcu > > > )}; > > > > Like this? > > > > # Complain about RCU Tasks Trace used outside of BPF (and of course, RCU). > > our $rcu_trace_funcs = qr{(?x: > > rcu_read_lock_trace | > > rcu_read_lock_trace_held | > > rcu_read_unlock_trace | > > call_rcu_tasks_trace | > > synchronize_rcu_tasks_trace | > > rcu_barrier_tasks_trace | > > rcu_request_urgent_qs_task > > )}; > > our $rcu_trace_paths = qr{(?x: > > kernel/bfp/ | > > include/linux/bpf | > > net/bpf/ | > > kernel/rcu/ | > > include/linux/rcu > > )}; > > if ($line =~ /$rcu_trace_funcs/) { > > if ($realfile !~ m@^$rcu_trace_paths@) { > > WARN("RCU_TASKS_TRACE", > > "use of RCU tasks trace is incorrect outside BPF or core RCU code\n" . $herecurr); > > } > > } > > > > No, that is definitely wrong. It has lost track of the list of pathnames, > > thus complaining about uses of those functions in files where their use > > is permitted. > > > > But this seems to work: > > > > # Complain about RCU Tasks Trace used outside of BPF (and of course, RCU). > > our $rcu_trace_funcs = qr{(?x: > > rcu_read_lock_trace | > > rcu_read_lock_trace_held | > > rcu_read_unlock_trace | > > call_rcu_tasks_trace | > > synchronize_rcu_tasks_trace | > > rcu_barrier_tasks_trace | > > rcu_request_urgent_qs_task > > )}; > > if ($line =~ /\b$rcu_trace_funcs\s*\(/) { > > if ($realfile !~ m@^kernel/bpf@ && > > $realfile !~ m@^include/linux/bpf@ && > > $realfile !~ m@^net/bpf@ && > > $realfile !~ m@^kernel/rcu@ && > > $realfile !~ m@^include/linux/rcu@) { > > WARN("RCU_TASKS_TRACE", > > "use of RCU tasks trace is incorrect outside BPF or core RCU code\n" . $herecurr); > > } > > } > > > > Maybe the "^" needs to be distributed into $rcu_trace_paths? > > > > # Complain about RCU Tasks Trace used outside of BPF (and of course, RCU). > > our $rcu_trace_funcs = qr{(?x: > > rcu_read_lock_trace | > > rcu_read_lock_trace_held | > > rcu_read_unlock_trace | > > call_rcu_tasks_trace | > > synchronize_rcu_tasks_trace | > > rcu_barrier_tasks_trace | > > rcu_request_urgent_qs_task > > )}; > > our $rcu_trace_paths = qr{(?x: > > ^kernel/bfp/ | > > ^include/linux/bpf | > > ^net/bpf/ | > > ^kernel/rcu/ | > > ^include/linux/rcu > > )}; > > if ($line =~ /\b$rcu_trace_funcs\s*\(/) { > > if ($realfile !~ m@$rcu_trace_paths@) { > > WARN("RCU_TASKS_TRACE", > > "use of RCU tasks trace is incorrect outside BPF or core RCU code\n" . $herecurr); > > } > > } > > > > But no joy here, either. Which is no surprise, given that perl is > > happy to distribute the "\b" and the "\s*\(" across the elements of > > $rcu_trace_funcs. I tried a number of other variations, including > > inverting the "if" condition "(!(... =~ ...))", inverting the "if" > > condition via an empty "then" clause, replacing the "m@" with "/", > > replacing the "|" in the "qr{}" with "&", and a few others. > > > > Again, listing the pathnames explicitly in the second "if" condition > > works just fine. > > > > Help? > > > > Thanx, Paul >