Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: minor __dev_alloc_name() optimization

__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 unnecessary locked operations.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Link: https://lore.kernel.org/r/20220203064609.3242863-1-eric.dumazet@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Eric Dumazet and committed by
Jakub Kicinski
25ee1660 c59400a6

+2 -2
+2 -2
net/core/dev.c
··· 1037 1037 /* avoid cases where sscanf is not exact inverse of printf */ 1038 1038 snprintf(buf, IFNAMSIZ, name, i); 1039 1039 if (!strncmp(buf, name_node->name, IFNAMSIZ)) 1040 - set_bit(i, inuse); 1040 + __set_bit(i, inuse); 1041 1041 } 1042 1042 if (!sscanf(d->name, name, &i)) 1043 1043 continue; ··· 1047 1047 /* avoid cases where sscanf is not exact inverse of printf */ 1048 1048 snprintf(buf, IFNAMSIZ, name, i); 1049 1049 if (!strncmp(buf, d->name, IFNAMSIZ)) 1050 - set_bit(i, inuse); 1050 + __set_bit(i, inuse); 1051 1051 } 1052 1052 1053 1053 i = find_first_zero_bit(inuse, max_netdevices);