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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Feb 02, 2021 at 12:48:28PM +0100, Vlastimil Babka wrote:
> On 2/2/21 12:36 PM, Ioana Ciornei wrote:
> > On Sun, Jan 31, 2021 at 03:44:23PM +0800, Kevin Hao 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.
> > 
> > Isn't the memory wasted even with this change?
> 
> Yes, but less of it. Not always full amount of align, but up to it. Perhaps even
> zero.

Indeed, the worst case is still there but we gain by not allocating the
full 'size + align' all the time.

Thanks.

> 
> > I am not familiar with the frag allocator so I might be missing
> > something, but from what I understood each page_frag_cache keeps only
> > the offset inside the current page being allocated, offset which you
> > ALIGN_DOWN() to match the alignment requirement. I don't see how that
> > memory between the non-aligned and aligned offset is going to be used
> > again before the entire page is freed.
> 
> True, thath's how page_frag is designed. The align amounts would be most likely
> too small to be usable anyway.





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux