diff mbox series

[v2,4/4] net: fix opencoded for_each_and_bit() in __netif_set_xps_queue()

Message ID 20221013234349.1165689-5-yury.norov@gmail.com (mailing list archive)
State Deferred
Delegated to: Netdev Maintainers
Headers show
Series net: drop netif_attrmask_next*() | expand

Checks

Context Check Description
netdev/tree_selection success Guessed tree name to be net-next, async
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 Series has a cover letter
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: 4341 this patch: 4341
netdev/cc_maintainers success CCed 6 of 6 maintainers
netdev/build_clang fail Errors and warnings before: 1058 this patch: 1058
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 4528 this patch: 4528
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 61 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Yury Norov Oct. 13, 2022, 11:43 p.m. UTC
Replace opencoded bitmap traversing and drop unused
netif_attrmask_next*() functions

Signed-off-by: Yury Norov <yury.norov@gmail.com>
---
 include/linux/netdevice.h | 46 ---------------------------------------
 net/core/dev.c            |  3 +--
 2 files changed, 1 insertion(+), 48 deletions(-)

Comments

Michael S. Tsirkin Oct. 14, 2022, 9:38 a.m. UTC | #1
On Thu, Oct 13, 2022 at 04:43:48PM -0700, Yury Norov wrote:
> Replace opencoded bitmap traversing and drop unused
> netif_attrmask_next*() functions
> 
> Signed-off-by: Yury Norov <yury.norov@gmail.com>

I think you want to document, here, that this fixes a warning.
Additionally, add a Fixes: tag.


> ---
>  include/linux/netdevice.h | 46 ---------------------------------------
>  net/core/dev.c            |  3 +--
>  2 files changed, 1 insertion(+), 48 deletions(-)
> 
> diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
> index 53d738f66159..5db2b6de7308 100644
> --- a/include/linux/netdevice.h
> +++ b/include/linux/netdevice.h
> @@ -3648,52 +3648,6 @@ static inline bool netif_attr_test_online(unsigned long j,
>  
>  	return (j < nr_bits);
>  }
> -
> -/**
> - *	netif_attrmask_next - get the next CPU/Rx queue in a cpu/Rx queues mask
> - *	@n: CPU/Rx queue index
> - *	@srcp: the cpumask/Rx queue mask pointer
> - *	@nr_bits: number of bits in the bitmask
> - *
> - * Returns >= nr_bits if no further CPUs/Rx queues set.
> - */
> -static inline unsigned int netif_attrmask_next(int n, const unsigned long *srcp,
> -					       unsigned int nr_bits)
> -{
> -	/* n is a prior cpu */
> -	cpu_max_bits_warn(n + 1, nr_bits);
> -
> -	if (srcp)
> -		return find_next_bit(srcp, nr_bits, n + 1);
> -
> -	return n + 1;
> -}
> -
> -/**
> - *	netif_attrmask_next_and - get the next CPU/Rx queue in \*src1p & \*src2p
> - *	@n: CPU/Rx queue index
> - *	@src1p: the first CPUs/Rx queues mask pointer
> - *	@src2p: the second CPUs/Rx queues mask pointer
> - *	@nr_bits: number of bits in the bitmask
> - *
> - * Returns >= nr_bits if no further CPUs/Rx queues set in both.
> - */
> -static inline int netif_attrmask_next_and(int n, const unsigned long *src1p,
> -					  const unsigned long *src2p,
> -					  unsigned int nr_bits)
> -{
> -	/* n is a prior cpu */
> -	cpu_max_bits_warn(n + 1, nr_bits);
> -
> -	if (src1p && src2p)
> -		return find_next_and_bit(src1p, src2p, nr_bits, n + 1);
> -	else if (src1p)
> -		return find_next_bit(src1p, nr_bits, n + 1);
> -	else if (src2p)
> -		return find_next_bit(src2p, nr_bits, n + 1);
> -
> -	return n + 1;
> -}
>  #else
>  static inline int netif_set_xps_queue(struct net_device *dev,
>  				      const struct cpumask *mask,
> diff --git a/net/core/dev.c b/net/core/dev.c
> index 8049e2ff11a5..b0fb592d51da 100644
> --- a/net/core/dev.c
> +++ b/net/core/dev.c
> @@ -2592,8 +2592,7 @@ int __netif_set_xps_queue(struct net_device *dev, const unsigned long *mask,
>  		copy = true;
>  
>  	/* allocate memory for queue storage */
> -	for (j = -1; j = netif_attrmask_next_and(j, online_mask, mask, nr_ids),
> -	     j < nr_ids;) {
> +	for_each_and_bit(j, online_mask, mask ? : online_mask, nr_ids) {
>  		if (!new_dev_maps) {
>  			new_dev_maps = kzalloc(maps_sz, GFP_KERNEL);
>  			if (!new_dev_maps)
> -- 
> 2.34.1
diff mbox series

Patch

diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 53d738f66159..5db2b6de7308 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -3648,52 +3648,6 @@  static inline bool netif_attr_test_online(unsigned long j,
 
 	return (j < nr_bits);
 }
-
-/**
- *	netif_attrmask_next - get the next CPU/Rx queue in a cpu/Rx queues mask
- *	@n: CPU/Rx queue index
- *	@srcp: the cpumask/Rx queue mask pointer
- *	@nr_bits: number of bits in the bitmask
- *
- * Returns >= nr_bits if no further CPUs/Rx queues set.
- */
-static inline unsigned int netif_attrmask_next(int n, const unsigned long *srcp,
-					       unsigned int nr_bits)
-{
-	/* n is a prior cpu */
-	cpu_max_bits_warn(n + 1, nr_bits);
-
-	if (srcp)
-		return find_next_bit(srcp, nr_bits, n + 1);
-
-	return n + 1;
-}
-
-/**
- *	netif_attrmask_next_and - get the next CPU/Rx queue in \*src1p & \*src2p
- *	@n: CPU/Rx queue index
- *	@src1p: the first CPUs/Rx queues mask pointer
- *	@src2p: the second CPUs/Rx queues mask pointer
- *	@nr_bits: number of bits in the bitmask
- *
- * Returns >= nr_bits if no further CPUs/Rx queues set in both.
- */
-static inline int netif_attrmask_next_and(int n, const unsigned long *src1p,
-					  const unsigned long *src2p,
-					  unsigned int nr_bits)
-{
-	/* n is a prior cpu */
-	cpu_max_bits_warn(n + 1, nr_bits);
-
-	if (src1p && src2p)
-		return find_next_and_bit(src1p, src2p, nr_bits, n + 1);
-	else if (src1p)
-		return find_next_bit(src1p, nr_bits, n + 1);
-	else if (src2p)
-		return find_next_bit(src2p, nr_bits, n + 1);
-
-	return n + 1;
-}
 #else
 static inline int netif_set_xps_queue(struct net_device *dev,
 				      const struct cpumask *mask,
diff --git a/net/core/dev.c b/net/core/dev.c
index 8049e2ff11a5..b0fb592d51da 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -2592,8 +2592,7 @@  int __netif_set_xps_queue(struct net_device *dev, const unsigned long *mask,
 		copy = true;
 
 	/* allocate memory for queue storage */
-	for (j = -1; j = netif_attrmask_next_and(j, online_mask, mask, nr_ids),
-	     j < nr_ids;) {
+	for_each_and_bit(j, online_mask, mask ? : online_mask, nr_ids) {
 		if (!new_dev_maps) {
 			new_dev_maps = kzalloc(maps_sz, GFP_KERNEL);
 			if (!new_dev_maps)