Re: [PATCH v7 net-next 1/4] net: add generic percpu page_pool allocator

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On 02/02/2024 09.12, Lorenzo Bianconi wrote:
Introduce generic percpu page_pools allocator.
Moreover add page_pool_create_percpu() and cpuid filed in page_pool struct
in order to recycle the page in the page_pool "hot" cache if
napi_pp_put_page() is running on the same cpu.
This is a preliminary patch to add xdp multi-buff support for xdp running
in generic mode.

Signed-off-by: Lorenzo Bianconi<lorenzo@xxxxxxxxxx>
---
  include/net/page_pool/types.h |  3 +++
  net/core/dev.c                | 45 +++++++++++++++++++++++++++++++++++
  net/core/page_pool.c          | 23 ++++++++++++++----
  net/core/skbuff.c             |  5 ++--
  4 files changed, 70 insertions(+), 6 deletions(-)

diff --git a/include/net/page_pool/types.h b/include/net/page_pool/types.h
index 76481c465375..3828396ae60c 100644
--- a/include/net/page_pool/types.h
+++ b/include/net/page_pool/types.h
@@ -128,6 +128,7 @@ struct page_pool_stats {
  struct page_pool {
  	struct page_pool_params_fast p;
+ int cpuid;
  	bool has_init_callback;
long frag_users;
@@ -203,6 +204,8 @@ struct page *page_pool_alloc_pages(struct page_pool *pool, gfp_t gfp);
  struct page *page_pool_alloc_frag(struct page_pool *pool, unsigned int *offset,
  				  unsigned int size, gfp_t gfp);
  struct page_pool *page_pool_create(const struct page_pool_params *params);
+struct page_pool *page_pool_create_percpu(const struct page_pool_params *params,
+					  int cpuid);
struct xdp_mem_info; diff --git a/net/core/dev.c b/net/core/dev.c
index b53b9c94de40..5a100360389f 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -153,6 +153,8 @@
  #include <linux/prandom.h>
  #include <linux/once_lite.h>
  #include <net/netdev_rx_queue.h>
+#include <net/page_pool/types.h>
+#include <net/page_pool/helpers.h>
#include "dev.h"
  #include "net-sysfs.h"
@@ -450,6 +452,12 @@ static RAW_NOTIFIER_HEAD(netdev_chain);
  DEFINE_PER_CPU_ALIGNED(struct softnet_data, softnet_data);
  EXPORT_PER_CPU_SYMBOL(softnet_data);
+/* Page_pool has a lockless array/stack to alloc/recycle pages.
+ * PP consumers must pay attention to run APIs in the appropriate context
+ * (e.g. NAPI context).
+ */
+static DEFINE_PER_CPU_ALIGNED(struct page_pool *, system_page_pool);

Thanks for adding comment.

Acked-by: Jesper Dangaard Brouer <hawk@xxxxxxxxxx>






[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux