Thread (8 messages) 8 messages, 3 authors, 2021-02-06

Re: [PATCH net-next v3 1/4] mm: page_frag: Introduce page_frag_alloc_align()

From: Alexander Duyck <hidden>
Date: 2021-02-04 16:11:34
Also in: linux-mm

On Thu, Feb 4, 2021 at 3:06 AM Kevin Hao [off-list ref] 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 <redacted>
Acked-by: Vlastimil Babka <redacted>
---
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>
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help