checkpatch: Error out if deprecated RCU API used
authorJoel Fernandes (Google) <joel@joelfernandes.org>
Mon, 6 Mar 2023 14:33:58 +0000 (14:33 +0000)
committerJoel Fernandes (Google) <joel@joelfernandes.org>
Wed, 5 Apr 2023 13:48:04 +0000 (13:48 +0000)
Single-argument kvfree_rcu() usage is being deprecated [1] [2]. 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/

Acked-by: Paul E. McKenney <paulmck@kernel.org>
Signed-off-by: Joel Fernandes (Google) <joel@joelfernandes.org>
scripts/checkpatch.pl

index bd44d12965c98e99042938880a17730c6dfac5c9..4bfbe3c9fa15fa0828ca33b282d9c169d37aab80 100755 (executable)
@@ -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 pass rcu_head object or call k[v]free_rcu_mightsleep()." . $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*\)/ &&