lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20251107044708.GA54407@system.software.com>
Date: Fri, 7 Nov 2025 13:47:08 +0900
From: Byungchul Park <byungchul@...com>
To: Jakub Kicinski <kuba@...nel.org>
Cc: linux-mm@...ck.org, netdev@...r.kernel.org,
	linux-kernel@...r.kernel.org, kernel_team@...ynix.com,
	harry.yoo@...cle.com, ast@...nel.org, daniel@...earbox.net,
	davem@...emloft.net, hawk@...nel.org, john.fastabend@...il.com,
	sdf@...ichev.me, saeedm@...dia.com, leon@...nel.org,
	tariqt@...dia.com, mbloch@...dia.com, andrew+netdev@...n.ch,
	edumazet@...gle.com, pabeni@...hat.com, akpm@...ux-foundation.org,
	david@...hat.com, lorenzo.stoakes@...cle.com,
	Liam.Howlett@...cle.com, vbabka@...e.cz, rppt@...nel.org,
	surenb@...gle.com, mhocko@...e.com, horms@...nel.org,
	jackmanb@...gle.com, hannes@...xchg.org, ziy@...dia.com,
	ilias.apalodimas@...aro.org, willy@...radead.org,
	brauner@...nel.org, kas@...nel.org, yuzhao@...gle.com,
	usamaarif642@...il.com, baolin.wang@...ux.alibaba.com,
	almasrymina@...gle.com, toke@...hat.com, asml.silence@...il.com,
	bpf@...r.kernel.org, linux-rdma@...r.kernel.org,
	sfr@...b.auug.org.au, dw@...idwei.uk, ap420073@...il.com,
	dtatulea@...dia.com
Subject: Re: [RFC mm v5 1/2] page_pool: check nmdesc->pp to see its usage as
 page pool for net_iov not page-backed

On Thu, Nov 06, 2025 at 06:08:10PM -0800, Jakub Kicinski wrote:
> On Fri, 7 Nov 2025 10:59:02 +0900 Byungchul Park wrote:
> > > > page-backed, the identification cannot be based on the page_type.
> > > > Instead, nmdesc->pp can be used to see if it belongs to a page pool, by
> > > > making sure nmdesc->pp is NULL otherwise.
> > >
> > > Please explain why. Isn't the type just a value in a field?
> > > Which net_iov could also set accordingly.. ?
> >
> > page_type field is in 'struct page', so 'struct page' can check the type.
> >
> > However, the field is not in 'struct net_iov', so 'struct net_iov' that
> > is not backed by page, cannot use the type checking to see if it's page
> > pool'ed instance.
> >
> > I'm afraid I didn't get your questions.  I will try to explain again
> > properly if you give me more detail and example about your questions or
> > requirement.
> 
> net_iov has members in the same place as page. page_type is just
> a field right now.

The current layout is:

  struct page {
	memdesc_flags_t flags;
	union {
		...
		struct {
			unsigned long pp_magic;
			struct page_pool *pp;
			unsigned long _pp_mapping_pad;
			unsigned long dma_addr;
			atomic_long_t pp_ref_count;
		};
		...
	};
	unsigned int page_type;
	...
  };

  struct net_iov {
	union {
		struct netmem_desc desc;
		struct
		{
			unsigned long _flags;
			unsigned long pp_magic;
			struct page_pool *pp;
			unsigned long _pp_mapping_pad;
			unsigned long dma_addr;
			atomic_long_t pp_ref_count;
		};
	};
	struct net_iov_area *owner; // the same offet of page_type
	enum net_iov_type type;
  };

The offset of page_type in struct page cannot be used in struct net_iov
for the same purpose, since the offset in struct net_iov is for storing
(struct net_iov_area *)owner.

Yeah, you can tell 'why don't we add the field, page_type, to struct
net_iov (or struct netmem_desc)' so as to be like:

  struct net_iov {
	union {
		struct netmem_desc desc;
		struct
		{
			unsigned long _flags;
			unsigned long pp_magic;
			struct page_pool *pp;
			unsigned long _pp_mapping_pad;
			unsigned long dma_addr;
			atomic_long_t pp_ref_count;
+			unsigned int page_type; // add this field newly
		};
	};
	struct net_iov_area *owner; // the same offet of page_type
	enum net_iov_type type;
  };

I think we can make it anyway but it makes less sense to add page_type
to struct net_iov, only for PGTY_netpp.

It'd be better to use netmem_desc->pp for that purpose, IMO.

Thoughts?

	Byungchul

> static __always_inline int Page##uname(const struct page *page)         \
> {                                                                       \
>         return data_race(page->page_type >> 24) == PGTY_##lname;        \
> }                                                                       \
> 
> The whole thing works right now by overlaying one struct on top of
> another, and shared members being in the same places.
> 
> Is this clear enough?

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ