diff mbox series

[net,1/2] net: add napi_schedule_prep variant with more granular return value

Message ID d739aa6d-f1e0-45fa-aad8-b4a1da779b30@gmail.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series r8169: Fix GRO-related issue with not disabled device interrupts | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net, async
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag present in non-next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 4866 this patch: 4866
netdev/build_tools success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers success CCed 4 of 4 maintainers
netdev/build_clang success Errors and warnings before: 1043 this patch: 1043
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 5146 this patch: 5146
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 47 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 101 this patch: 101
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-05-15--12-00 (tests: 1021)

Commit Message

Heiner Kallweit May 14, 2024, 6:50 a.m. UTC
For deciding whether to disable device interrupts, drivers may need the
information whether NAPIF_STATE_DISABLE or NAPIF_STATE_SCHED was set.
Therefore add a __napi_schedule_prep() which returns -1 in case
NAPIF_STATE_DISABLE was set.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
 include/linux/netdevice.h |  7 ++++++-
 net/core/dev.c            | 12 ++++++------
 2 files changed, 12 insertions(+), 7 deletions(-)

Comments

Eric Dumazet May 14, 2024, 11:07 a.m. UTC | #1
On Tue, May 14, 2024 at 8:50 AM Heiner Kallweit <hkallweit1@gmail.com> wrote:
>
> For deciding whether to disable device interrupts, drivers may need the
> information whether NAPIF_STATE_DISABLE or NAPIF_STATE_SCHED was set.
> Therefore add a __napi_schedule_prep() which returns -1 in case
> NAPIF_STATE_DISABLE was set.
>
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
> ---

net-next is closed.

See my feedback on the other patch.
Heiner Kallweit May 14, 2024, 11:40 a.m. UTC | #2
On 14.05.2024 13:07, Eric Dumazet wrote:
> On Tue, May 14, 2024 at 8:50 AM Heiner Kallweit <hkallweit1@gmail.com> wrote:
>>
>> For deciding whether to disable device interrupts, drivers may need the
>> information whether NAPIF_STATE_DISABLE or NAPIF_STATE_SCHED was set.
>> Therefore add a __napi_schedule_prep() which returns -1 in case
>> NAPIF_STATE_DISABLE was set.
>>
>> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
>> ---
> 
> net-next is closed.
> 
This patch is a prerequisite for the other one. Therefore I don't see it
as net-next material. If it would be a standalone patch, I'd agree.

> See my feedback on the other patch.
diff mbox series

Patch

diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index cf261fb89..d1515cf8c 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -498,7 +498,12 @@  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);
+int __napi_schedule_prep(struct napi_struct *n);
+
+static inline bool napi_schedule_prep(struct napi_struct *n)
+{
+	return __napi_schedule_prep(n) > 0;
+}
 
 /**
  *	napi_schedule - schedule NAPI poll
diff --git a/net/core/dev.c b/net/core/dev.c
index d2ce91a33..66f55fc50 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -6116,21 +6116,21 @@  void __napi_schedule(struct napi_struct *n)
 EXPORT_SYMBOL(__napi_schedule);
 
 /**
- *	napi_schedule_prep - check if napi can be scheduled
+ *	__napi_schedule_prep - check if napi can be scheduled
  *	@n: napi context
  *
  * Test if NAPI routine is already running, and if not mark
  * it as running.  This is used as a condition variable to
- * insure only one NAPI poll instance runs.  We also make
- * sure there is no pending NAPI disable.
+ * insure only one NAPI poll instance runs. Return -1 if
+ * there is a pending NAPI disable.
  */
-bool napi_schedule_prep(struct napi_struct *n)
+int __napi_schedule_prep(struct napi_struct *n)
 {
 	unsigned long new, val = READ_ONCE(n->state);
 
 	do {
 		if (unlikely(val & NAPIF_STATE_DISABLE))
-			return false;
+			return -1;
 		new = val | NAPIF_STATE_SCHED;
 
 		/* Sets STATE_MISSED bit if STATE_SCHED was already set
@@ -6145,7 +6145,7 @@  bool napi_schedule_prep(struct napi_struct *n)
 
 	return !(val & NAPIF_STATE_SCHED);
 }
-EXPORT_SYMBOL(napi_schedule_prep);
+EXPORT_SYMBOL(__napi_schedule_prep);
 
 /**
  * __napi_schedule_irqoff - schedule for receive