]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
xdp: register system page pool as an XDP memory model
authorToke Høiland-Jørgensen <toke@redhat.com>
Tue, 3 Dec 2024 17:37:29 +0000 (18:37 +0100)
committerJakub Kicinski <kuba@kernel.org>
Fri, 6 Dec 2024 02:41:07 +0000 (18:41 -0800)
To make the system page pool usable as a source for allocating XDP
frames, we need to register it with xdp_reg_mem_model(), so that page
return works correctly. This is done in preparation for using the system
page_pool to convert XDP_PASS XSk frames to skbs; for the same reason,
make the per-cpu variable non-static so we can access it from other
source files as well (but w/o exporting).

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
Signed-off-by: Alexander Lobakin <aleksander.lobakin@intel.com>
Link: https://patch.msgid.link/20241203173733.3181246-7-aleksander.lobakin@intel.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
include/linux/netdevice.h
net/core/dev.c

index ecca21387a6838fbe37989b5f825d0a9338ae2ba..d1a8d98b132c62bee02842743a22e082096d34a3 100644 (file)
@@ -3322,6 +3322,7 @@ struct softnet_data {
 };
 
 DECLARE_PER_CPU_ALIGNED(struct softnet_data, softnet_data);
+DECLARE_PER_CPU(struct page_pool *, system_page_pool);
 
 #ifndef CONFIG_PREEMPT_RT
 static inline int dev_recursion_level(void)
index 40a2332e3fa027faeaff6888674d645b5210fb72..c7f3dea3e0eb9eb05865e49dd7a8535afb974149 100644 (file)
@@ -460,7 +460,7 @@ EXPORT_PER_CPU_SYMBOL(softnet_data);
  * PP consumers must pay attention to run APIs in the appropriate context
  * (e.g. NAPI context).
  */
-static DEFINE_PER_CPU(struct page_pool *, system_page_pool);
+DEFINE_PER_CPU(struct page_pool *, system_page_pool);
 
 #ifdef CONFIG_LOCKDEP
 /*
@@ -12152,11 +12152,18 @@ static int net_page_pool_create(int cpuid)
                .nid = cpu_to_mem(cpuid),
        };
        struct page_pool *pp_ptr;
+       int err;
 
        pp_ptr = page_pool_create_percpu(&page_pool_params, cpuid);
        if (IS_ERR(pp_ptr))
                return -ENOMEM;
 
+       err = xdp_reg_page_pool(pp_ptr);
+       if (err) {
+               page_pool_destroy(pp_ptr);
+               return err;
+       }
+
        per_cpu(system_page_pool, cpuid) = pp_ptr;
 #endif
        return 0;
@@ -12290,6 +12297,7 @@ out:
                        if (!pp_ptr)
                                continue;
 
+                       xdp_unreg_page_pool(pp_ptr);
                        page_pool_destroy(pp_ptr);
                        per_cpu(system_page_pool, i) = NULL;
                }