Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp3255280iog; Mon, 20 Jun 2022 15:21:28 -0700 (PDT) X-Google-Smtp-Source: AGRyM1t9HJyGfCAy4DoWlqhb3doYJPvKcH2+tPBFRBSsw3AVLlV9drg5Jm+MRkShtIVW26D+dOLY X-Received: by 2002:a05:6402:4026:b0:435:87ec:467 with SMTP id d38-20020a056402402600b0043587ec0467mr6326288eda.303.1655763688164; Mon, 20 Jun 2022 15:21:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655763688; cv=none; d=google.com; s=arc-20160816; b=eN9XlbROhJFFqISwV0yIwSDmYa9aF/z82zCmqJexWCVdtGgIvpz3YI3WHmt3qxLrlx 60CuEgH5CH70Dc1kWCR15108OAlZH96NKWoSqjHhQfM0y4Iv22CMURgGRbtp0T8DZNlJ ZHQhZsOGgjHBHTdyI3UmE84IV429jcbv72ZJ85Kh8wcWgPb4TcLDL0Gz7fx4zcCqc6dD XKsSNtP5YLmtGWAZC3yhfQUjvQrfGRztR2oxDwTXhrjGG4lSz9MxYX0Lo98tAn6+HY/p V1LC7Icf+AtOBjwqd4DRQP9AMjIt19NmC2NZ8sQYh2o9JbcHB/D9fKqA4Qy2/zO6v7el 2spA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=ewUfh4XnkrDqRrJMBTCAGz/x057Ml+6QHcW8sFq1wII=; b=ku+zV3+Tn2ME4jIrdOZzAjLfq9AgzuufhlIG93AWKalWmvkV6/qCUD57XJBwe0VPdU CU3MGFwrpIWvxoSpiMvOFS5femon2B+New4q+8XQFELWptza/P2oUDBTHyWdtNEYoBX9 xPyxje6d2lH+HmVKr4r0UREE8UxmJvOjy/Whd0OM7Tg8sUGOAY5VHCkrJ1X6m2L3axGU RjGQHG0M0aqGxVyaGr1h9KN615MpMgQxajmgJJCydz5aMERy2AK+9yZcFjVw0+KnqZ2l ufg/CMwIsNcJzpI0Fd+I/bP/3DRGFa+eL1Yhgq9TNN464iHVk9w38VK9yBCFhLBQRGWS rk/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=aQ+WWpY1; 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=quicinc.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j18-20020a056402239200b0043583f0f23bsi3538573eda.495.2022.06.20.15.21.03; Mon, 20 Jun 2022 15:21:28 -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=@quicinc.com header.s=qcdkim header.b=aQ+WWpY1; 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=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237431AbiFTVgy (ORCPT + 99 others); Mon, 20 Jun 2022 17:36:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229608AbiFTVgx (ORCPT ); Mon, 20 Jun 2022 17:36:53 -0400 Received: from alexa-out-sd-02.qualcomm.com (alexa-out-sd-02.qualcomm.com [199.106.114.39]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 611A714D39 for ; Mon, 20 Jun 2022 14:36:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1655761012; x=1687297012; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=ewUfh4XnkrDqRrJMBTCAGz/x057Ml+6QHcW8sFq1wII=; b=aQ+WWpY1Jns68K4HF6Z8Y/6/yejGrFSde1UZR//75PNtRPGMIKSAnn4E zP2PJ7zYPGOQWTVvEY7U8DK+U55lDlNpdsdn8J1SGDOMLSnmIQ0OSzWYX yBm+OYv1iuAKFtJocqifc1Sq2N95xWbh7+aSB4DVnUq7oIAKTUHBAKuxk 4=; Received: from unknown (HELO ironmsg05-sd.qualcomm.com) ([10.53.140.145]) by alexa-out-sd-02.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) X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,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 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()..."