netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] net: minor __dev_alloc_name() optimization
@ 2022-02-03  6:46 Eric Dumazet
  2022-02-04  3:20 ` patchwork-bot+netdevbpf
  2022-02-04 19:57 ` Stephen Hemminger
  0 siblings, 2 replies; 3+ messages in thread
From: Eric Dumazet @ 2022-02-03  6:46 UTC (permalink / raw)
  To: David S . Miller, Jakub Kicinski; +Cc: netdev, Eric Dumazet, Eric Dumazet

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(-)

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);
-- 
2.35.0.rc2.247.g8bbb082509-goog


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

* Re: [PATCH net-next] net: minor __dev_alloc_name() optimization
  2022-02-03  6:46 [PATCH net-next] net: minor __dev_alloc_name() optimization Eric Dumazet
@ 2022-02-04  3:20 ` patchwork-bot+netdevbpf
  2022-02-04 19:57 ` Stephen Hemminger
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-02-04  3:20 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: davem, kuba, netdev, edumazet

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!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

* Re: [PATCH net-next] net: minor __dev_alloc_name() optimization
  2022-02-03  6:46 [PATCH net-next] net: minor __dev_alloc_name() optimization Eric Dumazet
  2022-02-04  3:20 ` patchwork-bot+netdevbpf
@ 2022-02-04 19:57 ` Stephen Hemminger
  1 sibling, 0 replies; 3+ messages in thread
From: Stephen Hemminger @ 2022-02-04 19:57 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: David S . Miller, Jakub Kicinski, netdev, Eric Dumazet

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>


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

end of thread, other threads:[~2022-02-04 19:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-03  6:46 [PATCH net-next] net: minor __dev_alloc_name() optimization Eric Dumazet
2022-02-04  3:20 ` patchwork-bot+netdevbpf
2022-02-04 19:57 ` Stephen Hemminger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).