Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp432049pxb; Wed, 14 Apr 2021 20:20:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz2k/a0Z6ssQ0KMeS3SIrEaERWN17zk5ieVKvUsa30fQOrGrrP4ZiHKC9OTbnaP6CJCSKzb X-Received: by 2002:a17:903:3106:b029:e9:15e8:250e with SMTP id w6-20020a1709033106b02900e915e8250emr1592519plc.33.1618456821058; Wed, 14 Apr 2021 20:20:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618456821; cv=none; d=google.com; s=arc-20160816; b=opfJ+KqFxi2t1aPWuymDMNSlSB9eJlbz5wWb8SyfG8SrnekG75SizINI1l+KXWA8Sv 4wy0rxnyTpF+elskv1kFv3DKf4TXa4GOTJSTDnS7azcaOZ94x3KxdN2V2yKC+kIRWkud H+1/6In6Q1Adx/emvsDRsMlLgVzukBcFxt/rt4cSdh5/P2mQx60oV3JHiZLXKTUlNu/O sYEpVaZTblSf5f4lV/4R8v6lwg1Xc/LuTNh1JVgk+hAW2bzINly5MHYUtc8eIqQLtsfM CYTaksto/1tWDpXkjByuvclRMCtd+wzuo6Ti9zGA717o6aSZB5rhGmBwIyqUKjv2M/hb 6tGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=5eRr+4BiOpSeKHP6oXHQchs1clUnYleqpHpAKDoYCQA=; b=bVFlC1tTlPj9757rLEROQTITGGbB/6iZcrlmZEuhYgj6r2n0J1djaGUu4Sn1q49S7N EKT4uIl6OYYJK/D5G6aTRHJYi6oO1BWZaflbaVeTs+u8E11yCpmjApAa3mR6ujP56kHP BiSBh+nTZ9vt93KlKvnTAxt4ajV9+l8J678NTks1mFja/sRyMVkJ5dSrOsP9CNA7mACY 9z5nZy+o3e9p1Y2y1BijJH789BMxhJ/pB+qxnRv6oQJvjo0aKD/ZtLeeVzdFDvheZm9c 8j/VzSTRSb7XUTDxlHDDutFbRdUFMyCp1U/cYdCTfImUq77WahNV4fMVGm2tjnhRzo8t 9Q4Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u4si1841050plg.371.2021.04.14.20.20.08; Wed, 14 Apr 2021 20:20:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229618AbhDODUC (ORCPT + 99 others); Wed, 14 Apr 2021 23:20:02 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:16590 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229467AbhDODUB (ORCPT ); Wed, 14 Apr 2021 23:20:01 -0400 Received: from DGGEMS407-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4FLPf84wj3z17Qhk; Thu, 15 Apr 2021 11:17:20 +0800 (CST) Received: from [10.174.176.162] (10.174.176.162) by DGGEMS407-HUB.china.huawei.com (10.3.19.207) with Microsoft SMTP Server id 14.3.498.0; Thu, 15 Apr 2021 11:19:34 +0800 Subject: Re: [PATCH 2/5] swap: fix do_swap_page() race with swapoff To: Tim Chen , "Huang, Ying" 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> <7ce9d6a2-6a9a-1203-0566-8a3bf478876f@linux.intel.com> From: Miaohe Lin Message-ID: Date: Thu, 15 Apr 2021 11:19:34 +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: <7ce9d6a2-6a9a-1203-0566-8a3bf478876f@linux.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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021/4/15 0:13, Tim Chen wrote: > > > On 4/13/21 6:04 PM, 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(). >> > > 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. > Looks like a good way to organize this patch series. Many thanks! > Tim > . >