Message ID | 20210204105638.1584-1-haokexin@gmail.com |
---|---|
Headers | show |
Series | net: Avoid the memory waste in some Ethernet drivers | expand |
On Thu, Feb 4, 2021 at 3:06 AM Kevin Hao <haokexin@gmail.com> wrote: > > In the current implementation of page_frag_alloc(), it doesn't have > any align guarantee for the returned buffer address. But for some > hardwares they do require the DMA buffer to be aligned correctly, > so we would have to use some workarounds like below if the buffers > allocated by the page_frag_alloc() are used by these hardwares for > DMA. > buf = page_frag_alloc(really_needed_size + align); > buf = PTR_ALIGN(buf, align); > > These codes seems ugly and would waste a lot of memories if the buffers > are used in a network driver for the TX/RX. So introduce > page_frag_alloc_align() to make sure that an aligned buffer address is > returned. > > Signed-off-by: Kevin Hao <haokexin@gmail.com> > Acked-by: Vlastimil Babka <vbabka@suse.cz> > --- > v3: Use align mask as suggested by Alexander. > > include/linux/gfp.h | 12 ++++++++++-- > mm/page_alloc.c | 8 +++++--- > 2 files changed, 15 insertions(+), 5 deletions(-) Looks good to me. Reviewed-by: Alexander Duyck <alexanderduyck@fb.com>
Hello: This series was applied to netdev/net-next.git (refs/heads/master): On Thu, 4 Feb 2021 18:56:34 +0800 you wrote: > Hi, > > v3: > - Adjust patch 1 and 2 according to Alexander's suggestion. > - Add Tested-by from Subbaraya. > - Add Reviewed-by from Ioana. > > [...] Here is the summary with links: - [net-next,v3,1/4] mm: page_frag: Introduce page_frag_alloc_align() https://git.kernel.org/netdev/net-next/c/b358e2122b9d - [net-next,v3,2/4] net: Introduce {netdev,napi}_alloc_frag_align() https://git.kernel.org/netdev/net-next/c/3f6e687dff39 - [net-next,v3,3/4] net: octeontx2: Use napi_alloc_frag_align() to avoid the memory waste https://git.kernel.org/netdev/net-next/c/1b041601c798 - [net-next,v3,4/4] net: dpaa2: Use napi_alloc_frag_align() to avoid the memory waste https://git.kernel.org/netdev/net-next/c/d0dfbb9912d9 You are awesome, thank you! -- Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html