All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] checkpatch: Error out if deprecated RCU API used
@ 2023-03-07  3:04 Joel Fernandes (Google)
  2023-03-07  3:08 ` Joe Perches
  0 siblings, 1 reply; 9+ messages in thread
From: Joel Fernandes (Google) @ 2023-03-07  3:04 UTC (permalink / raw)
  To: linux-kernel
  Cc: Joel Fernandes (Google), Andy Whitcroft, Dwaipayan Ray,
	Joe Perches, Lukas Bulwahn, Paul E. McKenney, RCU,
	Oleksiy Avramchenko, Jens Axboe, Philipp Reisner, Bryan Tan,
	Steven Rostedt, Eric Dumazet, Bob Pearson, Ariel Levkovich,
	Theodore Ts'o, Julian Anastasov, Uladzislau Rezki

Single-argument kvfree_rcu() usage is being deprecated [1] [2] as it is
error-prone. However, till all users are converted, we would like to introduce
checkpatch errors for new patches submitted.

This patch adds support for the same. Tested with a trial patch.

For now, we are only considering usages that don't have compound
nesting, for example ignore: kvfree_rcu( (rcu_head_obj), rcu_head_name).
This is sufficient as such usages are unlikely.

Once all users are converted and we remove the old API, we can also revert this
checkpatch patch then.

[1] https://lore.kernel.org/rcu/CAEXW_YRhHaVuq+5f+VgCZM=SF+9xO+QXaxe0yE7oA9iCXK-XPg@mail.gmail.com/
[2] https://lore.kernel.org/rcu/CAEXW_YSY=q2_uaE2qo4XSGjzs4+C102YMVJ7kWwuT5LGmJGGew@mail.gmail.com/

Signed-off-by: Joel Fernandes (Google) <joel@joelfernandes.org>
---
 scripts/checkpatch.pl |  9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index bd44d12965c9..9da0a3cb1615 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -6388,6 +6388,15 @@ sub process {
 			}
 		}
 
+# check for soon-to-be-deprecated single-argument k[v]free_rcu() API
+		if ($line =~ /\bk[v]?free_rcu\s*\([^(]+\)/) {
+			if ($line =~ /\bk[v]?free_rcu\s*\([^,]+\)/) {
+				ERROR("DEPRECATED_API",
+				      "Single-argument k[v]free_rcu() API is deprecated, please call the API with an rcu_head object passed, like: k[v]free_rcu(object_ptr, rcu_head_name);  " . $herecurr);
+			}
+		}
+
+
 # check for unnecessary "Out of Memory" messages
 		if ($line =~ /^\+.*\b$logFunctions\s*\(/ &&
 		    $prevline =~ /^[ \+]\s*if\s*\(\s*(\!\s*|NULL\s*==\s*)?($Lval)(\s*==\s*NULL\s*)?\s*\)/ &&
-- 
2.40.0.rc0.216.gc4246ad0f0-goog


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2023-03-07  5:32 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-07  3:04 [PATCH] checkpatch: Error out if deprecated RCU API used Joel Fernandes (Google)
2023-03-07  3:08 ` Joe Perches
2023-03-07  3:10   ` Joel Fernandes
2023-03-07  3:23     ` Joe Perches
2023-03-07  4:41       ` Joel Fernandes
2023-03-07  4:53         ` Joe Perches
2023-03-07  5:11           ` Joel Fernandes
2023-03-07  5:22             ` Joe Perches
2023-03-07  5:32               ` Joel Fernandes

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.