diff mbox series

[net-next] net: minor __dev_alloc_name() optimization

Message ID 20220203064609.3242863-1-eric.dumazet@gmail.com (mailing list archive)
State Accepted
Commit 25ee1660a590d9b1ea209f92deb212ec4690547e
Delegated to: Netdev Maintainers
Headers show
Series [net-next] net: minor __dev_alloc_name() optimization | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 7 this patch: 7
netdev/cc_maintainers success CCed 4 of 4 maintainers
netdev/build_clang success Errors and warnings before: 18 this patch: 18
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 12 this patch: 12
netdev/checkpatch warning WARNING: 'unecessary' may be misspelled - perhaps 'unnecessary'?
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Eric Dumazet Feb. 3, 2022, 6:46 a.m. UTC
From: Eric Dumazet <edumazet@google.com>

__dev_alloc_name() allocates a private zeroed page,
then sets bits in it while iterating through net devices.

It can use __set_bit() to avoid unecessary locked operations.

Signed-off-by: Eric Dumazet <edumazet@google.com>
---
 net/core/dev.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

patchwork-bot+netdevbpf@kernel.org Feb. 4, 2022, 3:20 a.m. UTC | #1
Hello:

This patch was applied to netdev/net-next.git (master)
by Jakub Kicinski <kuba@kernel.org>:

On Wed,  2 Feb 2022 22:46:09 -0800 you wrote:
> From: Eric Dumazet <edumazet@google.com>
> 
> __dev_alloc_name() allocates a private zeroed page,
> then sets bits in it while iterating through net devices.
> 
> It can use __set_bit() to avoid unecessary locked operations.
> 
> [...]

Here is the summary with links:
  - [net-next] net: minor __dev_alloc_name() optimization
    https://git.kernel.org/netdev/net-next/c/25ee1660a590

You are awesome, thank you!
Stephen Hemminger Feb. 4, 2022, 7:57 p.m. UTC | #2
On Wed,  2 Feb 2022 22:46:09 -0800
Eric Dumazet <eric.dumazet@gmail.com> wrote:

> From: Eric Dumazet <edumazet@google.com>
> 
> __dev_alloc_name() allocates a private zeroed page,
> then sets bits in it while iterating through net devices.
> 
> It can use __set_bit() to avoid unecessary locked operations.
> 
> Signed-off-by: Eric Dumazet <edumazet@google.com>

That looks correct.


Acked-by: Stephen Hemminger <stephen@networkplumber.org>
diff mbox series

Patch

diff --git a/net/core/dev.c b/net/core/dev.c
index 1baab07820f65f9bcf88a6d73e2c9ff741d33c18..f79744d99413434ad28b26dee9aeeb2893a0e3ae 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -1037,7 +1037,7 @@  static int __dev_alloc_name(struct net *net, const char *name, char *buf)
 				/*  avoid cases where sscanf is not exact inverse of printf */
 				snprintf(buf, IFNAMSIZ, name, i);
 				if (!strncmp(buf, name_node->name, IFNAMSIZ))
-					set_bit(i, inuse);
+					__set_bit(i, inuse);
 			}
 			if (!sscanf(d->name, name, &i))
 				continue;
@@ -1047,7 +1047,7 @@  static int __dev_alloc_name(struct net *net, const char *name, char *buf)
 			/*  avoid cases where sscanf is not exact inverse of printf */
 			snprintf(buf, IFNAMSIZ, name, i);
 			if (!strncmp(buf, d->name, IFNAMSIZ))
-				set_bit(i, inuse);
+				__set_bit(i, inuse);
 		}
 
 		i = find_first_zero_bit(inuse, max_netdevices);