Skip to contentSkip to conversation

net: minor __dev_alloc_name() optimization

PATCH Applied Eric Dumazet 3 participants 3 messages Feb 3, 2022 – Feb 4, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: minor __dev_alloc_name() optimization

From: Eric Dumazet <[email protected]>

__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.

---
 net/core/dev.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
net/core/dev.c +2 -2
index 1baab07820f65f9bcf88a6d73e2c9ff741d33c18..f79744d99413434ad28b26dee9aeeb2893a0e3ae 100644
@@ -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);
Signature · 1 line
2.35.0.rc2.247.g8bbb082509-goog
#1 lore raw
This patch was applied to netdev/net-next.git (master) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (master) by Jakub Kicinski <[email protected]>:

Quoted 8 lines · On Wed, 2 Feb 2022 22:46:09 -0800 you wrote:

From: Eric Dumazet <[email protected]>

__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!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
Acked-by on v1 1/1
#2 lore raw
In reply to Eric Dumazet
Quoted 8 lines · On Wed, 2 Feb 2022 22:46:09 -0800 Eric Dumazet <[email protected]> wrote:

From: Eric Dumazet <[email protected]>

__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.

That looks correct.