diff mbox series

net: spider_net: Use non-atomic bitmap API when applicable

Message ID 3de0792f5088f00d135c835df6c19e63ae95f5d2.1638026251.git.christophe.jaillet@wanadoo.fr (mailing list archive)
State Accepted
Delegated to: Netdev Maintainers
Headers show
Series net: spider_net: Use non-atomic bitmap API when applicable | 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: 0 this patch: 0
netdev/cc_maintainers success CCed 6 of 6 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
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: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 30 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. 27, 2021, 3:18 p.m. UTC
No concurrent access is possible when a bitmap is local to a function.
So prefer the non-atomic functions to save a few cycles.
   - replace a 'for' loop by an equivalent non-atomic 'bitmap_fill()' call
   - use '__set_bit()'

While at it, clear the 'bitmask' bitmap only when needed.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
This patch is *not* compile tested. I don't have the needed cross compiling
tool chain.
---
 drivers/net/ethernet/toshiba/spider_net.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

Comments

Geoff Levand Dec. 4, 2021, 3:47 p.m. UTC | #1
Hi Christophe,

On 11/27/21 7:18 AM, Christophe JAILLET wrote:
> No concurrent access is possible when a bitmap is local to a function.
> So prefer the non-atomic functions to save a few cycles.
>    - replace a 'for' loop by an equivalent non-atomic 'bitmap_fill()' call
>    - use '__set_bit()'
> 
> While at it, clear the 'bitmask' bitmap only when needed.
> 
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> This patch is *not* compile tested. I don't have the needed cross compiling
> tool chain.
> ---
>  drivers/net/ethernet/toshiba/spider_net.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)

As I mentioned, my tdd-builder Docker image has a
gcc-powerpc-linux-gnu cross compiler that can be used to build
a ppc64 kernel:

  https://hub.docker.com/r/glevand/tdd-builder

I also have a few helper scripts to run the container and cross
compile a kernel:

  https://github.com/glevand/tdd--docker/blob/master/builder/run-builder.sh
  https://github.com/glevand/tdd-project/blob/master/scripts/build-linux-kernel.sh


I applied your patch to v5.16-rc3 and no spider_net warnings
or errors were seen when building with ppc64_defconfig. Thanks
for your contribution.

Acked-by: Geoff Levand <geoff@infradead.org>
diff mbox series

Patch

diff --git a/drivers/net/ethernet/toshiba/spider_net.c b/drivers/net/ethernet/toshiba/spider_net.c
index f50f9a43d3ea..f47b8358669d 100644
--- a/drivers/net/ethernet/toshiba/spider_net.c
+++ b/drivers/net/ethernet/toshiba/spider_net.c
@@ -595,24 +595,24 @@  spider_net_set_multi(struct net_device *netdev)
 	int i;
 	u32 reg;
 	struct spider_net_card *card = netdev_priv(netdev);
-	DECLARE_BITMAP(bitmask, SPIDER_NET_MULTICAST_HASHES) = {};
+	DECLARE_BITMAP(bitmask, SPIDER_NET_MULTICAST_HASHES);
 
 	spider_net_set_promisc(card);
 
 	if (netdev->flags & IFF_ALLMULTI) {
-		for (i = 0; i < SPIDER_NET_MULTICAST_HASHES; i++) {
-			set_bit(i, bitmask);
-		}
+		bitmap_fill(bitmask, SPIDER_NET_MULTICAST_HASHES);
 		goto write_hash;
 	}
 
+	bitmap_zero(bitmask, SPIDER_NET_MULTICAST_HASHES);
+
 	/* well, we know, what the broadcast hash value is: it's xfd
 	hash = spider_net_get_multicast_hash(netdev, netdev->broadcast); */
-	set_bit(0xfd, bitmask);
+	__set_bit(0xfd, bitmask);
 
 	netdev_for_each_mc_addr(ha, netdev) {
 		hash = spider_net_get_multicast_hash(netdev, ha->addr);
-		set_bit(hash, bitmask);
+		__set_bit(hash, bitmask);
 	}
 
 write_hash: