lkml.org 
[lkml]   [2021]   [May]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH 0/6 v2] Calculate pcp->high based on zone sizes and active CPUs
Date
On 28.05.21 12:09, Mel Gorman wrote:
> On Fri, May 28, 2021 at 11:52:53AM +0200, David Hildenbrand wrote:
>>>> "Disable pcplists so that page isolation cannot race with freeing
>>>> in a way that pages from isolated pageblock are left on pcplists."
>>>>
>>>> Guess we'd then want to move the draining before start_isolate_page_range()
>>>> in alloc_contig_range().
>>>>
>>>
>>> Or instead of draining, validate the PFN range in alloc_contig_range
>>> is within the same zone and if so, call zone_pcp_disable() before
>>> start_isolate_page_range and enable after __alloc_contig_migrate_range.
>>>
>>
>> We require the caller to only pass a range within a single zone, so that
>> should be fine.
>>
>> The only ugly thing about zone_pcp_disable() is
>> mutex_lock(&pcp_batch_high_lock) which would serialize all
>> alloc_contig_range() and even with offline_pages().
>>
>
> True so it would have to be accessed if that is bad or not. If racing
> against offline_pages, memory is potentially being offlined in the
> target zone which may cause allocation failure. If racing with other
> alloc_contig_range calls, the two callers are potentially racing to
> isolate and allocate the same range. The arguement could be made that
> alloc_contig_ranges should be serialised within one zone to improve the
> allocation success rate at the potential cost of allocation latency.

We have 3 main users of alloc_contig_range():

1. CMA

CMA synchronizes allocation within a CMA area via the allocation bitmap.
So parallel CMA is perfectly possible and avoids races by design.

2. alloc_contig_pages() / Gigantic pages

Gigantic page allocation could race with virtio-mem. CMA does not apply.
Possible but unlikely to matter in practice. virtio-mem will retry later
again.

3. virito-mem

A virtio-mem device only operates on its assigned memory region, so we
cannot have alloc_contig_range() from different devices racing, even
when within a single zone. It could only race with gigantic pages as CMA
does not apply.


So serializing would mostly harm parallel CMA (possible and likely) and
parallel virtio-mem operation (e.g., unplug memory of two virtio-mem
devices -- unlikely but possible).


Memory offlining racing with CMA is not an issue (impossible).
virtio-mem synchronizes with memory offlining via memory notifiers,
there is only a tiny little race window that usually doesn't matter as
virtio-mem is expected to usually triggers offlining itself, and not
user space rancomly. Memory offlining can race with dynamic gigantic
page allocation, wich is highly unreliable already.

I wonder if we could optimize locking in zone_pcp_disable() instead.

--
Thanks,

David / dhildenb

\
 
 \ /
  Last update: 2021-05-28 12:21    [W:0.091 / U:0.656 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site