Re: [PATCH v2 15/16] netdevsim: use netmem descriptor and APIs for page pool
From: Byungchul Park <byungchul@sk.com>
Date: 2025-05-28 06:04:22
Also in:
bpf, linux-mm, linux-rdma, lkml
On Tue, May 27, 2025 at 08:25:54PM -0700, Mina Almasry wrote:
On Tue, May 27, 2025 at 7:29 PM Byungchul Park [off-list ref] wrote:quoted
To simplify struct page, the effort to separate its own descriptor from struct page is required and the work for page pool is on going. Use netmem descriptor and APIs for page pool in netdevsim code. Signed-off-by: Byungchul Park <byungchul@sk.com> --- drivers/net/netdevsim/netdev.c | 19 ++++++++++--------- drivers/net/netdevsim/netdevsim.h | 2 +- 2 files changed, 11 insertions(+), 10 deletions(-)diff --git a/drivers/net/netdevsim/netdev.c b/drivers/net/netdevsim/netdev.c index af545d42961c..d134a6195bfa 100644 --- a/drivers/net/netdevsim/netdev.c +++ b/drivers/net/netdevsim/netdev.c@@ -821,7 +821,7 @@ nsim_pp_hold_read(struct file *file, char __user *data, struct netdevsim *ns = file->private_data; char buf[3] = "n\n"; - if (ns->page) + if (ns->netmem) buf[0] = 'y'; return simple_read_from_buffer(data, count, ppos, buf, 2);@@ -841,18 +841,19 @@ nsim_pp_hold_write(struct file *file, const char __user *data, rtnl_lock(); ret = count; - if (val == !!ns->page) + if (val == !!ns->netmem) goto exit; if (!netif_running(ns->netdev) && val) { ret = -ENETDOWN; } else if (val) { - ns->page = page_pool_dev_alloc_pages(ns->rq[0]->page_pool); - if (!ns->page) + ns->netmem = page_pool_alloc_netmems(ns->rq[0]->page_pool, + GFP_ATOMIC | __GFP_NOWARN);Can we add a page_pool_dev_alloc_netmems instead of doing this GFP at the callsite? Other drivers will be interested in using _dev_alloc_netmems as well.
Sounds good. I can add it tho, however, Tariq Toukan might also need the API while working on converting to netmem in mlx5. Since I will re-work on his work done, why don't we ask him to add the API so that he, I, and any other drivers can use it? +cc tariqt@nvidia.com Byungchul
-- Thanks, Mina