Skip to content

Commit

Permalink
checkpatch: Discourage a new use of rtnl_lock() variants.
Browse files Browse the repository at this point in the history
rtnl_lock() is a "Big Kernel Lock" in the networking slow path
and still serialises most of RTM_(NEW|DEL|SET)* rtnetlink requests.

Commit 76aed95 ("rtnetlink: Add per-netns RTNL.") started a
very large, in-progress, effort to make the RTNL lock scope per
network namespace.

However, there are still some patches that newly use rtnl_lock(),
which is now discouraged, and we need to revisit it later.

Let's warn about the case by checkpatch.

The target functions are as follows:

  * rtnl_lock()
  * rtnl_trylock()
  * rtnl_lock_interruptible()
  * rtnl_lock_killable()

and the warning will be like:

  WARNING: A new use of rtnl_lock() variants is discouraged, try to use rtnl_net_lock(net) variants
  torvalds#18: FILE: net/core/rtnetlink.c:79:
  +	rtnl_lock();

Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Signed-off-by: NipaLocal <nipa@local>
  • Loading branch information
q2ven authored and NipaLocal committed Feb 14, 2025
1 parent 887ac8d commit 6e49341
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions scripts/checkpatch.pl
Original file line number Diff line number Diff line change
Expand Up @@ -6995,6 +6995,12 @@ sub process {
# }
# }

# A new use of rtnl_lock() is discouraged as it's being converted to rtnl_net_lock(net).
if ($line =~ /\brtnl_(try)?lock(_interruptible|_killable)?\s*\(\)/) {
WARN("rtnl_lock()",
"A new use of rtnl_lock() variants is discouraged, try to use rtnl_net_lock(net) variants\n" . $herecurr);
}

# strcpy uses that should likely be strscpy
if ($line =~ /\bstrcpy\s*\(/) {
WARN("STRCPY",
Expand Down

0 comments on commit 6e49341

Please sign in to comment.