]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
netconsole: move find_skb() from netpoll
authorBreno Leitao <leitao@debian.org>
Tue, 12 May 2026 10:46:42 +0000 (03:46 -0700)
committerJakub Kicinski <kuba@kernel.org>
Thu, 14 May 2026 01:09:13 +0000 (18:09 -0700)
find_skb() is the netconsole-specific entry into the netpoll skb
pool: every other netpoll consumer (bonding, team, vlan, bridge,
macvlan, dsa) builds its own sk_buff and never touches the pool.
With netpoll_send_udp() (its only caller) now living in netconsole,
find_skb() can join it.

Move find_skb() into drivers/net/netconsole.c as a file-static
helper, drop EXPORT_SYMBOL_GPL(find_skb) and remove its prototype
from include/linux/netpoll.h. find_skb() drains TX completions via
netpoll_zap_completion_queue(), which is already exported in the
NETDEV_INTERNAL namespace, so netconsole picks up
MODULE_IMPORT_NS("NETDEV_INTERNAL") to consume it.

The skb pool's lifecycle (np->skb_pool, np->refill_wq, refill_skbs(),
refill_skbs_work_handler(), skb_pool_flush()) stays in netpoll: it
is initialised in __netpoll_setup() and torn down in
__netpoll_cleanup(), both of which remain netpoll's responsibility.
The refill work queued via schedule_work(&np->refill_wq) from the
moved find_skb() runs refill_skbs_work_handler() in netpoll without
any further plumbing.

This is pure code motion: the function body is unchanged and its
sole caller (netpoll_send_udp(), already moved by an earlier patch)
keeps invoking it the same way. Pre-existing concerns about
find_skb() running from NMI/printk context (zap_completion_queue()
re-entry, skb_pool spinlocks, GFP_ATOMIC allocation, fallback skb
sizing vs. MAX_SKB_SIZE, PREEMPT_RT semantics of __kfree_skb()) are
inherited as-is and are not addressed here; they predate this
series and are out of scope. Fixing them is left for follow-up
work.

Signed-off-by: Breno Leitao <leitao@debian.org>
Link: https://patch.msgid.link/20260512-netconsole_split-v2-9-1191d14ad66d@debian.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/netconsole.c
include/linux/netpoll.h
net/core/netpoll.c

index 48d2670bbdef5e6348aaadcdffd0f8f1cf450eaf..d804d44af87c811c6be419a0d22dad4541fff9ef 100644 (file)
@@ -50,6 +50,7 @@
 MODULE_AUTHOR("Matt Mackall <mpm@selenic.com>");
 MODULE_DESCRIPTION("Console driver for network interfaces");
 MODULE_LICENSE("GPL");
+MODULE_IMPORT_NS("NETDEV_INTERNAL");
 
 #define MAX_PARAM_LENGTH               256
 #define MAX_EXTRADATA_ENTRY_LEN                256
@@ -1653,6 +1654,33 @@ static struct notifier_block netconsole_netdev_notifier = {
        .notifier_call  = netconsole_netdev_event,
 };
 
+static struct sk_buff *find_skb(struct netpoll *np, int len, int reserve)
+{
+       int count = 0;
+       struct sk_buff *skb;
+
+       netpoll_zap_completion_queue();
+repeat:
+
+       skb = alloc_skb(len, GFP_ATOMIC);
+       if (!skb) {
+               skb = skb_dequeue(&np->skb_pool);
+               schedule_work(&np->refill_wq);
+       }
+
+       if (!skb) {
+               if (++count < 10) {
+                       netpoll_poll_dev(np->dev);
+                       goto repeat;
+               }
+               return NULL;
+       }
+
+       refcount_set(&skb->users, 1);
+       skb_reserve(skb, reserve);
+       return skb;
+}
+
 static void netpoll_udp_checksum(struct netpoll *np, struct sk_buff *skb,
                                 int len)
 {
index f986f7486cb8ccddb478b3279da73bbf4fd24711..e4b8f1f91e54b15f8b5eaef1137e9dbc3d81fea0 100644 (file)
@@ -73,7 +73,6 @@ void __netpoll_free(struct netpoll *np);
 void netpoll_cleanup(struct netpoll *np);
 void do_netpoll_cleanup(struct netpoll *np);
 netdev_tx_t netpoll_send_skb(struct netpoll *np, struct sk_buff *skb);
-struct sk_buff *find_skb(struct netpoll *np, int len, int reserve);
 void netpoll_zap_completion_queue(void);
 
 #ifdef CONFIG_NETPOLL
index e4cda0aa4d488ab2c47f3b3c254afb162f6c6cee..33ab3d827a427323bc471fdab628dde9f363863f 100644 (file)
@@ -265,34 +265,6 @@ void netpoll_zap_completion_queue(void)
 }
 EXPORT_SYMBOL_NS_GPL(netpoll_zap_completion_queue, "NETDEV_INTERNAL");
 
-struct sk_buff *find_skb(struct netpoll *np, int len, int reserve)
-{
-       int count = 0;
-       struct sk_buff *skb;
-
-       netpoll_zap_completion_queue();
-repeat:
-
-       skb = alloc_skb(len, GFP_ATOMIC);
-       if (!skb) {
-               skb = skb_dequeue(&np->skb_pool);
-               schedule_work(&np->refill_wq);
-       }
-
-       if (!skb) {
-               if (++count < 10) {
-                       netpoll_poll_dev(np->dev);
-                       goto repeat;
-               }
-               return NULL;
-       }
-
-       refcount_set(&skb->users, 1);
-       skb_reserve(skb, reserve);
-       return skb;
-}
-EXPORT_SYMBOL_GPL(find_skb);
-
 static int netpoll_owner_active(struct net_device *dev)
 {
        struct napi_struct *napi;