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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 93F98C43334 for ; Tue, 21 Jun 2022 06:40:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DF8D46B0072; Tue, 21 Jun 2022 02:40:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DA7616B0073; Tue, 21 Jun 2022 02:40:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C497B6B0074; Tue, 21 Jun 2022 02:40:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id AFCCD6B0072 for ; Tue, 21 Jun 2022 02:40:55 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 808C361140 for ; Tue, 21 Jun 2022 06:40:55 +0000 (UTC) X-FDA: 79601295270.23.51F4F35 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf23.hostedemail.com (Postfix) with ESMTP id D693314001A for ; Tue, 21 Jun 2022 06:40:54 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.54]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4LRxg935fCz1KC8b; Tue, 21 Jun 2022 14:38:45 +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, 21 Jun 2022 14:40:50 +0800 Subject: Re: [PATCH v2 2/3] mm/swapfile: fix possible data races of inuse_pages To: Muchun Song , "Huang, Ying" , Qian Cai CC: , , , References: <20220608144031.829-3-linmiaohe@huawei.com> <87edzjrcq8.fsf@yhuang6-desk2.ccr.corp.intel.com> <13414d6a-9e72-fb6c-f0a8-8b83ba0455de@huawei.com> <09ffac27-7fe9-0977-cb33-30433e78e662@huawei.com> <87pmj2q0mf.fsf@yhuang6-desk2.ccr.corp.intel.com> From: Miaohe Lin Message-ID: Date: Tue, 21 Jun 2022 14:40:49 +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: Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.177.76] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655793655; a=rsa-sha256; cv=none; b=l6uW23jGJoZRsKhuQxepuDW0zJboLPQt1KuQxHcKIMk9Ax6WweamnQJ0ZJHb2mlKUL/ycl ZfzX9NjYiOll/ZTZSlHSuYBSwfLQtNQ1U4tzWJcni1qfRX9BhXjjfVuKloWOVP+bAhxx17 fY3/u3Qz9saaUAl/fq0igdkzi+U0acI= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf23.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1655793655; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xcLJ0CKEmy75PISHwh9PfRRL/tFxLDvqWuUCn83OkOg=; b=RLDDxRTdGMoIdX870vEei8bstDe/hXGqodt2tHhiHpQ7/3G9jpetDN/rXeq31cAaSs2wa7 mC8zm1SZlWeq0nyuuVce9qEuYEhjNsTz0Clxzav+U/6QGX6L4adZ9ERwrkqJ9Illlqc7P4 ZKVLMdUUgQBGZG+hilg5MDlGsVaPyH4= Authentication-Results: imf23.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf23.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com X-Stat-Signature: 8xt6mcxfyefj9mztri448s76wa9esjh6 X-Rspamd-Queue-Id: D693314001A X-Rspam-User: X-Rspamd-Server: rspam03 X-HE-Tag: 1655793654-773538 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 2022/6/21 11:39, Muchun Song wrote: > On Tue, Jun 21, 2022 at 09:14:00AM +0800, Huang, Ying wrote: >> Qian Cai writes: >> >>> On Mon, Jun 20, 2022 at 10:20:07PM +0800, Muchun Song wrote: >>>> The lock does not protect the read sides. So the write side should be >>>> fixed by WRITTE_ONCE(). >>> >>> https://lwn.net/Articles/816854/ >>> >>> "Unmarked writes (aligned and up to word size) can be treated as if they had >>> used WRITE_ONCE() by building with >>> CONFIG_KCSAN_ASSUME_PLAIN_WRITES_ATOMIC=y (also selected by default). > > All right, CONFIG_KCSAN_ASSUME_PLAIN_WRITES_ATOMIC help us avoid KCSAN > complaining. > >>> Experience has shown that compilers are much less likely to destructively >>> optimize in-kernel writes than reads. Some developers might therefore >>> choose to use READ_ONCE() but omit the corresponding WRITE_ONCE(). Other >>> developers might prefer the documentation benefits and long-term peace of >>> mind accruing from explicit use of WRITE_ONCE()..." >> >> Thanks for pointing me to this great article. So although not required >> by KCSAN strictly, WRITE_ONCE() is still good for documentation, etc. >> Just like we have done for swap_info_struct->highest_bit, etc. >> > > +1 I tend to agree with Muchun & Huang, Ying. Thanks all of you. > >> Best Regards, >> Huang, Ying >> > . >