diff mbox series

net-sysfs: Slightly optimize 'xps_queue_show()'

Message ID 498b1a0a7a0cba019c9d95693cd489827168b79e.1637517554.git.christophe.jaillet@wanadoo.fr (mailing list archive)
State Accepted
Commit 08a7abf4aff1a42290fd20ff7a5fa8a3ff5f90e7
Delegated to: Netdev Maintainers
Headers show
Series net-sysfs: Slightly optimize 'xps_queue_show()' | expand

Checks

Context Check Description
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix warning Target tree name not specified in the subject
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: 2 this patch: 2
netdev/cc_maintainers success CCed 5 of 5 maintainers
netdev/build_clang success Errors and warnings before: 22 this patch: 22
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: 6 this patch: 6
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 8 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/tree_selection success Guessing tree name failed - patch did not apply

Commit Message

Christophe JAILLET Nov. 21, 2021, 6:01 p.m. UTC
The 'mask' bitmap is local to this function. So the non-atomic
'__set_bit()' can be used to save a few cycles.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 net/core/net-sysfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

patchwork-bot+netdevbpf@kernel.org Nov. 22, 2021, 3 p.m. UTC | #1
Hello:

This patch was applied to netdev/net-next.git (master)
by David S. Miller <davem@davemloft.net>:

On Sun, 21 Nov 2021 19:01:03 +0100 you wrote:
> The 'mask' bitmap is local to this function. So the non-atomic
> '__set_bit()' can be used to save a few cycles.
> 
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
>  net/core/net-sysfs.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Here is the summary with links:
  - net-sysfs: Slightly optimize 'xps_queue_show()'
    https://git.kernel.org/netdev/net-next/c/08a7abf4aff1

You are awesome, thank you!
Xin Long Nov. 22, 2021, 3:23 p.m. UTC | #2
On Sun, Nov 21, 2021 at 2:38 PM Christophe JAILLET
<christophe.jaillet@wanadoo.fr> wrote:
>
> The 'mask' bitmap is local to this function. So the non-atomic
> '__set_bit()' can be used to save a few cycles.
>
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
>  net/core/net-sysfs.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
> index 9c01c642cf9e..3be3f4a6add3 100644
> --- a/net/core/net-sysfs.c
> +++ b/net/core/net-sysfs.c
> @@ -1452,7 +1452,7 @@ static ssize_t xps_queue_show(struct net_device *dev, unsigned int index,
>
>                 for (i = map->len; i--;) {
>                         if (map->queues[i] == index) {
> -                               set_bit(j, mask);
> +                               __set_bit(j, mask);
>                                 break;
>                         }
>                 }
> --
> 2.30.2
>
The similar optimization can seem to be done in br_vlan.c and br_if.c as well.
Christophe JAILLET Nov. 22, 2021, 7:10 p.m. UTC | #3
Le 22/11/2021 à 16:23, Xin Long a écrit :
> On Sun, Nov 21, 2021 at 2:38 PM Christophe JAILLET
> <christophe.jaillet@wanadoo.fr> wrote:
>>
>> The 'mask' bitmap is local to this function. So the non-atomic
>> '__set_bit()' can be used to save a few cycles.
>>
>> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
>> ---
>>   net/core/net-sysfs.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
>> index 9c01c642cf9e..3be3f4a6add3 100644
>> --- a/net/core/net-sysfs.c
>> +++ b/net/core/net-sysfs.c
>> @@ -1452,7 +1452,7 @@ static ssize_t xps_queue_show(struct net_device *dev, unsigned int index,
>>
>>                  for (i = map->len; i--;) {
>>                          if (map->queues[i] == index) {
>> -                               set_bit(j, mask);
>> +                               __set_bit(j, mask);
>>                                  break;
>>                          }
>>                  }
>> --
>> 2.30.2
>>
> The similar optimization can seem to be done in br_vlan.c and br_if.c as well.
> 

Hi,

br_if.c should be fixed in cc0be1ad686f.

br_vlan.c was not spotted by my heuristic (a set of grep, while looking 
at something else). So, thanks for your feedback.

Feel free to propose a patch for it, it was not part of my todo list :)

If you prefer, I can also send a patch. Let me know.

CJ
diff mbox series

Patch

diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
index 9c01c642cf9e..3be3f4a6add3 100644
--- a/net/core/net-sysfs.c
+++ b/net/core/net-sysfs.c
@@ -1452,7 +1452,7 @@  static ssize_t xps_queue_show(struct net_device *dev, unsigned int index,
 
 		for (i = map->len; i--;) {
 			if (map->queues[i] == index) {
-				set_bit(j, mask);
+				__set_bit(j, mask);
 				break;
 			}
 		}