net: provide generic busy polling to all NAPI drivers

NAPI drivers no longer need to observe a particular protocol
to benefit from busy polling (CONFIG_NET_RX_BUSY_POLL=y)

napi_hash_add() and napi_hash_del() are automatically called
from core networking stack, respectively from
netif_napi_add() and netif_napi_del()

This patch depends on free_netdev() and netif_napi_del() being
called from process context, which seems to be the norm.

Drivers might still prefer to call napi_hash_del() on their
own, since they might combine all the rcu grace periods into
a single one, knowing their NAPI structures lifetime, while
core networking stack has no idea of a possible combining.

Once this patch proves to not bring serious regressions,
we will cleanup drivers to either remove napi_hash_del()
or provide appropriate rcu grace periods combining.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Eric Dumazet
2015-11-18 06:31:03 -08:00
committed by David S. Miller
parent 34cbe27e81
commit 93d05d4a32
14 changed files with 16 additions and 20 deletions

View File

@@ -466,6 +466,9 @@ static inline void napi_complete(struct napi_struct *n)
* @napi: napi context
*
* generate a new napi_id and store a @napi under it in napi_hash
* Used for busy polling (CONFIG_NET_RX_BUSY_POLL)
* Note: This is normally automatically done from netif_napi_add(),
* so might disappear in a future linux version.
*/
void napi_hash_add(struct napi_struct *napi);
@@ -476,6 +479,10 @@ void napi_hash_add(struct napi_struct *napi);
* Warning: caller must observe rcu grace period
* before freeing memory containing @napi, if
* this function returns true.
* Note: core networking stack automatically calls it
* from netif_napi_del()
* Drivers might want to call this helper to combine all
* the needed rcu grace periods into a single one.
*/
bool napi_hash_del(struct napi_struct *napi);