Re: [PATCH net-next v10 02/12] netmem: use netmem_desc instead of page to access ->pp in __netmem_get_pp()

From
Byungchul Park <byungchul@sk.com>
Date
2025-07-17 00:54:34
Also in
bpf, imx, intel-wired-lan, linux-mediatek, linux-mm, linux-rdma, linux-wireless, lkml
Reply to
Mina Almasry, 2025-07-16
On Wed, Jul 16, 2025 at 12:41:04PM -0700, Mina Almasry wrote:
On Tue, Jul 15, 2025 at 9:51 PM Byungchul Park [off-list ref] wrote:
quoted
On Tue, Jul 15, 2025 at 12:09:34PM -0700, Mina Almasry wrote:
quoted
On Mon, Jul 14, 2025 at 6:36 PM Byungchul Park [off-list ref] wrote:
quoted
On Mon, Jul 14, 2025 at 12:58:15PM -0700, Mina Almasry wrote:
quoted
On Mon, Jul 14, 2025 at 12:37 PM Mina Almasry [off-list ref] wrote:
   2) Introduce the unsafe version, __netmem_to_nmdesc(), and use it in
      __netmem_get_pp().
No need following Pavel's feedback. We can just delete
__netmem_get_pp. If we do find a need in the future to extract the
netmem_desc from a netmem_ref, I would rather we do a straight cast
from netmem_ref to netmem_desc rather than netmem_ref -> pages/net_iov
-> netmem_desc.

But that seems unnecessary for this series.
No.  The series should remove accessing ->pp through page.

I will kill __netmem_get_pp() as you and I prefer.  However,
__netmem_get_pp() users e.i. libeth_xdp_return_va() and
libeth_xdp_tx_fill_buf() should be altered.  I will modify the code like:

as is: __netmem_get_pp(netmem)
to be: __netmem_nmdesc(netmem)->pp

Is it okay with you?
When Pavel and I were saying 'remove __netmem_get_pp', I think we
meant to remove the entire concept of unsafe netmem -> page
conversions. I think we both don't like them. From this perspective,
__netmem_nmdesc(netmem)->pp is just as bad as __netmem_get_pp(netmem).

I think since the unsafe netmem-to-page casts are already in mainline,
lets assume they should stay there until someone feels strongly enough
to remove them. The logic in Olek's patch is sound:

https://lore.kernel.org/all/20241203173733.3181246-8-aleksander.lobakin@intel.com/ (local)

Header buffer page pools do always use pages and will likely remain so
for a long time, so I guess lets continue to support them rather than
try to remove them in this series. A followup series could try to
remove them.
At the beginning of this work, I was unconfortable to see the network
code keeps the unsafe version maybe for optimization(?).  I decided to
accept it, thinking there must be some reason.

However, it'd be good that a followup series would try to remove them as
you said.
quoted
quoted
quoted
   3) Rename __netmem_clear_lsb() to netmem_to_nmdesc(), and return
      netmem_desc, and use it in all users of __netmem_clear_lsb().
Following Pavel's comment, this I think also is not necessary for this
series. Cleaning up the return value of __netmem_clear_lsb is good
work I think, but we're already on v10 of this and I think it would
unnecessary to ask for added cleanups. We can do the cleanup on top.
However, I still need to include 'introduce __netmem_nmdesc() helper'
Yes.
quoted
in this series since it should be used to remove __netmem_get_pp() as I
lets keep __netmem_get_pp, which does a `return
Okay.  I will.

	Byungchul
__netmem_nmdesc(netmem)->pp;` In general we avoid allowing the driver
to do any netmem casts in the driver code, and we do any casting in
core.
quoted
described above.  I think I'd better add netmem_nmdesc() too while at it.
Yes. netmem_nmdesc should replace __netmem_clear_lsb.
quoted
I assume __netmem_nmdesc() is an unsafe version not clearing lsb.  The
Yes.
quoted
safe version, netmem_nmdesc() needs an additional operation clearing lsb.
Yes.


--
Thanks,
Mina
Thread (29 messages) 29 messages, 4 authors, last reply 2025-07-17
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help