Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp3528133iog; Mon, 27 Jun 2022 19:01:07 -0700 (PDT) X-Google-Smtp-Source: AGRyM1u9uc22OXHy6eZJzr2FHT4kpa6fC4FWY/WBgm4UX0kFMcfPHoy6nQeeoAAIYPwXPK4QnG+F X-Received: by 2002:a17:90b:3b4e:b0:1ed:2236:34f3 with SMTP id ot14-20020a17090b3b4e00b001ed223634f3mr19946474pjb.6.1656381667592; Mon, 27 Jun 2022 19:01:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656381667; cv=none; d=google.com; s=arc-20160816; b=XN/V29ennYY69i1NTDGcAsNEyv3/m3IJoymxhgXejyYNLwYaVi5/xpwmCxO8e0yK3+ X7HPh7Zkk7f7XpWjZhdimyVqOApxhYNgqJAtLriSMFWnJ4Wi4bRuOm7WUf3e/RSV0NFe gNHnv1vtsO27MEXZDbVgS9MPEqaSXQ1Id26kbSikLF6TfWvNTWMxJRE7FCDn7171IflL R+08vL+QFcXjl7DdTHe9REscU8QuFJP1MV+Ft5ihpbpYehgLU5nfvZwWLIoXiA0r6l6f 2NvzLuSBaMOPVInt1zUmn4+6nEYSvvYvK3fUsdL2NbzCHBdB2FoPbXK/6XA6bWVfm044 V/rw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:message-id:in-reply-to :date:references:subject:cc:to:from:dkim-signature; bh=RRUQArDRdq8cbD+GIUA7N05b3UciN8l8gkjW8r/i47Y=; b=zTZSsd8HTJq5yK3BZrdXGSbxSCGqvpXFcvW2WPV2HNq91ndi+YsMxBWaPwDDtouGbP r16qVjwAQR1+Ej9rNdXgM2wSftJyvVEbvtqHpTFGHQL+XF1yeBuUhi8N58VUeBOQDXya ihXzBMSvri2bI9x8olcCQuNz//a7cALFdA1xoWiR/0OGyXPZlvKmBLR8a2CqHyPjM2yk 1iyy9Hd96Duwtb+clpxxVpd3oSQnZfGJDlUJjT4/DQbP+R5ON6ClY3wfNDuJgZM7lCp9 zgbvS8WsIKKH26+0+0RUdpkAHJyxFroL8aYhHAc5XPX4m54jVBI5rSTcFknck6bV/1Bk CDBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=B1flKjPX; 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=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d7-20020a056a00244700b0051c0fe8e54dsi17499631pfj.374.2022.06.27.19.00.55; Mon, 27 Jun 2022 19:01:07 -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; dkim=pass header.i=@intel.com header.s=Intel header.b=B1flKjPX; 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=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235287AbiF1B5G (ORCPT + 99 others); Mon, 27 Jun 2022 21:57:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41178 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230437AbiF1B5F (ORCPT ); Mon, 27 Jun 2022 21:57:05 -0400 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D8CC1BC94 for ; Mon, 27 Jun 2022 18:57:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1656381424; x=1687917424; h=from:to:cc:subject:references:date:in-reply-to: message-id:mime-version; bh=KhNIX1vdfNA11IMZRMjDJRfMks3in0mWikfrfge0Psw=; b=B1flKjPXe5i/wv6FEB24J5cJCZoooGxsiAx/39yGU2THZA3R3bfe3uBx hN/4hIGaOe4oxwxroOGs8UOfgga71bVbnl81smmoCgZQ1jT1dgX7aBYRP WR9xMeVuXz50GSyhmKs/xRrZMigXyq0tITDrSOtwEDSXpGdxgyzK2tku6 uzhymXXNg+YOdbkPkA8zmXbA8e9HN+PWNTVECoUz7kBgPCZdNIdGPxU/D vPYtMNIriAVHIC2FPzpuRPT4lMED3l9RWyx8Tete7z6fFIwn8Hg4fjpR3 LTW0EeTfdbFleqm6Qva1rC+ybf8zF+VGIRL3Fc+DvjGSPRMJVn55v7aSG w==; X-IronPort-AV: E=McAfee;i="6400,9594,10391"; a="282699785" X-IronPort-AV: E=Sophos;i="5.92,227,1650956400"; d="scan'208";a="282699785" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Jun 2022 18:57:04 -0700 X-IronPort-AV: E=Sophos;i="5.92,227,1650956400"; d="scan'208";a="692881407" Received: from yhuang6-desk2.sh.intel.com (HELO yhuang6-desk2.ccr.corp.intel.com) ([10.239.13.94]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Jun 2022 18:57:02 -0700 From: "Huang, Ying" To: Qian Cai Cc: Miaohe Lin , , , , , Subject: Re: [PATCH v3 1/2] mm/swapfile: fix possible data races of inuse_pages References: <20220625093346.48894-1-linmiaohe@huawei.com> <20220625093346.48894-2-linmiaohe@huawei.com> Date: Tue, 28 Jun 2022 09:56:58 +0800 In-Reply-To: (Qian Cai's message of "Mon, 27 Jun 2022 09:47:16 -0400") Message-ID: <874k057dp1.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 X-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,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 Qian Cai writes: > On Mon, Jun 27, 2022 at 09:27:43PM +0800, Miaohe Lin wrote: >> On 2022/6/27 20:43, Qian Cai wrote: >> > On Sat, Jun 25, 2022 at 05:33:45PM +0800, Miaohe Lin wrote: >> >> si->inuse_pages could still be accessed concurrently now. The plain reads >> >> outside si->lock critical section, i.e. swap_show and si_swapinfo, which >> >> results in data races. READ_ONCE and WRITE_ONCE is used to fix such data >> >> races. Note these data races should be ok because they're just used for >> >> showing swap info. >> > >> > Was this found by kcsan? If so, it would be useful to record the exact >> > kscan report in the commit message. >> >> Sorry, it's found via code inspection. > > Well, if we are going to do a WRITE_ONCE() in those places just for > documentation purpose now, I think we will need to fix all places in the mm > subsystem to be consistent. We have already done this in swapfile.c, please search "WRITE_ONCE" in that file. Best Regards, Huang, Ying