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 1B1D6C43334 for ; Mon, 27 Jun 2022 13:47:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 89CFD6B0071; Mon, 27 Jun 2022 09:47:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 825E76B0072; Mon, 27 Jun 2022 09:47:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6A0196B0073; Mon, 27 Jun 2022 09:47:22 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 5BBF06B0071 for ; Mon, 27 Jun 2022 09:47:22 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay12.hostedemail.com (Postfix) with ESMTP id 2BE9A120308 for ; Mon, 27 Jun 2022 13:47:22 +0000 (UTC) X-FDA: 79624142724.16.80CAC63 Received: from alexa-out-sd-01.qualcomm.com (alexa-out-sd-01.qualcomm.com [199.106.114.38]) by imf06.hostedemail.com (Postfix) with ESMTP id 74D30180007 for ; Mon, 27 Jun 2022 13:47:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1656337641; x=1687873641; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=Gnsf+QTLVChURM0F3ZGZR9Oqi9oIQdMjnKYpZYGncic=; b=sj06xmk59a663Mn6SJn5aevR+2QnbRXKW1+RSwr0PtMKF0/gFx4XHo2a +GMkEMao4MwUSp6GzaAmGodjXympfd05Ouo+QywspCFlHLt19dBvoNJcr +ocWkK4QZckMDbZFGoRbNasDdBgHHbmclBi2I/ryiHsuO+7U4A7eoCF1i 8=; Received: from unknown (HELO ironmsg-SD-alpha.qualcomm.com) ([10.53.140.30]) by alexa-out-sd-01.qualcomm.com with ESMTP; 27 Jun 2022 06:47:20 -0700 X-QCInternal: smtphost Received: from nasanex01c.na.qualcomm.com ([10.47.97.222]) by ironmsg-SD-alpha.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Jun 2022 06:47:20 -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, 27 Jun 2022 06:47:19 -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, 27 Jun 2022 06:47:18 -0700 Date: Mon, 27 Jun 2022 09:47:16 -0400 From: Qian Cai To: Miaohe Lin CC: , , , , , Subject: Re: [PATCH v3 1/2] mm/swapfile: fix possible data races of inuse_pages Message-ID: References: <20220625093346.48894-1-linmiaohe@huawei.com> <20220625093346.48894-2-linmiaohe@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: nasanex01a.na.qualcomm.com (10.52.223.231) 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=1656337641; 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=Gnsf+QTLVChURM0F3ZGZR9Oqi9oIQdMjnKYpZYGncic=; b=wS1fzhv8MoqSA6IdJ+l4VeGGz40jVlKKqOPWzD8H26riSMSQHIXfUPZb9MGNPXan9VcLES cj1TX4PvwiNXkoE1KpVJSyBoEQcj69cb9e70/qtAsNdkg66Jsb2h3WHF4Cf1Tt4va58iAX 4GPAQKSse3PNQ1dYryesDf10UUXlLCk= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=quicinc.com header.s=qcdkim header.b=sj06xmk5; dmarc=pass (policy=none) header.from=quicinc.com; spf=pass (imf06.hostedemail.com: domain of quic_qiancai@quicinc.com designates 199.106.114.38 as permitted sender) smtp.mailfrom=quic_qiancai@quicinc.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656337641; a=rsa-sha256; cv=none; b=iUuc5Gd3q52UBitNP4JBB8GLLUfM//Tjoq3KoV+meHkJMN29hoXKQPNIk8Zc+q+hEYUZRg w3l0LGy7+LWWgo+jizrE26Uev7hmV1SUCSWsXUPsfkjLkKySjL0L2f0xhH+IlszUHo+/mk OuRLHaIuH5dhd0hCBALCcisxHHspHYI= X-Rspamd-Queue-Id: 74D30180007 Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=quicinc.com header.s=qcdkim header.b=sj06xmk5; dmarc=pass (policy=none) header.from=quicinc.com; spf=pass (imf06.hostedemail.com: domain of quic_qiancai@quicinc.com designates 199.106.114.38 as permitted sender) smtp.mailfrom=quic_qiancai@quicinc.com X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: 1wp6n3te95nugnfkse3b1foxc9w7z4oa X-HE-Tag: 1656337641-899298 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 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.