From: Breno Leitao <leitao@debian.org>
To: "David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>,
Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>,
Andrew Lunn <andrew+netdev@lunn.ch>
Cc: netdev@vger.kernel.org, asantostc@gmail.com, gustavold@gmail.com,
linux-kernel@vger.kernel.org, Breno Leitao <leitao@debian.org>,
kernel-team@meta.com
Subject: [PATCH net-next v2 6/8] netconsole: move skb_pool / refill_wq from struct netpoll to netconsole_target
Date: Thu, 02 Jul 2026 05:19:50 -0700 [thread overview]
Message-ID: <20260702-netconsole_move_more-v2-6-1ebedd921dcb@debian.org> (raw)
In-Reply-To: <20260702-netconsole_move_more-v2-0-1ebedd921dcb@debian.org>
These two fields back the fallback skb pool that find_skb() uses.
Every helper that touches them lives in netconsole now (refill_skbs,
refill_skbs_work_handler, netconsole_skb_pool_init,
netconsole_skb_pool_flush, find_skb, netcons_skb_pop), so the data
can move alongside its only consumer.
Add skb_pool and refill_wq to struct netconsole_target, drop them
from struct netpoll.
This will save 48-bytes for every netpoll user instance (except
netconsole that will have it in netconsole target struct).
Signed-off-by: Breno Leitao <leitao@debian.org>
---
drivers/net/netconsole.c | 53 +++++++++++++++++++++++++++---------------------
include/linux/netpoll.h | 2 --
2 files changed, 30 insertions(+), 25 deletions(-)
diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c
index 3e1b8ece7032e..bfa5fdac9600b 100644
--- a/drivers/net/netconsole.c
+++ b/drivers/net/netconsole.c
@@ -183,6 +183,11 @@ enum target_state {
* remote_mac (read-write)
* @buf: The buffer used to send the full msg to the network stack
* @resume_wq: Workqueue to resume deactivated target
+ * @skb_pool: Per-target fallback skb pool consulted by find_skb() when
+ * its GFP_ATOMIC allocation fails. Lifetime brackets a
+ * successful netpoll_setup() / netpoll_cleanup() pair on @np.
+ * @refill_wq: Work item that asynchronously tops @skb_pool back up to
+ * MAX_SKBS after find_skb() drains an entry.
*/
struct netconsole_target {
struct list_head list;
@@ -208,6 +213,8 @@ struct netconsole_target {
*/
char buf[MAX_PRINT_CHUNK + 1];
struct work_struct resume_wq;
+ struct sk_buff_head skb_pool;
+ struct work_struct refill_wq;
};
#ifdef CONFIG_NETCONSOLE_DYNAMIC
@@ -305,13 +312,11 @@ static void netcons_release_dev(struct netconsole_target *nt)
memset(&nt->np.dev_name, 0, IFNAMSIZ);
}
-static void refill_skbs(struct netpoll *np)
+static void refill_skbs(struct netconsole_target *nt)
{
- struct sk_buff_head *skb_pool;
+ struct sk_buff_head *skb_pool = &nt->skb_pool;
struct sk_buff *skb;
- skb_pool = &np->skb_pool;
-
while (READ_ONCE(skb_pool->qlen) < MAX_SKBS) {
skb = alloc_skb(MAX_SKB_SIZE, GFP_ATOMIC | __GFP_NOWARN);
if (!skb)
@@ -323,10 +328,10 @@ static void refill_skbs(struct netpoll *np)
static void refill_skbs_work_handler(struct work_struct *work)
{
- struct netpoll *np =
- container_of(work, struct netpoll, refill_wq);
+ struct netconsole_target *nt =
+ container_of(work, struct netconsole_target, refill_wq);
- refill_skbs(np);
+ refill_skbs(nt);
}
/* Initialise the per-target skb pool that find_skb() falls back to and
@@ -335,17 +340,15 @@ static void refill_skbs_work_handler(struct work_struct *work)
*/
static void netconsole_skb_pool_init(struct netconsole_target *nt)
{
- skb_queue_head_init(&nt->np.skb_pool);
- INIT_WORK(&nt->np.refill_wq, refill_skbs_work_handler);
- refill_skbs(&nt->np);
+ skb_queue_head_init(&nt->skb_pool);
+ INIT_WORK(&nt->refill_wq, refill_skbs_work_handler);
+ refill_skbs(nt);
}
static void netconsole_skb_pool_flush(struct netconsole_target *nt)
{
- struct netpoll *np = &nt->np;
-
- cancel_work_sync(&np->refill_wq);
- skb_queue_purge_reason(&np->skb_pool, SKB_CONSUMED);
+ cancel_work_sync(&nt->refill_wq);
+ skb_queue_purge_reason(&nt->skb_pool, SKB_CONSUMED);
}
/* Attempts to resume logging to a deactivated target. */
@@ -1784,7 +1787,7 @@ static struct notifier_block netconsole_netdev_notifier = {
* pool locks and is therefore not NMI-safe. Skip the refill when called
* from NMI context; the next non-NMI caller will top the pool back up.
*/
-static struct sk_buff *netcons_skb_pop(struct netpoll *np, int len)
+static struct sk_buff *netcons_skb_pop(struct netconsole_target *nt, int len)
{
struct sk_buff *skb;
@@ -1796,19 +1799,21 @@ static struct sk_buff *netcons_skb_pop(struct netpoll *np, int len)
if (!in_nmi())
net_warn_ratelimited("netconsole: dropping message, requested skb len %d exceeds pool buffer size %zu on %s\n",
len, (size_t)MAX_SKB_SIZE,
- np->dev->name);
+ nt->np.dev->name);
return NULL;
}
- skb = skb_dequeue(&np->skb_pool);
+ skb = skb_dequeue(&nt->skb_pool);
if (!in_nmi())
- schedule_work(&np->refill_wq);
+ schedule_work(&nt->refill_wq);
return skb;
}
-static struct sk_buff *find_skb(struct netpoll *np, int len, int reserve)
+static struct sk_buff *find_skb(struct netconsole_target *nt, int len,
+ int reserve)
{
+ struct netpoll *np = &nt->np;
int count = 0;
struct sk_buff *skb;
@@ -1817,7 +1822,7 @@ static struct sk_buff *find_skb(struct netpoll *np, int len, int reserve)
skb = alloc_skb(len, GFP_ATOMIC | __GFP_NOWARN);
if (!skb)
- skb = netcons_skb_pop(np, len);
+ skb = netcons_skb_pop(nt, len);
if (!skb) {
if (++count < 10) {
@@ -1939,8 +1944,10 @@ static void push_ipv6(struct netpoll *np, struct sk_buff *skb, int len)
skb->protocol = htons(ETH_P_IPV6);
}
-static int netpoll_send_udp(struct netpoll *np, const char *msg, int len)
+static int netpoll_send_udp(struct netconsole_target *nt, const char *msg,
+ int len)
{
+ struct netpoll *np = &nt->np;
int total_len, ip_len, udp_len;
struct sk_buff *skb;
@@ -1955,7 +1962,7 @@ static int netpoll_send_udp(struct netpoll *np, const char *msg, int len)
total_len = ip_len + LL_RESERVED_SPACE(np->dev);
- skb = find_skb(np, total_len + np->dev->needed_tailroom,
+ skb = find_skb(nt, total_len + np->dev->needed_tailroom,
total_len - len);
if (!skb)
return -ENOMEM;
@@ -1986,7 +1993,7 @@ static int netpoll_send_udp(struct netpoll *np, const char *msg, int len)
*/
static void send_udp(struct netconsole_target *nt, const char *msg, int len)
{
- int result = netpoll_send_udp(&nt->np, msg, len);
+ int result = netpoll_send_udp(nt, msg, len);
if (IS_ENABLED(CONFIG_NETCONSOLE_DYNAMIC)) {
if (result == NET_XMIT_DROP) {
diff --git a/include/linux/netpoll.h b/include/linux/netpoll.h
index 1216b5c237ce4..f377fdf7839ca 100644
--- a/include/linux/netpoll.h
+++ b/include/linux/netpoll.h
@@ -37,8 +37,6 @@ struct netpoll {
bool ipv6;
u16 local_port, remote_port;
u8 remote_mac[ETH_ALEN];
- struct sk_buff_head skb_pool;
- struct work_struct refill_wq;
};
#define np_info(np, fmt, ...) \
--
2.53.0-Meta
next prev parent reply other threads:[~2026-07-02 12:20 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-02 12:19 [PATCH net-next v2 0/8] netconsole: stop charging netpoll users for netconsole-only data Breno Leitao
2026-07-02 12:19 ` [PATCH net-next v2 1/8] netpoll: export refill_skbs(), refill_skbs_work_handler(), skb_pool_flush() Breno Leitao
2026-07-02 12:19 ` [PATCH net-next v2 2/8] netconsole: take over skb pool lifecycle from netpoll Breno Leitao
2026-07-02 12:19 ` [PATCH net-next v2 3/8] netconsole: move refill_skbs_work_handler() " Breno Leitao
2026-07-02 12:19 ` [PATCH net-next v2 4/8] netconsole: move refill_skbs() and skb-pool sizing macros " Breno Leitao
2026-07-02 12:19 ` [PATCH net-next v2 5/8] netconsole: move skb_pool_flush() " Breno Leitao
2026-07-02 12:19 ` Breno Leitao [this message]
2026-07-02 12:19 ` [PATCH net-next v2 7/8] netconsole: move local_port / remote_port from struct netpoll to netconsole_target Breno Leitao
2026-07-02 12:19 ` [PATCH net-next v2 8/8] netconsole: move remote_mac " Breno Leitao
2026-07-06 11:55 ` [PATCH net-next v2 0/8] netconsole: stop charging netpoll users for netconsole-only data Breno Leitao
2026-07-09 10:19 ` Simon Horman
2026-07-09 10:27 ` Paolo Abeni
2026-07-09 16:38 ` Breno Leitao
2026-07-09 10:20 ` Paolo Abeni
2026-07-10 9:46 ` Breno Leitao
2026-07-10 11:01 ` Breno Leitao
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=20260702-netconsole_move_more-v2-6-1ebedd921dcb@debian.org \
--to=leitao@debian.org \
--cc=andrew+netdev@lunn.ch \
--cc=asantostc@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=gustavold@gmail.com \
--cc=horms@kernel.org \
--cc=kernel-team@meta.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.