lkml.org 
[lkml]   [2023]   [Nov]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Memory corruption with CONFIG_SWIOTLB_DYNAMIC=y
On Fri, 3 Nov 2023 19:59:49 +0100
Petr Tesařík <petr@tesarici.cz> wrote:

> > Not sure how to properly fix this as the different alignment
> > requirements get pretty complex quickly. So would appreciate your
> > input.
>
> I don't think it's possible to improve the allocation logic without
> modifying the page allocator and/or the DMA atomic pool allocator to
> take additional constraints into account.

I don't understand. What speaks against calculating the amount of space
needed, so that with the waste we can still fit the bounce-buffer in the
pool?

I believe alloc_size + combined_mask is a trivial upper bound, but we can
do slightly better since we know that we allocate pages.

For the sake of simplicity let us assume we only have the min_align_mask
requirement. Then I believe the worst case is that we need
(orig_addr & min_align_mask & PAGE_MASK) + (min_align_mask & ~PAGE_MASK)
extra space to fit.

Depending on how the semantics pan out one may be able to replace
min_align_mask with combined_mask.

Is your point that for large combined_mask values
_get_free_pages(GFP_NOWAIT | __GFP_NOWARN, required_order) is not
likely to complete successfully?

Regards,
Halil




\
 
 \ /
  Last update: 2023-11-20 13:52    [W:0.136 / U:3.660 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site