From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 27AD9C433ED for ; Wed, 14 Apr 2021 02:20:49 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A1DC9610E8 for ; Wed, 14 Apr 2021 02:20:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A1DC9610E8 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=huawei.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id EF8496B0070; Tue, 13 Apr 2021 22:20:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E81B26B0071; Tue, 13 Apr 2021 22:20:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CFB4F6B0072; Tue, 13 Apr 2021 22:20:47 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0133.hostedemail.com [216.40.44.133]) by kanga.kvack.org (Postfix) with ESMTP id B0E456B0070 for ; Tue, 13 Apr 2021 22:20:47 -0400 (EDT) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 6E2FE4061F5D for ; Wed, 14 Apr 2021 02:20:47 +0000 (UTC) X-FDA: 78029369334.07.4F427F3 Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) by imf04.hostedemail.com (Postfix) with ESMTP id A776412E for ; Wed, 14 Apr 2021 02:20:44 +0000 (UTC) Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4FKmMv6nqQzNvYw; Wed, 14 Apr 2021 10:17:47 +0800 (CST) Received: from [10.174.176.162] (10.174.176.162) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.498.0; Wed, 14 Apr 2021 10:20:37 +0800 Subject: Re: [PATCH 2/5] swap: fix do_swap_page() race with swapoff To: "Huang, Ying" , Tim Chen CC: , , , , , , , , , , , References: <20210408130820.48233-1-linmiaohe@huawei.com> <20210408130820.48233-3-linmiaohe@huawei.com> <87o8ejug76.fsf@yhuang6-desk1.ccr.corp.intel.com> <878s5lu16i.fsf@yhuang6-desk1.ccr.corp.intel.com> From: Miaohe Lin Message-ID: <26c15777-d775-967b-3ddf-1db983154053@huawei.com> Date: Wed, 14 Apr 2021 10:20:37 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: <878s5lu16i.fsf@yhuang6-desk1.ccr.corp.intel.com> Content-Type: text/plain; charset="windows-1252" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.176.162] X-CFilter-Loop: Reflected X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: A776412E X-Stat-Signature: qmx553q6g65qiemnm8yw4i178rdkz8hk Received-SPF: none (huawei.com>: No applicable sender policy available) receiver=imf04; identity=mailfrom; envelope-from=""; helo=szxga05-in.huawei.com; client-ip=45.249.212.191 X-HE-DKIM-Result: none/none X-HE-Tag: 1618366844-440108 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 2021/4/14 9:04, Huang, Ying wrote: > Tim Chen 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(). > The patch was split to make it easier to review originally, i.e. 1/5 introduces the percpu_ref to swap and 2/5 uses it to fix the race between do_swap_page() and swapoff. Btw, I have no preference for merging 1/5 and 2/5 or not. > Best Regards, > Huang, Ying > . >