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 3FC71C43334 for ; Mon, 20 Jun 2022 21:36:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5B2E68E0001; Mon, 20 Jun 2022 17:36:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 561306B0073; Mon, 20 Jun 2022 17:36:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 428E18E0001; Mon, 20 Jun 2022 17:36:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 311206B0071 for ; Mon, 20 Jun 2022 17:36:55 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 056B633F74 for ; Mon, 20 Jun 2022 21:36:54 +0000 (UTC) X-FDA: 79599924390.21.0334201 Received: from alexa-out-sd-01.qualcomm.com (alexa-out-sd-01.qualcomm.com [199.106.114.38]) by imf13.hostedemail.com (Postfix) with ESMTP id 0F252200AF for ; Mon, 20 Jun 2022 21:36:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1655761014; x=1687297014; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=ewUfh4XnkrDqRrJMBTCAGz/x057Ml+6QHcW8sFq1wII=; b=vIzEmRHSyKQM8GRDM4HQGya0W+lSw1C3lRST612CLgAstkKh8tZ796rG gvPAkhw2VCIpSFTIkEW7DNddLltexCsBg5Byc5Pc54FvO/QLkI8JZn8OT tJorLAZAj/IGJWaJK4lnKt2Vbwzw2/Y+z0SFvy5BHr/PaVRYIMYaMuJSZ A=; Received: from unknown (HELO ironmsg05-sd.qualcomm.com) ([10.53.140.145]) by alexa-out-sd-01.qualcomm.com with ESMTP; 20 Jun 2022 14:36:51 -0700 X-QCInternal: smtphost Received: from nasanex01c.na.qualcomm.com ([10.47.97.222]) by ironmsg05-sd.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Jun 2022 14:36:51 -0700 Received: from nalasex01a.na.qualcomm.com (10.47.209.196) by nasanex01c.na.qualcomm.com (10.47.97.222) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.22; Mon, 20 Jun 2022 14:36:51 -0700 Received: from qian (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.22; Mon, 20 Jun 2022 14:36:49 -0700 Date: Mon, 20 Jun 2022 17:36:47 -0400 From: Qian Cai To: Muchun Song CC: Miaohe Lin , "Huang, Ying" , , , , Subject: Re: [PATCH v2 2/3] mm/swapfile: fix possible data races of inuse_pages Message-ID: References: <20220608144031.829-1-linmiaohe@huawei.com> <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> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01a.na.qualcomm.com (10.47.209.196) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1655761014; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=ewUfh4XnkrDqRrJMBTCAGz/x057Ml+6QHcW8sFq1wII=; b=iRK6Br/DVxgClEFdeG+rBLZVXs9eLmh2W6Dw4Fl+SzbK+RIpLoLJUGoirq9VAthv4cmBrP Hi3Tw3S9+oN25+qAnAmzhOeeapKMGqeESqDDUR9ctoWL5LjvTMeL/hj5P2WWeiROsCpftF nJUtEeaixDovk/tBLTV+5SO9SXD5vbo= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655761014; a=rsa-sha256; cv=none; b=pPQZhDWiS9bsv+CgArYHDoppnYPPQfiK+v24EtjKvh4O5SqS+NXFcq/SDiAYjfPaWTZ5o1 WSFIXONSKwvTumkz9kH9Bl4P7Prk5xJJx3FadikaL83h0uYFs+4MCQaBnxLn/vdPQAZTkX 0cYdvDBee3OJSY+iTi/vTHZn60Tl0bs= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=quicinc.com header.s=qcdkim header.b=vIzEmRHS; spf=pass (imf13.hostedemail.com: domain of quic_qiancai@quicinc.com designates 199.106.114.38 as permitted sender) smtp.mailfrom=quic_qiancai@quicinc.com; dmarc=pass (policy=none) header.from=quicinc.com X-Stat-Signature: nm8qpz8yjsmo8bey4cj9dxs3pw1dqiih Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=quicinc.com header.s=qcdkim header.b=vIzEmRHS; spf=pass (imf13.hostedemail.com: domain of quic_qiancai@quicinc.com designates 199.106.114.38 as permitted sender) smtp.mailfrom=quic_qiancai@quicinc.com; dmarc=pass (policy=none) header.from=quicinc.com X-Rspamd-Queue-Id: 0F252200AF X-Rspamd-Server: rspam02 X-Rspam-User: X-HE-Tag: 1655761013-754953 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 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). 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()..."