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=-10.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable 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 721C8C43460 for ; Fri, 9 Apr 2021 08:01:35 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 14C5261182 for ; Fri, 9 Apr 2021 08:01:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 14C5261182 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 93D3C6B006C; Fri, 9 Apr 2021 04:01:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8C53B6B006E; Fri, 9 Apr 2021 04:01:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 73F256B0070; Fri, 9 Apr 2021 04:01:34 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0030.hostedemail.com [216.40.44.30]) by kanga.kvack.org (Postfix) with ESMTP id 540CB6B006C for ; Fri, 9 Apr 2021 04:01:34 -0400 (EDT) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 22C4E1836779C for ; Fri, 9 Apr 2021 08:01:34 +0000 (UTC) X-FDA: 78012084108.19.832A323 Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) by imf13.hostedemail.com (Postfix) with ESMTP id EAE94E00012E for ; Fri, 9 Apr 2021 08:01:30 +0000 (UTC) Received: from DGGEMS403-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4FGrBD65z7z1BGK1; Fri, 9 Apr 2021 15:59:16 +0800 (CST) Received: from [10.174.179.9] (10.174.179.9) by DGGEMS403-HUB.china.huawei.com (10.3.19.203) with Microsoft SMTP Server id 14.3.498.0; Fri, 9 Apr 2021 16:01:23 +0800 Subject: Re: [PATCH 0/5] close various race windows for swap To: riteshh CC: , , , , , , , , , , , , , References: <20210408130820.48233-1-linmiaohe@huawei.com> <20210408145517.jqodfz6cmm4wwk7g@riteshh-domain> From: Miaohe Lin Message-ID: <48892512-c2f7-9898-0373-a185975b456c@huawei.com> Date: Fri, 9 Apr 2021 16:01:23 +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: <20210408145517.jqodfz6cmm4wwk7g@riteshh-domain> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.179.9] X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: EAE94E00012E X-Stat-Signature: 8k6tkbeimq9diw8mb6oyhxbr6izcw3xp X-Rspamd-Server: rspam02 Received-SPF: none (huawei.com>: No applicable sender policy available) receiver=imf13; identity=mailfrom; envelope-from=""; helo=szxga04-in.huawei.com; client-ip=45.249.212.190 X-HE-DKIM-Result: none/none X-HE-Tag: 1617955290-471691 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/8 22:55, riteshh wrote: > On 21/04/08 09:08AM, Miaohe Lin wrote: >> Hi all, >> When I was investigating the swap code, I found some possible race >> windows. This series aims to fix all these races. But using current >> get/put_swap_device() to guard against concurrent swapoff for >> swap_readpage() looks terrible because swap_readpage() may take really >> long time. And to reduce the performance overhead on the hot-path as >> much as possible, it appears we can use the percpu_ref to close this >> race window(as suggested by Huang, Ying). The patch 1 adds percpu_ref >> support for swap and the rest of the patches use this to close various >> race windows. More details can be found in the respective changelogs. >> Thanks! >> >> Miaohe Lin (5): >> mm/swapfile: add percpu_ref support for swap >> swap: fix do_swap_page() race with swapoff >> mm/swap_state: fix get_shadow_from_swap_cache() race with swapoff >> mm/swap_state: fix potential faulted in race in swap_ra_info() >> mm/swap_state: fix swap_cluster_readahead() race with swapoff > Many thanks for quick respond. > Somehow I see Patch-1 and Patch-2 are missing on linux-mm[1]. I have no idea why Patch-1 and Patch-2 are missing. But they could be found at: https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg2542188.html > Also I wanted to ask if you have a way to trigger this in a more controlled > environment (consistently)? > This is *theoretical* issue. The race window is very small but not impossible. Please see the discussion: https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg2530094.html > [1]: https://patchwork.kernel.org/project/linux-mm/cover/20210408130820.48233-1-linmiaohe@huawei.com/ > Thanks again. > -ritesh > >> >> include/linux/swap.h | 4 +++- >> mm/memory.c | 10 +++++++++ >> mm/swap_state.c | 33 +++++++++++++++++++++-------- >> mm/swapfile.c | 50 +++++++++++++++++++++++++++----------------- >> 4 files changed, 68 insertions(+), 29 deletions(-) >> >> -- >> 2.19.1 >> >> > . >