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 14331CCA47E for ; Tue, 21 Jun 2022 03:40:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 80DA76B0072; Mon, 20 Jun 2022 23:40:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7BD466B0073; Mon, 20 Jun 2022 23:40:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 685598E0001; Mon, 20 Jun 2022 23:40:05 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 5A1B06B0072 for ; Mon, 20 Jun 2022 23:40:05 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 314002104A for ; Tue, 21 Jun 2022 03:40:05 +0000 (UTC) X-FDA: 79600839570.24.E28F452 Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) by imf15.hostedemail.com (Postfix) with ESMTP id 5621FA0097 for ; Tue, 21 Jun 2022 03:40:04 +0000 (UTC) Received: by mail-pl1-f170.google.com with SMTP id g8so11389978plt.8 for ; Mon, 20 Jun 2022 20:40:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=ncah84k9sMBGcB2WtPshMSQrdUVaR1RC5zTYDDCem3g=; b=rQaaBwyB65GRSW2+iq8RFmdRU/e01guMpTALlKzM/1EbKwfZeRLAJ4TW0Ft4mP0dyB R3r4j3HyIKOxVn7p+CR0+ffda1H6y7CMhmv+O3Msglrg4ZS3Dn+oyi1iyKoQzX1d0Wsq BXBBMRn/WgdnMu6RDIzRF+Vc4tCBij7fmB32Zil9ZlpTWjQLgOG+nFkmTjHUxwWlcU9E 7wM3t3MYjytRaKy5oMW/wnt+Mz2v2c1P9t/JjLj4c319rGzJTM8p6S53Bgs3cbdrYU2g EFnfoIDfwFq01eyN5egGDgi4VX7JbY/ir2wHlELPyzuu2UkHlg0tV987zVil7fYy4BnA yQ4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=ncah84k9sMBGcB2WtPshMSQrdUVaR1RC5zTYDDCem3g=; b=VPHIwIztkuxFK40Wevj6/byFjXwnZ/5gxKvR2KwgREZWVN2qgCP0dd19ABuVCQpeP9 ztzqJdvA2SCsROoWosivNl5LzPFCO1GImfR72fQnIINpqzz7F1b8JPDxdzjlz94Qi0TP FB1KR4vERvoPaw84CucP6AHHr5oTt9c39Crej7ICH9dJ+CLp870f1WmURQLZheAhRCGZ b0xSKDiyiKwUvNPsSTdC9tE3fwx4AqWS0fvxycNLUcBtxF1jSUkbuh8t539kj5sxjB1c Gmb+oYbNTdElm9ZklEN6X9ncZLNklGb/sjvSsd8nCZo/Jyz3hWwLXu7ijI7aiwjZGbB5 EiQw== X-Gm-Message-State: AJIora+/EsuxY+TCdWcKgO/U4T0uwfnPT80jKQYOx5LYRaG3S3kVrHtA VXudwJ0UFswh0/vy3r75QEEj5Q== X-Google-Smtp-Source: AGRyM1t+IOdRjsWZf2HOKGEv5IzGSX4elwgQ5HoXltg8QSzLXPulnrj/f9UlYLqB8ef43dX40Ne92Q== X-Received: by 2002:a17:90b:682:b0:1e3:142:a562 with SMTP id m2-20020a17090b068200b001e30142a562mr40505915pjz.91.1655782803008; Mon, 20 Jun 2022 20:40:03 -0700 (PDT) Received: from localhost ([139.177.225.255]) by smtp.gmail.com with ESMTPSA id i64-20020a628743000000b0051b930b7bbesm9985607pfe.135.2022.06.20.20.40.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jun 2022 20:40:02 -0700 (PDT) Date: Tue, 21 Jun 2022 11:39:59 +0800 From: Muchun Song To: "Huang, Ying" , Qian Cai Cc: Miaohe Lin , akpm@linux-foundation.org, david@redhat.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 2/3] mm/swapfile: fix possible data races of inuse_pages Message-ID: 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87pmj2q0mf.fsf@yhuang6-desk2.ccr.corp.intel.com> ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655782804; a=rsa-sha256; cv=none; b=bd5JwyKnO/f0ARta0E7zbLvY/OyCtaooxsjclJJzCgLpzSQp0zfxd99PkeItmDjW0X22p9 /6tnD1LQI3rMY6AZDUUmqqenYOGUj7CuO4BCIw4FG8dDdv4KDSLOlrGStmeq/Ay6JIbzCe 2sdNeiMUDDivD+HZf1eM+yvVfuV9D08= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1655782804; 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=ncah84k9sMBGcB2WtPshMSQrdUVaR1RC5zTYDDCem3g=; b=HToaIjzE5tIy8lmv4tFOScugr5c3xsiu8nlM0XEgF0SqJHGK6/VwkCz0Qqq9vP6Ab4T/Uw KACVD5RjF9XKY9rvLvweN4kR8HBYjYO3hVDjZqUmAssFIoCzozS9PpBGhGEC9S6BandzW9 0hsfAEkMZ1DBsxLmlwWAzKGJsjCsZDc= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=rQaaBwyB; dmarc=pass (policy=none) header.from=bytedance.com; spf=pass (imf15.hostedemail.com: domain of songmuchun@bytedance.com designates 209.85.214.170 as permitted sender) smtp.mailfrom=songmuchun@bytedance.com Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=rQaaBwyB; dmarc=pass (policy=none) header.from=bytedance.com; spf=pass (imf15.hostedemail.com: domain of songmuchun@bytedance.com designates 209.85.214.170 as permitted sender) smtp.mailfrom=songmuchun@bytedance.com X-Rspam-User: X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 5621FA0097 X-Stat-Signature: p565a7aczgmzxfkehkh51h5x48xzr3iw X-HE-Tag: 1655782804-548389 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 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 > Best Regards, > Huang, Ying >