xdp: compact the function xsk_map_inc
Subsystems (3)
PATCH 1/1 xdp: compact the function xsk_map_inc
From: Zhu Yanjun <[email protected]>
The function xsk_map_inc always returns zero. As such, changing the return type to void and removing the test code.
Signed-off-by Zhu Yanjun <[email protected]>
Signed-off-by Zhu Yanjun <[email protected]>
--- net/xdp/xsk.c | 1 - net/xdp/xsk.h | 2 +- net/xdp/xskmap.c | 10 ++-------- 3 files changed, 3 insertions(+), 10 deletions(-)
net/xdp/xsk.c +0 -1
@@ -548,7 +548,6 @@ static void xsk_unbind_dev(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)); map = node->map; *map_entry = node->map_entry; }
net/xdp/xsk.h +1 -1
@@ -41,7 +41,7 @@ struct xsk_map_node {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_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,
net/xdp/xskmap.c +2 -8
@@ -11,10 +11,9 @@#include "xsk.h" -int xsk_map_inc (struct xsk_map *map) +void xsk_map_inc (struct xsk_map *map) {bpf_map_inc (&map->map); -return 0 ; }void xsk_map_put (struct xsk_map *map)
@@ -26,17 +25,12 @@ void xsk_map_put(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); - } +xsk_map_inc (map); node->map = map; node->map_entry = map_entry;
Signature · 1 line
1.7.1
Quoted 44 lines · Zhu Yanjun
From: Zhu Yanjun <[email protected]>
The function
xsk_map_incalways returns zero. As such, changing the return type to void and removing the test code.Signed-off-by Zhu Yanjun <[email protected]>Signed-off-by Zhu Yanjun <[email protected]>--- net/xdp/xsk.c | 1 - net/xdp/xsk.h | 2 +- net/xdp/xskmap.c | 10 ++-------- 3 files changed, 3 insertions(+), 10 deletions(-)net/xdp/xsk.c +0
-1@@ -548,7 +548,6 @@ static void xsk_unbind_dev(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)); map = node->map; *map_entry = node->map_entry; }net/xdp/xsk.h +1
-1@@ -41,7 +41,7 @@ struct xsk_map_node {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_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,net/xdp/xskmap.c +0
-0
net/xdp/xskmap.c line 17
Quoted 9 lines
net/xdp/xskmap.c +1
-2@@ -11,10 +11,9 @@#include "xsk.h" -int xsk_map_inc (struct xsk_map *map) +void xsk_map_inc (struct xsk_map *map) {bpf_map_inc (&map->map); -return 0 ; }
Thank you Yanjun for your cleanup. I think we can take this one step further and remove the function xsk_map_inc completely and use bpf_map_inc directly in the code. Could you please do this and submit a v2?
Quoted 23 lines
net/xdp/xskmap.c +1
-7void xsk_map_put (struct xsk_map *map)@@ -26,17 +25,12 @@ void xsk_map_put(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); - } +xsk_map_inc (map); node->map = map; node->map_entry = map_entry; --1.7.1