Skip to content

Commit 82dc3c6

Browse files
edumazetdavem330
authored andcommitted
net: introduce NAPI_POLL_WEIGHT
Some drivers use a too big NAPI poll weight. This patch adds a NAPI_POLL_WEIGHT default value and issues an error message if a driver attempts to use a bigger weight. Signed-off-by: Eric Dumazet <[email protected]> Cc: Eilon Greenstein <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent dd9f319 commit 82dc3c6

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

include/linux/netdevice.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1475,6 +1475,11 @@ static inline void *netdev_priv(const struct net_device *dev)
14751475
*/
14761476
#define SET_NETDEV_DEVTYPE(net, devtype) ((net)->dev.type = (devtype))
14771477

1478+
/* Default NAPI poll() weight
1479+
* Device drivers are strongly advised to not use bigger value
1480+
*/
1481+
#define NAPI_POLL_WEIGHT 64
1482+
14781483
/**
14791484
* netif_napi_add - initialize a napi context
14801485
* @dev: network device

net/core/dev.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4057,6 +4057,9 @@ void netif_napi_add(struct net_device *dev, struct napi_struct *napi,
40574057
napi->gro_list = NULL;
40584058
napi->skb = NULL;
40594059
napi->poll = poll;
4060+
if (weight > NAPI_POLL_WEIGHT)
4061+
pr_err_once("netif_napi_add() called with weight %d on device %s\n",
4062+
weight, dev->name);
40604063
napi->weight = weight;
40614064
list_add(&napi->dev_list, &dev->napi_list);
40624065
napi->dev = dev;

0 commit comments

Comments
 (0)