diff options
author | Christian Marangi <ansuelsmth@gmail.com> | 2023-10-18 14:35:47 +0200 |
---|---|---|
committer | Paolo Abeni <pabeni@redhat.com> | 2023-10-19 15:41:31 +0200 |
commit | 7f3eb2174512fe6c9c0f062e96eccb0d3cc6d5cd (patch) | |
tree | ea7864364f06d4cc11892fcb4ae72696d882fa86 /include/linux | |
parent | a0e6323dbae6e96af5d1acbc8bb592b56f96c65e (diff) | |
download | linux-stable-7f3eb2174512fe6c9c0f062e96eccb0d3cc6d5cd.tar.gz linux-stable-7f3eb2174512fe6c9c0f062e96eccb0d3cc6d5cd.tar.bz2 linux-stable-7f3eb2174512fe6c9c0f062e96eccb0d3cc6d5cd.zip |
net: introduce napi_is_scheduled helper
We currently have napi_if_scheduled_mark_missed that can be used to
check if napi is scheduled but that does more thing than simply checking
it and return a bool. Some driver already implement custom function to
check if napi is scheduled.
Drop these custom function and introduce napi_is_scheduled that simply
check if napi is scheduled atomically.
Update any driver and code that implement a similar check and instead
use this new helper.
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Diffstat (limited to 'include/linux')
-rw-r--r-- | include/linux/netdevice.h | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 1c7681263d30..b8bf669212cc 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -482,6 +482,29 @@ static inline bool napi_prefer_busy_poll(struct napi_struct *n) return test_bit(NAPI_STATE_PREFER_BUSY_POLL, &n->state); } +/** + * napi_is_scheduled - test if NAPI is scheduled + * @n: NAPI context + * + * This check is "best-effort". With no locking implemented, + * a NAPI can be scheduled or terminate right after this check + * and produce not precise results. + * + * NAPI_STATE_SCHED is an internal state, napi_is_scheduled + * should not be used normally and napi_schedule should be + * used instead. + * + * Use only if the driver really needs to check if a NAPI + * is scheduled for example in the context of delayed timer + * that can be skipped if a NAPI is already scheduled. + * + * Return True if NAPI is scheduled, False otherwise. + */ +static inline bool napi_is_scheduled(struct napi_struct *n) +{ + return test_bit(NAPI_STATE_SCHED, &n->state); +} + bool napi_schedule_prep(struct napi_struct *n); /** |