Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp3402411pxb; Wed, 14 Apr 2021 04:56:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx6ZpiFigeirjcCp/pjUgwpMm474gX6Td/OFMMAc4SUQ6AWDM0/b9SBMsKFFGZ3vXDmUhKp X-Received: by 2002:a17:90a:bb0c:: with SMTP id u12mr3265843pjr.234.1618401384921; Wed, 14 Apr 2021 04:56:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618401384; cv=none; d=google.com; s=arc-20160816; b=uFwLdDwAhOJScodpnpgXTvyhvFGfyK7bBCj6lkGWYLHlHVzKv0J09h9Omf7cU3nz+f Pjhz7qql2ztDK+sNbeblfC//745L9DFquhbBYWpFsHhMVf1S2ZlPoEmF3M9BIAZZ0qVE 1PgprJw62a9ytonkZ43kBe/y95hAoqOvMnLirsz1cjdjNrb31Dm1VoQUVe6lCubeF1zH 72msN9q+5XFzvM3yJJox1qeZvH3uPi3mpZuIUxmI5vc+6a0FBrwlRjHcch/F4pTv/ztu CVz86/aNP8TiLa2Fx8k6Fz2yOZjruCB2sl30Ig9XDXG3WC1YFpcT8tNYLsDBtPpGxSGN teMg== 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=NHa75Qd82K+cxyhW9Od4dOaw3rRW7o57MRokOiJkb5k=; b=hAlmKvAxn/RUGYG7egkvyKlu1UJpteL23JOkqa2d08/xpVXi/iCkAKYHVmKx/6f8ji M9GeNFV/uuSraddDcmS4W13Oslsk/+4UyKIUg1fM0q/cWAlflouAxh3KSNx/DgqxPxIu OWo+9tUBwrYQblHsCs087lB33CfndFccvu5qCkr9fMyxx5IUm+UqQ3OVbLuC2iVaGxjH pWnTHFyxkoRP93kAMkrNYn4egEsyzclIOK0C8U+mDoV77v97LUspWGxfEm6N96m6F3tz h++M+SdIF9QYkxIhia7lGC9V8jPErHccSywvi1gYAOVFYX3rEPV9WdCGi364RY1kMpQM sZyA== 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 h4si17230597pfc.139.2021.04.14.04.56.12; Wed, 14 Apr 2021 04:56:24 -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 S238264AbhDNCVF (ORCPT + 99 others); Tue, 13 Apr 2021 22:21:05 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:16555 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237922AbhDNCVE (ORCPT ); Tue, 13 Apr 2021 22:21:04 -0400 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > . >