Thread (19 messages) 19 messages, 4 authors, 2018-08-07

Re: Re: [PATCH] [PATCH] mm: disable preemption before swapcache_free

From: Michal Hocko <mhocko@kernel.org>
Date: 2018-07-25 10:34:20
Also in: lkml

On Wed 25-07-18 17:53:07, zhaowuyun@wingtech.com wrote:
quoted
[Please do not top post - thank you]
[CC Hugh - the original patch was http://lkml.kernel.org/r/2018072514375722198958@wingtech.com]

On Wed 25-07-18 15:57:55, zhaowuyun@wingtech.com wrote:
quoted
That is a BUG we found in mm/vmscan.c at KERNEL VERSION 4.9.82
The code is quite similar in the current tree as well.
quoted
Sumary is TASK A (normal priority) doing __remove_mapping page preempted by TASK B (RT priority) doing __read_swap_cache_async,
the TASK A preempted before swapcache_free, left SWAP_HAS_CACHE flag in the swap cache,
the TASK B which doing __read_swap_cache_async, will not success at swapcache_prepare(entry) because the swap cache was exist, then it will loop forever because it is a RT thread...
the spin lock unlocked before swapcache_free, so disable preemption until swapcache_free executed ...
OK, I see your point now. I have missed the lock is dropped before
swapcache_free. How can preemption disabling prevent this race to happen
while the code is preempted by an IRQ?
--
Michal Hocko
SUSE Labs 
Hi Michal,

The action what processes __read_swap_cache_async is on the process context, so I think disable preemption is enough.
So what you are saying is that no IRQ or other non-process contexts will
not loop in __read_swap_cache_async so the live lock is not possible?
-- 
Michal Hocko
SUSE Labs
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help