Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp9224690rwp; Thu, 20 Jul 2023 01:13:43 -0700 (PDT) X-Google-Smtp-Source: APBJJlGMFf2T+eJ6NffC/LWiR9HByswd7T6RajcCXGd87QoHYvp3l6Ns6RrDOaQWgPiWIji5b5k3 X-Received: by 2002:a17:907:75c3:b0:973:71c3:8b21 with SMTP id jl3-20020a17090775c300b0097371c38b21mr4255621ejc.72.1689840823674; Thu, 20 Jul 2023 01:13:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689840823; cv=none; d=google.com; s=arc-20160816; b=bZSfGVd61/jOcAqiYK0qFhF0s0kBcv4oljwtAoO/RQpHxQoKvFvUNUt9fsaxWo6kcj 2fNnKSoYxFWEXQvlDOKxu0jm4wdro1X11pTDDLTzOr0/xsivHO9sUmFqqXxuB2RDRbQa r4IOFrggZO7sVaduoUp9lG9Re4/hsFe3ZXLxObsLd4OE6AKnnimqeLKAFcnTIxF2PUGc KuOGujB8B1BW/STcflcE/6yslwuhRctjQ2A6gp4BqVoqzAx+UyscEjLUCBVG2EzQYMoL a/48by1vjHVkM+Frcls0yr0+l7Lek3i4GKNg2ek8JwUXEiJCsCL8ha0eE0R5uBtKYGIk JUIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent :content-transfer-encoding:references:in-reply-to:date:cc:to:from :subject:message-id; bh=3P9bui9yInCMPwJ1K+jxbTOIV3bD/lLI1x6X5V2sEbU=; fh=eAC7o9mhgHPZ7dGsOWnjQmX7EP9PWTy3gYhRrLbC/Cw=; b=0sd/FHXJnWVQNDEJBqP8lSS1YOzkhjHLoKtRmYIph06Y0wqp328hcMTubif/0bOmJx FzuS7/odM9QATx1sPmR1v06OvaC6Nlxd4/dPURfnkvG6drnB+jfVk/2Mr3wzTkSfEywJ AIQ84cB6lFdnqlv2lX5vK6pcOkNo3mzqUYIhRUOewRHyoFNfonr2q38fbc6awnN6LKlj 0uixXyZZSeCiCu1GfGRDUzpFIlYqOD03Y95DJdr5vyoaXi+pqqZ0lNOkFS94/IXe2rhJ ULnSBRCi+/Ez7tsGukn3q2iMW/yGpgGiNG+MFxYnqB9c5Xbg9WrY50mRBY+qDZlONeNN xltA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y7-20020a170906914700b0098722b28a18si344669ejw.458.2023.07.20.01.13.18; Thu, 20 Jul 2023 01:13:43 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230477AbjGTH3y convert rfc822-to-8bit (ORCPT + 99 others); Thu, 20 Jul 2023 03:29:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230140AbjGTH3w (ORCPT ); Thu, 20 Jul 2023 03:29:52 -0400 Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C4E02118; Thu, 20 Jul 2023 00:29:50 -0700 (PDT) Received: from omf20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 5A86E401AC; Thu, 20 Jul 2023 07:29:48 +0000 (UTC) Received: from [HIDDEN] (Authenticated sender: joe@perches.com) by omf20.hostedemail.com (Postfix) with ESMTPA id E4DEC20028; Thu, 20 Jul 2023 07:29:43 +0000 (UTC) Message-ID: <589412dd594b7efc618728fe68ad6c86f3c60878.camel@perches.com> Subject: Re: [PATCH rcu 5/5] checkpatch: Complain about unexpected uses of RCU Tasks Trace From: Joe Perches To: paulmck@kernel.org 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 Date: Thu, 20 Jul 2023 00:29:42 -0700 In-Reply-To: <8477fd32-38a5-4d66-8deb-a61b0e290df5@paulmck-laptop> References: <20230717180454.1097714-5-paulmck@kernel.org> <04e74fd214a01bee0fb5ac690730cb386536cced.camel@perches.com> <8477fd32-38a5-4d66-8deb-a61b0e290df5@paulmck-laptop> Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8BIT User-Agent: Evolution 3.48.4 (3.48.4-1.fc38) MIME-Version: 1.0 X-Stat-Signature: cijt47qa3gutgm4mse8f61ihc156sytj X-Rspamd-Server: rspamout07 X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS, SPF_NONE,T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY autolearn=no autolearn_force=no version=3.4.6 X-Rspamd-Queue-Id: E4DEC20028 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Session-ID: U2FsdGVkX19bWiq7WZ/5O5QREbocb7bKaf2iJ1IJsm8= X-HE-Tag: 1689838183-320032 X-HE-Meta: U2FsdGVkX1/WarbZk931biGimJZzUmR0O/BUkC16MDMYi+FZCE9vkChV5+1oQv6fW7ys3SKQXW6ny8ivNo+4hr59Zu0HwPgQVExCwjMOWdBjkXj1wru2zKknxwNVBrYhpYn3niGT0jMfQaKKf5f2K+lZNMiT/Tuu0zydTf+uBcVFdyzJpgNCqTHtB/RwZNqaaJH3+WWoKuBdrBdTfOyTyol2UlAOv9t7t6x1uwPo33MeFYV3deDRqHFbev2Xfx3cBsG+gkVwiwRtStG89YFKfgTozhO0ixB3fYkRsV8GMqTEQcmqZgsAxa6w76geQUWVpfdy6KJHLa/FHKsZ+1wKwkhWHVT9ncBcctS0nvMkNa9f8w75v8m2Iwpm3CW7x51aSRX2TcwtlxR5eKcfSI9NMEFRuusF334j39b6nkzTbutvUyxguv6WODZhCYB35codJJ0JdujRE//8K4pa6ZyjVJevUpcc5HdLH3YoN5mccX05SDuyrKmHmx93iyb6J6K98o592DeGGMU1+AQYQZNLni5OtqEPJxqhM90T6jyrh+HXqY829BrUsXQFRu6vlMqmmQpeC1NKC3I= 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 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. > > 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