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 29A9CC43334 for ; Tue, 21 Jun 2022 01:14:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9AE2F6B0072; Mon, 20 Jun 2022 21:14:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 95C4A6B0073; Mon, 20 Jun 2022 21:14:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7FDAD6B0074; Mon, 20 Jun 2022 21:14:30 -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 6D5696B0072 for ; Mon, 20 Jun 2022 21:14:30 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 2A52421032 for ; Tue, 21 Jun 2022 01:14:30 +0000 (UTC) X-FDA: 79600472700.19.9B3534F Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by imf07.hostedemail.com (Postfix) with ESMTP id 6803140099 for ; Tue, 21 Jun 2022 01:14:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1655774069; x=1687310069; h=from:to:cc:subject:references:date:in-reply-to: message-id:mime-version; bh=b00p+JPCNLBqBtIBRmsVShSdYPWHF1lrMDDwHIhXKXY=; b=ARGmm2iPw7UJJoG4MxIeJ8KlyCYOEBtRNIXLKCifn38U4lZFY5OHkhFJ B/JupgeUwX2YGfV7BMI++Gkpvwnz0pS17v3OrWzq3Ejt6cgbw0WVks+iD BjkYrOkkJBwwBspOHPepTXdada2JjTwqDjCpD2Hma9/sud9HkqiOPNDEk k7aGp+yxC5ZaYJDoPImbW78EJ0W80MLcgS9wDqwPaDFjgThE21FeJhnCK Uvun26fveYCHj/cfe2/IKcI4D/kcLhKsdP5URkvVUble97ku5mwUQR4IZ sJitvUXd+x7qdxzfa47IsK5XmFZ+JdT26svIfBYh2vw4t4cRtHXsxa/xB g==; X-IronPort-AV: E=McAfee;i="6400,9594,10384"; a="366322947" X-IronPort-AV: E=Sophos;i="5.92,207,1650956400"; d="scan'208";a="366322947" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Jun 2022 18:14:28 -0700 X-IronPort-AV: E=Sophos;i="5.92,207,1650956400"; d="scan'208";a="833333958" Received: from yhuang6-desk2.sh.intel.com (HELO yhuang6-desk2.ccr.corp.intel.com) ([10.239.13.94]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Jun 2022 18:14:26 -0700 From: "Huang, Ying" To: Qian Cai , Miaohe Lin Cc: Muchun Song , , , , Subject: Re: [PATCH v2 2/3] mm/swapfile: fix possible data races of inuse_pages 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> Date: Tue, 21 Jun 2022 09:14:00 +0800 In-Reply-To: (Qian Cai's message of "Mon, 20 Jun 2022 17:36:47 -0400") Message-ID: <87pmj2q0mf.fsf@yhuang6-desk2.ccr.corp.intel.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=ascii ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655774069; a=rsa-sha256; cv=none; b=p7AutUy4lVnkuaorhXJgWWEpRvuqEMbIRvqUBVkLwZSkFTlhVnboiosPxw1FfpevI1esHg srp06zQPGRb/AIc5/mSnNlPRjAgPpcW+bGVSw3Ha8zyPXP8u27lgENWUc1Ftp0Vwq75ksk 8pOUTDw3k8N0xtqa7X2vkE+PzOqx/TM= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=ARGmm2iP; spf=none (imf07.hostedemail.com: domain of ying.huang@intel.com has no SPF policy when checking 192.55.52.43) smtp.mailfrom=ying.huang@intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1655774069; 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=HVxF7nN+U1ZSRIaDYa1f8lSYvwGnKolVH6cMzgiBph8=; b=q0wupfNfGabb2N7HGV1EKprYU7rcBtRCc9Dv++/EtZ/4I8FDOEGbOq4nWDSfJQ6evhnsMU yM1M10iV8xRXfF76MTBau3IK1s73GdJu7/Rm8DorRVXw6cKT6cDu7U7bRRuOaJ3n8yF5K2 RetVd+nsGQIy8TrdG8oSQidICT0kqiE= X-Stat-Signature: ownbd8cy68ocgwp8ujyhtwc9acpxxpti X-Rspamd-Queue-Id: 6803140099 Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=ARGmm2iP; spf=none (imf07.hostedemail.com: domain of ying.huang@intel.com has no SPF policy when checking 192.55.52.43) smtp.mailfrom=ying.huang@intel.com; dmarc=pass (policy=none) header.from=intel.com X-Rspamd-Server: rspam07 X-Rspam-User: X-HE-Tag: 1655774069-777683 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: 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). > 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. Best Regards, Huang, Ying