Re: [PATCH 2/5] swap: fix do_swap_page() race with swapoff
From: Tim Chen
Date: Wed Apr 14 2021 - 12:14:23 EST
On 4/13/21 6:04 PM, Huang, Ying wrote:
> Tim Chen <tim.c.chen@xxxxxxxxxxxxxxx> writes:
>
>> On 4/12/21 6:27 PM, Huang, Ying wrote:
>>
>>>
>>> This isn't the commit that introduces the race. You can use `git blame`
>>> find out the correct commit. For this it's commit 0bcac06f27d7 "mm,
>>> swap: skip swapcache for swapin of synchronous device".
>>>
>>> And I suggest to merge 1/5 and 2/5 to make it easy to get the full
>>> picture.
>>
>> I'll suggest make fix to do_swap_page race with get/put_swap_device
>> as a first patch. Then the per_cpu_ref stuff in patch 1 and patch 2 can
>> be combined together.
>
> The original get/put_swap_device() use rcu_read_lock/unlock(). I don't
> think it's good to wrap swap_read_page() with it. After all, some
> complex operations are done in swap_read_page(), including
> blk_io_schedule().
>
In that case then have the patches to make get/put_swap_device to use
percpu_ref first. And the patch to to fix the race in do_swap_page
later in another patch.
Patch 2 is mixing the two.
Tim