mirror of
https://github.com/torvalds/linux.git
synced 2024-10-30 08:42:47 +00:00
net: napi_hash_del() returns a boolean status
napi_hash_del() will soon be used from both drivers (if they want) or core networking stack. Callers are responsibles to ensure an RCU grace period is respected before freeing napi structure : napi_hash_del() can signal if this RCU grace period is needed or not. Signed-off-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
6180d9de61
commit
34cbe27e81
@ -474,9 +474,10 @@ void napi_hash_add(struct napi_struct *napi);
|
|||||||
* @napi: napi context
|
* @napi: napi context
|
||||||
*
|
*
|
||||||
* Warning: caller must observe rcu grace period
|
* Warning: caller must observe rcu grace period
|
||||||
* before freeing memory containing @napi
|
* before freeing memory containing @napi, if
|
||||||
|
* this function returns true.
|
||||||
*/
|
*/
|
||||||
void napi_hash_del(struct napi_struct *napi);
|
bool napi_hash_del(struct napi_struct *napi);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* napi_disable - prevent NAPI from scheduling
|
* napi_disable - prevent NAPI from scheduling
|
||||||
|
@ -4760,14 +4760,18 @@ EXPORT_SYMBOL_GPL(napi_hash_add);
|
|||||||
/* Warning : caller is responsible to make sure rcu grace period
|
/* Warning : caller is responsible to make sure rcu grace period
|
||||||
* is respected before freeing memory containing @napi
|
* is respected before freeing memory containing @napi
|
||||||
*/
|
*/
|
||||||
void napi_hash_del(struct napi_struct *napi)
|
bool napi_hash_del(struct napi_struct *napi)
|
||||||
{
|
{
|
||||||
|
bool rcu_sync_needed = false;
|
||||||
|
|
||||||
spin_lock(&napi_hash_lock);
|
spin_lock(&napi_hash_lock);
|
||||||
|
|
||||||
if (test_and_clear_bit(NAPI_STATE_HASHED, &napi->state))
|
if (test_and_clear_bit(NAPI_STATE_HASHED, &napi->state)) {
|
||||||
|
rcu_sync_needed = true;
|
||||||
hlist_del_rcu(&napi->napi_hash_node);
|
hlist_del_rcu(&napi->napi_hash_node);
|
||||||
|
}
|
||||||
spin_unlock(&napi_hash_lock);
|
spin_unlock(&napi_hash_lock);
|
||||||
|
return rcu_sync_needed;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(napi_hash_del);
|
EXPORT_SYMBOL_GPL(napi_hash_del);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user