From: Heiner Kallweit <hkallweit1@gmail.com>
To: Paolo Abeni <pabeni@redhat.com>, Jakub Kicinski <kuba@kernel.org>,
Eric Dumazet <edumazet@google.com>,
David Miller <davem@davemloft.net>,
Realtek linux nic maintainers <nic_swsd@realtek.com>
Cc: "netdev@vger.kernel.org" <netdev@vger.kernel.org>,
Ken Milmore <ken.milmore@gmail.com>
Subject: [PATCH net 1/2] net: add napi_schedule_prep variant with more granular return value
Date: Tue, 14 May 2024 08:50:37 +0200 [thread overview]
Message-ID: <d739aa6d-f1e0-45fa-aad8-b4a1da779b30@gmail.com> (raw)
In-Reply-To: <6d4a0450-9be1-4d91-ba18-5e9bd750fa40@gmail.com>
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(-)
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
--
2.45.0
next prev parent reply other threads:[~2024-05-14 6:50 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-14 6:49 [PATCH net 0/2] r8169: Fix GRO-related issue with not disabled device interrupts Heiner Kallweit
2024-05-14 6:50 ` Heiner Kallweit [this message]
2024-05-14 11:07 ` [PATCH net 1/2] net: add napi_schedule_prep variant with more granular return value Eric Dumazet
2024-05-14 11:40 ` Heiner Kallweit
2024-05-14 6:52 ` [PATCH net 2/2] r8169: disable interrupts also for GRO-scheduled NAPI Heiner Kallweit
2024-05-14 9:45 ` Eric Dumazet
2024-05-14 10:52 ` Alexander Lobakin
2024-05-14 11:05 ` Eric Dumazet
2024-05-14 11:17 ` Alexander Lobakin
2024-05-14 14:27 ` Eric Dumazet
2024-05-14 11:29 ` Heiner Kallweit
2024-05-14 14:11 ` Jakub Kicinski
2024-05-14 16:35 ` Heiner Kallweit
2024-05-14 16:49 ` Jakub Kicinski
2024-05-14 17:09 ` Heiner Kallweit
2024-05-14 17:47 ` Jakub Kicinski
2024-05-14 17:49 ` Jakub Kicinski
2024-05-14 20:47 ` Ken Milmore
2024-05-15 5:53 ` Heiner Kallweit
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d739aa6d-f1e0-45fa-aad8-b4a1da779b30@gmail.com \
--to=hkallweit1@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=ken.milmore@gmail.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=nic_swsd@realtek.com \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).