From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from invmail4.hynix.com (exvmail4.hynix.com [166.125.252.92]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A197330F951; Fri, 17 Oct 2025 06:26:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=166.125.252.92 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760682396; cv=none; b=b8rEW4UdAtPWuW7jZ/+qOefWfWizHXRgJMOM/R1eqZuUtTOZksPRXpcSVLRxbrDHiusaDfRcEjxOBQBAKsTXyNJFL7eWgxPG/aFp5V+H2Dtut4eSQ7mh3L3YSuddSSikevkIAe5rty6rNnF4taqxXMAGREBpEYkZZEcRmL/3Sd8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760682396; c=relaxed/simple; bh=28OhauPmUcAgORsj2s2x+3Bd/Y90rouYgwE26pYkae0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Lh7Tqioh3jt0WOKJhigFr9yd1ByFFiHOuw2lUafnVPQ5NiR5SUsTSUWLDi7W9ckLZrWrRQv6knljFHUc5vNQb/bM56CbMxnK4jXci4hlc8unKRBbgg+ok9bMLvnyjndYOvyQ+PxJMTOeCWXMzyEnyJ2Zv4BEU9BpGcwYKXPdX+0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sk.com; spf=pass smtp.mailfrom=sk.com; arc=none smtp.client-ip=166.125.252.92 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sk.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sk.com X-AuditID: a67dfc5b-c45ff70000001609-77-68f1e18c2a50 Date: Fri, 17 Oct 2025 15:26:14 +0900 From: Byungchul Park To: almasrymina@google.com Cc: davem@davemloft.net, edumazet@google.com, horms@kernel.org, hawk@kernel.org, ilias.apalodimas@linaro.org, sdf@fomichev.me, dw@davidwei.uk, ap420073@gmail.com, dtatulea@nvidia.com, toke@redhat.com, io-uring@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, kernel_team@skhynix.com, max.byungchul.park@gmail.com, ziy@nvidia.com, willy@infradead.org, david@redhat.com, axboe@kernel.dk, kuba@kernel.org, pabeni@redhat.com, asml.silence@gmail.com Subject: Re: [PATCH net-next] page_pool: check if nmdesc->pp is !NULL to confirm its usage as pp for net_iov Message-ID: <20251017062614.GA57077@system.software.com> References: <20251016063657.81064-1-byungchul@sk.com> <20251016233139.GA37304@system.software.com> Precedence: bulk X-Mailing-List: io-uring@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20251016233139.GA37304@system.software.com> User-Agent: Mutt/1.9.4 (2018-02-28) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrHIsWRmVeSWpSXmKPExsXC9ZZnoW7Pw48ZBq+nyVqs/lFh8XPNcyaL Oau2MVqsvtvPZjHnfAuLxdf1v5gtdu56zmjxasZaNounxx6xW+xp385s8aj/BJtFb8tvZot3 redYLC5s62O1uLxrDpvFhYm9rBbHFohZfDv9htHi6sxdTBaXDj9isfj9Ayg5++g9dgcxjy0r bzJ5XJsxkcXjxr5TTB47Z91l91iwqdRj8wotj8tnSz02repk87hzbQ+bR2/zOzaP9/uusnl8 3iQXwBPFZZOSmpNZllqkb5fAldG2qpu54KNKxfwnq9gaGOfKdjFyckgImEhs/LSdFcZu2HOH HcRmEVCVuLdkGzOIzSagLnHjxk8wW0RASuLC4vtsXYxcHMwCj5gl5i/fy9jFyM4hLJAn8cwY pIRXwELi8MNGRhBbSCBF4n7XK2aIuKDEyZlPWEBsZgEtiRv/XjJ1MXIA2dISy/9xgIQ5BSwl DrUtAisXFVCWOLDtOBPIJgmBU+wSG5/9ZYE4U1Li4IobLBMYBWYhGT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ILUIpgsEwenVAPjbr4LqV7/LH6nhh7c 6+r667TNT46cuant00Ss4zf/kRHmX5jXPNHw1JW5FX7K93pfz5gYYK65X23rnv1pxw8bKv8+ sHpde1lk7He1rQmTfwvvNQng2rFx642QOU6HNGs36Wrxn+Z95DKpcY1G+czqfY6TBBsufTpS 0VQe2/ZbbdOuGzPE5y3kUWIpzkg01GIuKk4EADV5eNO4AgAA X-CFilter-Loop: Reflected On Fri, Oct 17, 2025 at 08:31:39AM +0900, Byungchul Park wrote: > On Thu, Oct 16, 2025 at 03:36:57PM +0900, Byungchul Park wrote: > > ->pp_magic field in struct page is current used to identify if a page > > belongs to a page pool. However, ->pp_magic will be removed and page > > type bit in struct page e.g. PGTY_netpp should be used for that purpose. > > > > As a preparation, the check for net_iov, that is not page-backed, should > > avoid using ->pp_magic since net_iov doens't have to do with page type. > > Instead, nmdesc->pp can be used if a net_iov or its nmdesc belongs to a > > page pool, by making sure nmdesc->pp is NULL otherwise. > > > > For page-backed netmem, just leave unchanged as is, while for net_iov, > > make sure nmdesc->pp is initialized to NULL and use nmdesc->pp for the > > check. Hi Mina, This patch extracts the network part from the following work: https://lore.kernel.org/all/20250729110210.48313-1-byungchul@sk.com/ Can I keep your reviewed-by tag on this patch? Reviewed-by: Mina Almasry Byungchul > +cc David Hildenbrand > +cc Zi Yan > +cc willy@infradead.org > > Byungchul > > > > Signed-off-by: Byungchul Park > > --- > > io_uring/zcrx.c | 4 ++++ > > net/core/devmem.c | 1 + > > net/core/netmem_priv.h | 6 ++++++ > > net/core/page_pool.c | 16 ++++++++++++++-- > > 4 files changed, 25 insertions(+), 2 deletions(-) > > > > diff --git a/io_uring/zcrx.c b/io_uring/zcrx.c > > index 723e4266b91f..cf78227c0ca6 100644 > > --- a/io_uring/zcrx.c > > +++ b/io_uring/zcrx.c > > @@ -450,6 +450,10 @@ static int io_zcrx_create_area(struct io_zcrx_ifq *ifq, > > area->freelist[i] = i; > > atomic_set(&area->user_refs[i], 0); > > niov->type = NET_IOV_IOURING; > > + > > + /* niov->desc.pp is already initialized to NULL by > > + * kvmalloc_array(__GFP_ZERO). > > + */ > > } > > > > area->free_count = nr_iovs; > > diff --git a/net/core/devmem.c b/net/core/devmem.c > > index d9de31a6cc7f..f81b700f1fd1 100644 > > --- a/net/core/devmem.c > > +++ b/net/core/devmem.c > > @@ -291,6 +291,7 @@ net_devmem_bind_dmabuf(struct net_device *dev, > > niov = &owner->area.niovs[i]; > > niov->type = NET_IOV_DMABUF; > > niov->owner = &owner->area; > > + niov->desc.pp = NULL; > > page_pool_set_dma_addr_netmem(net_iov_to_netmem(niov), > > net_devmem_get_dma_addr(niov)); > > if (direction == DMA_TO_DEVICE) > > diff --git a/net/core/netmem_priv.h b/net/core/netmem_priv.h > > index 23175cb2bd86..fb21cc19176b 100644 > > --- a/net/core/netmem_priv.h > > +++ b/net/core/netmem_priv.h > > @@ -22,6 +22,12 @@ static inline void netmem_clear_pp_magic(netmem_ref netmem) > > > > static inline bool netmem_is_pp(netmem_ref netmem) > > { > > + /* Use ->pp for net_iov to identify if it's pp, which requires > > + * that non-pp net_iov should have ->pp NULL'd. > > + */ > > + if (netmem_is_net_iov(netmem)) > > + return !!netmem_to_nmdesc(netmem)->pp; > > + > > return (netmem_get_pp_magic(netmem) & PP_MAGIC_MASK) == PP_SIGNATURE; > > } > > > > diff --git a/net/core/page_pool.c b/net/core/page_pool.c > > index 1a5edec485f1..2756b78754b0 100644 > > --- a/net/core/page_pool.c > > +++ b/net/core/page_pool.c > > @@ -699,7 +699,13 @@ s32 page_pool_inflight(const struct page_pool *pool, bool strict) > > void page_pool_set_pp_info(struct page_pool *pool, netmem_ref netmem) > > { > > netmem_set_pp(netmem, pool); > > - netmem_or_pp_magic(netmem, PP_SIGNATURE); > > + > > + /* For page-backed, pp_magic is used to identify if it's pp. > > + * For net_iov, it's ensured nmdesc->pp is non-NULL if it's pp > > + * and nmdesc->pp is NULL if it's not. > > + */ > > + if (!netmem_is_net_iov(netmem)) > > + netmem_or_pp_magic(netmem, PP_SIGNATURE); > > > > /* Ensuring all pages have been split into one fragment initially: > > * page_pool_set_pp_info() is only called once for every page when it > > @@ -714,7 +720,13 @@ void page_pool_set_pp_info(struct page_pool *pool, netmem_ref netmem) > > > > void page_pool_clear_pp_info(netmem_ref netmem) > > { > > - netmem_clear_pp_magic(netmem); > > + /* For page-backed, pp_magic is used to identify if it's pp. > > + * For net_iov, it's ensured nmdesc->pp is non-NULL if it's pp > > + * and nmdesc->pp is NULL if it's not. > > + */ > > + if (!netmem_is_net_iov(netmem)) > > + netmem_clear_pp_magic(netmem); > > + > > netmem_set_pp(netmem, NULL); > > } > > > > > > base-commit: e1f5bb196f0b0eee197e06d361f8ac5f091c2963 > > -- > > 2.17.1