Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp5579156iob; Mon, 9 May 2022 21:22:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxkiVFPhti8LxiRtWGawYPg3LWCd4Pdg1VGt2MU5srXS04ebVvz0u+Jcx+/4hGfWgVI4KM3 X-Received: by 2002:a17:903:120a:b0:15f:99f:95bc with SMTP id l10-20020a170903120a00b0015f099f95bcmr9808746plh.48.1652156528131; Mon, 09 May 2022 21:22:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652156528; cv=none; d=google.com; s=arc-20160816; b=sbHmd9xzbxT4D2VAIgtYplJwyFML2M4BUgAkcA78M/ytIB73UfhBkonvJ6U6KELA+U zw/ba40WWWTAV252BE9qcvvCIdc7no9msAv/Ar2IbNYojRo7A1HwwKGqMb8ipNKxVRQi uMHDPcOXZ4fSpCa+Fbel3/E5DybZjCnIa+XE0MiHpyg2x7GbEX2LcJsweuc89anF0YVA iBMt37ynC7SZuvfjWWzInsdmsm0au0CWmrCc1pusE+lWWX8w673OXcAxizzYisnlgRrD 1U3NTtSHs4sMUgXErYyY4ofxzjuv57mzogz8Uz0jBSB7y4gXalQWe+pADEdeASr9pn/u 4YTw== 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=yfKJUMedOLnAqyZLwnNFm4u1gNDS7DfE24jK2NKbAEY=; b=g55r5xvlFtAypPxntblZEgj820eteuHzju2d/V+/fio+O1rcs6mrQiaIDHTwJdqjyn EUrUGQEwBCD1DhtaTuO6SE+w2Jw+TEp2TGGsqQzaU5wRqGxe71dX/QZ+0+99MGUjHWK8 S8FT9WcnpzGPH+0sMyxxwDsDTL01WXaxtnN+YIMdl/x9/rEmO+W0GfbKmOuVpY+FkZKT 5hXn9nHZmMKvW3+WNNfVj3XGIsDtVOKAellg2EkPs+VwLKW+M8iNU9IXW5rQ2xqCpwLa QZzaM3Xb3S61ilrfVWyY6OybyJcuESYxT7NGspP1UOpNAeD53f3bTY09IULsPTcTAAwK Mj0w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b4-20020a170902d50400b00153b2d165d4si2022528plg.476.2022.05.09.21.21.53; Mon, 09 May 2022 21:22:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234540AbiEJCZX (ORCPT + 99 others); Mon, 9 May 2022 22:25:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39546 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231676AbiEJCZU (ORCPT ); Mon, 9 May 2022 22:25:20 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D94BC590BB for ; Mon, 9 May 2022 19:21:24 -0700 (PDT) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4Ky1x33jL3zhYym; Tue, 10 May 2022 10:20:55 +0800 (CST) Received: from [10.174.177.76] (10.174.177.76) by canpemm500002.china.huawei.com (7.192.104.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Tue, 10 May 2022 10:21:21 +0800 Subject: Re: [PATCH 09/15] mm/swap: avoid calling swp_swap_info when try to check SWP_STABLE_WRITES To: NeilBrown CC: , , , , , , , , , , References: <20220509131416.17553-1-linmiaohe@huawei.com> <20220509131416.17553-10-linmiaohe@huawei.com> <165214248406.14782.6536817483979050668@noble.neil.brown.name> From: Miaohe Lin Message-ID: Date: Tue, 10 May 2022 10:21:21 +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: <165214248406.14782.6536817483979050668@noble.neil.brown.name> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.177.76] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-5.3 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2022/5/10 8:28, NeilBrown wrote: > On Mon, 09 May 2022, Miaohe Lin wrote: >> Use flags of si directly to check SWP_STABLE_WRITES to avoid possible >> READ_ONCE and thus save some cpu cycles. >> >> Signed-off-by: Miaohe Lin >> --- >> mm/memory.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/mm/memory.c b/mm/memory.c >> index 9c3e7e6ac202..89dd15504f3d 100644 >> --- a/mm/memory.c >> +++ b/mm/memory.c >> @@ -3892,7 +3892,7 @@ vm_fault_t do_swap_page(struct vm_fault *vmf) >> */ >> exclusive = true; >> } else if (exclusive && PageWriteback(page) && >> - (swp_swap_info(entry)->flags & SWP_STABLE_WRITES)) { >> + (si->flags & SWP_STABLE_WRITES)) { > > Should this have a data_race() annotation. Other bit-tests of si->flags > do because scan_swap_map_slots can update it asynchronously, but we know > that won't matter in practice. Yes, you're right. scan_swap_map_slots can update si->flags asynchronously while do_swap_page tests SWP_STABLE_WRITES here. We know this is harmless because SWP_STABLE_WRITES is only changed at swapon/swapoff. Will add data_race() annotation in next version to avoid possible KCSAN data-race complaint. Many thanks for pointing this out! :) > > Thanks, > NeilBrown > > >> /* >> * This is tricky: not all swap backends support >> * concurrent page modifications while under writeback. >> -- >> 2.23.0 >> >> > . >