Complete the SKB pool management refactoring by moving find_skb() from
netpoll core to netconsole driver, making it a static function.
This is the final step in removing SKB pool management from the generic
netpoll infrastructure. With this change:
1. Netpoll core is now purely transmission-focused: Contains only
the essential netpoll_send_skb() function for low-level packet
transmission, with no knowledge of SKB allocation or pool management.
2. Complete encapsulation in netconsole: All SKB lifecycle
management (allocation, pool handling, packet construction) is now
contained within the netconsole driver where it belongs.
3. Cleaner API surface: Removes the last SKB management export from
netpoll, leaving only zap_completion_queue() as a utility function
and netpoll_send_skb() for transmission.
4. Better maintainability: Changes to SKB allocation strategies or
pool management can now be made entirely within netconsole without
affecting the core netpoll infrastructure.
The find_skb() function is made static since it's now only used within
netconsole.c for its internal SKB allocation needs.
This completes the architectural cleanup that separates generic netpoll
transmission capabilities from console-specific resource management.
Signed-off-by: Breno Leitao <leitao@debian.org>
---
drivers/net/netconsole.c | 27 +++++++++++++++++++++++++++
include/linux/netpoll.h | 1 -
net/core/netpoll.c | 28 ----------------------------
3 files changed, 27 insertions(+), 29 deletions(-)
diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c
index 3fe55db07cfe5..bf7bab7a9c2f0 100644
--- a/drivers/net/netconsole.c
+++ b/drivers/net/netconsole.c
@@ -1655,6 +1655,33 @@ static void push_eth(struct netpoll *np, struct sk_buff *skb)
eth->h_proto = htons(ETH_P_IP);
}
+static struct sk_buff *find_skb(struct netpoll *np, int len, int reserve)
+{
+ int count = 0;
+ struct sk_buff *skb;
+
+ 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 struct sk_buff *netpoll_prepare_skb(struct netpoll *np, const char *msg,
int len)
{
diff --git a/include/linux/netpoll.h b/include/linux/netpoll.h
index 7f8b4d758a1e7..f89bc9fb1f773 100644
--- a/include/linux/netpoll.h
+++ b/include/linux/netpoll.h
@@ -74,7 +74,6 @@ int netpoll_setup(struct netpoll *np);
void __netpoll_free(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 zap_completion_queue(void);
#ifdef CONFIG_NETPOLL
diff --git a/net/core/netpoll.c b/net/core/netpoll.c
index 94c75f39787bb..5aa83c9c09e05 100644
--- a/net/core/netpoll.c
+++ b/net/core/netpoll.c
@@ -235,34 +235,6 @@ void zap_completion_queue(void)
}
EXPORT_SYMBOL_GPL(zap_completion_queue);
-struct sk_buff *find_skb(struct netpoll *np, int len, int reserve)
-{
- int count = 0;
- struct sk_buff *skb;
-
- 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;
--
2.47.3
Breno Leitao wrote: > Complete the SKB pool management refactoring by moving find_skb() from > netpoll core to netconsole driver, making it a static function. > > This is the final step in removing SKB pool management from the generic > netpoll infrastructure. With this change: > > 1. Netpoll core is now purely transmission-focused: Contains only > the essential netpoll_send_skb() function for low-level packet > transmission, with no knowledge of SKB allocation or pool management. > > 2. Complete encapsulation in netconsole: All SKB lifecycle > management (allocation, pool handling, packet construction) is now > contained within the netconsole driver where it belongs. > > 3. Cleaner API surface: Removes the last SKB management export from > netpoll, leaving only zap_completion_queue() as a utility function > and netpoll_send_skb() for transmission. > > 4. Better maintainability: Changes to SKB allocation strategies or > pool management can now be made entirely within netconsole without > affecting the core netpoll infrastructure. > > The find_skb() function is made static since it's now only used within > netconsole.c for its internal SKB allocation needs. > > This completes the architectural cleanup that separates generic netpoll > transmission capabilities from console-specific resource management. > > Signed-off-by: Breno Leitao <leitao@debian.org> Reviewed-by: Willem de Bruijn <willemb@google.com>
© 2016 - 2025 Red Hat, Inc.