Thread (14 messages) 14 messages, 5 authors, 2021-04-01

Re: [PATCH v2] kernel/resource: Fix locking in request_free_mem_region

From: David Hildenbrand <hidden>
Date: 2021-03-26 08:58:45
Also in: lkml

On 26.03.21 02:20, Alistair Popple wrote:
request_free_mem_region() is used to find an empty range of physical
addresses for hotplugging ZONE_DEVICE memory. It does this by iterating
over the range of possible addresses using region_intersects() to see if
the range is free.
Just a high-level question: how does this iteract with memory 
hot(un)plug? IOW, how defines and manages the "range of possible 
addresses" ?
region_intersects() obtains a read lock before walking the resource tree
to protect against concurrent changes. However it drops the lock prior
to returning. This means by the time request_mem_region() is called in
request_free_mem_region() another thread may have already reserved the
requested region resulting in unexpected failures and a message in the
kernel log from hitting this condition:
I am confused. Why can't we return an error to the caller and let the 
caller continue searching? This feels much simpler than what you propose 
here. What am I missing?



-- 
Thanks,

David / dhildenb

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help