Skip to contentSkip to conversation

xdp: remove the functions xsk_map_inc and xsk_map_put

PATCH Applied Zhu Yanjun 3 participants 3 messages Nov 26, 2020 – Nov 27, 2020

Subsystems (3)
lore
Share & tools
lore

Zhu Yanjun

author
#0 lore raw

PATCH v5 1/1 xdp: remove the functions xsk_map_inc and xsk_map_put

From: Zhu Yanjun <[email protected]>

The functions xsk_map_put and xsk_map_inc are simple wrappers. As such, replacing these functions with the functions bpf_map_inc and bpf_map_put and removing some test codes.

Fixes d20a1676df7e ("xsk: Move xskmap.c to net/xdp/")
---
 net/xdp/xsk.c    |  4 ++--
 net/xdp/xsk.h    |  2 --
 net/xdp/xskmap.c | 20 ++------------------
 3 files changed, 4 insertions(+), 22 deletions(-)
net/xdp/xsk.c +2 -2
index cfbec3989a76..4f0250f5d676 100644
@@ -548,7 +548,7 @@ static struct xsk_map *xsk_get_map_list_entry(struct xdp_sock *xs,
 	node = list_first_entry_or_null(&xs->map_list, struct xsk_map_node,
 					node);
 	if (node) {
-		WARN_ON(xsk_map_inc(node->map));
+		bpf_map_inc(&node->map->map);
 		map = node->map;
 		*map_entry = node->map_entry;
 	}
@@ -578,7 +578,7 @@ static void xsk_delete_from_maps(struct xdp_sock *xs)
 
 	while ((map = xsk_get_map_list_entry(xs, &map_entry))) {
 		xsk_map_try_sock_delete(map, xs, map_entry);
-		xsk_map_put(map);
+		bpf_map_put(&map->map);
 	}
 }
 
net/xdp/xsk.h +0 -2
index b9e896cee5bb..edcf249ad1f1 100644
@@ -41,8 +41,6 @@ static inline struct xdp_sock *xdp_sk(struct sock *sk)
 
 void xsk_map_try_sock_delete(struct xsk_map *map, struct xdp_sock *xs,
 			     struct xdp_sock **map_entry);
-int xsk_map_inc(struct xsk_map *map);
-void xsk_map_put(struct xsk_map *map);
 void xsk_clear_pool_at_qid(struct net_device *dev, u16 queue_id);
 int xsk_reg_pool_at_qid(struct net_device *dev, struct xsk_buff_pool *pool,
 			u16 queue_id);
net/xdp/xskmap.c +2 -18
index 49da2b8ace8b..66231ba6c348 100644
@@ -11,32 +11,16 @@
 
 #include "xsk.h"
 
-int xsk_map_inc(struct xsk_map *map)
-{
-	bpf_map_inc(&map->map);
-	return 0;
-}
-
-void xsk_map_put(struct xsk_map *map)
-{
-	bpf_map_put(&map->map);
-}
-
 static struct xsk_map_node *xsk_map_node_alloc(struct xsk_map *map,
 					       struct xdp_sock **map_entry)
 {
 	struct xsk_map_node *node;
-	int err;
 
 	node = kzalloc(sizeof(*node), GFP_ATOMIC | __GFP_NOWARN);
 	if (!node)
 		return ERR_PTR(-ENOMEM);
 
-	err = xsk_map_inc(map);
-	if (err) {
-		kfree(node);
-		return ERR_PTR(err);
-	}
+	bpf_map_inc(&map->map);
 
 	node->map = map;
 	node->map_entry = map_entry;
@@ -45,7 +29,7 @@ static struct xsk_map_node *xsk_map_node_alloc(struct xsk_map *map,
 
 static void xsk_map_node_free(struct xsk_map_node *node)
 {
-	xsk_map_put(node->map);
+	bpf_map_put(&node->map->map);
 	kfree(node);
 }
 
Signature · 1 line
2.25.1
Acked-by on v5 1/1
#1 lore raw
Quoted 7 lines · Zhu Yanjun

From: Zhu Yanjun <[email protected]>

The functions xsk_map_put and xsk_map_inc are simple wrappers. As such, replacing these functions with the functions bpf_map_inc and bpf_map_put and removing some test codes.

Quoted 7 lines
Fixes d20a1676df7e ("xsk: Move xskmap.c to net/xdp/")
---
 net/xdp/xsk.c    |  4 ++--
 net/xdp/xsk.h    |  2 --
 net/xdp/xskmap.c | 20 ++------------------
 3 files changed, 4 insertions(+), 22 deletions(-)

Thank you Yanjun for this cleanup!

Quoted 85 lines
net/xdp/xsk.c +2 -2
index cfbec3989a76..4f0250f5d676 100644
@@ -548,7 +548,7 @@ static struct xsk_map *xsk_get_map_list_entry(struct xdp_sock *xs,
        node = list_first_entry_or_null(&xs->map_list, struct xsk_map_node,
                                        node);
        if (node) {
-               WARN_ON(xsk_map_inc(node->map));
+               bpf_map_inc(&node->map->map);
                map = node->map;
                *map_entry = node->map_entry;
        }
@@ -578,7 +578,7 @@ static void xsk_delete_from_maps(struct xdp_sock *xs)
 
        while ((map = xsk_get_map_list_entry(xs, &map_entry))) {
                xsk_map_try_sock_delete(map, xs, map_entry);
-               xsk_map_put(map);
+               bpf_map_put(&map->map);
        }
 }
 
net/xdp/xsk.h +0 -2
index b9e896cee5bb..edcf249ad1f1 100644
@@ -41,8 +41,6 @@ static inline struct xdp_sock *xdp_sk(struct sock *sk)
 
 void xsk_map_try_sock_delete(struct xsk_map *map, struct xdp_sock *xs,
                             struct xdp_sock **map_entry);
-int xsk_map_inc(struct xsk_map *map);
-void xsk_map_put(struct xsk_map *map);
 void xsk_clear_pool_at_qid(struct net_device *dev, u16 queue_id);
 int xsk_reg_pool_at_qid(struct net_device *dev, struct xsk_buff_pool *pool,
                        u16 queue_id);
net/xdp/xskmap.c +2 -19
index 49da2b8ace8b..66231ba6c348 100644
@@ -11,32 +11,16 @@
 
 #include "xsk.h"
 
-int xsk_map_inc(struct xsk_map *map)
-{
-       bpf_map_inc(&map->map);
-       return 0;
-}
-
-void xsk_map_put(struct xsk_map *map)
-{
-       bpf_map_put(&map->map);
-}
-
 static struct xsk_map_node *xsk_map_node_alloc(struct xsk_map *map,
                                               struct xdp_sock **map_entry)
 {
        struct xsk_map_node *node;
-       int err;
 
        node = kzalloc(sizeof(*node), GFP_ATOMIC | __GFP_NOWARN);
        if (!node)
                return ERR_PTR(-ENOMEM);
 
-       err = xsk_map_inc(map);
-       if (err) {
-               kfree(node);
-               return ERR_PTR(err);
-       }
+       bpf_map_inc(&map->map);
 
        node->map = map;
        node->map_entry = map_entry;
@@ -45,7 +29,7 @@ static struct xsk_map_node *xsk_map_node_alloc(struct xsk_map *map,
 
 static void xsk_map_node_free(struct xsk_map_node *node)
 {
-       xsk_map_put(node->map);
+       bpf_map_put(&node->map->map);
        kfree(node);
 }
 
--

2.25.1

#2 lore raw
In reply to Zhu Yanjun
This patch was applied to bpf/bpf-next.git (refs/heads/master):

Hello:

This patch was applied to bpf/bpf-next.git (refs/heads/master):

Quoted 10 lines · On Thu, 26 Nov 2020 23:03:18 +0800 you wrote:

From: Zhu Yanjun <[email protected]>

The functions xsk_map_put and xsk_map_inc are simple wrappers. As such, replacing these functions with the functions bpf_map_inc and bpf_map_put and removing some test codes.

Fixes d20a1676df7e ("xsk: Move xskmap.c to net/xdp/")

[...]

Here is the summary with links:
- [v5,1/1] xdp: remove the functions xsk_map_inc and xsk_map_put

    https://git.kernel.org/bpf/bpf-next/c/bb1b25cab043

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html