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 X-Spam-Level: X-Spam-Status: No, score=-3.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A2DE4C4338F for ; Wed, 18 Aug 2021 15:08:15 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D87736104F for ; Wed, 18 Aug 2021 15:08:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org D87736104F Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id E926F6B006C; Wed, 18 Aug 2021 11:08:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E42996B0072; Wed, 18 Aug 2021 11:08:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D31646B0073; Wed, 18 Aug 2021 11:08:13 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0139.hostedemail.com [216.40.44.139]) by kanga.kvack.org (Postfix) with ESMTP id B74076B006C for ; Wed, 18 Aug 2021 11:08:13 -0400 (EDT) Received: from smtpin12.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 3BE75235C4 for ; Wed, 18 Aug 2021 15:08:13 +0000 (UTC) X-FDA: 78488532066.12.89AD65A Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf25.hostedemail.com (Postfix) with ESMTP id 4293AB008892 for ; Wed, 18 Aug 2021 15:08:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=a3+aWwZ8A2mBrlkKyurg8rkEDu4ERvvcEAkDI68YCTY=; b=ilXjIsZjeoTJmRb5cFbzJQzGEk BCxWY+LTPYRz6hRYdtZApF7gNBWJ2D0f3edub72EOEvUw2iAPyQbQl32m00/LDNYpfikIt/+5RQql kpgXT1HBmadVdkCpb8xbNempBVtMbKtv/Z+Lfy0LtiXwxBT+gf7smajPAj+U7y0xy9tKFTBQqCwPy xb36a0cHRt4/1ccucnatUepY/kqM1Enove9Vu/TOqi/MbptsRjo3XG/rX9XOt5oZhytUkVl4RvZEX +5KWwYIeVkWGr/ZO+PnE1qHHnTgb8UF6ZwCdLkBaCSLGJQHZOkiv7vS4Y8tXOm4aDSNwPvGx+rJZp M10y2D3w==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mGN9r-003xpe-Ii; Wed, 18 Aug 2021 15:07:17 +0000 Date: Wed, 18 Aug 2021 16:07:11 +0100 From: Matthew Wilcox To: Muchun Song Cc: Andrew Morton , yanghui , Linux Memory Management List , LKML Subject: Re: [PATCH v3] mm/mempolicy: fix a race between offset_il_node and mpol_rebind_task Message-ID: References: <20210815061034.84309-1-yanghui.def@bytedance.com> <20210816175952.3c0d1eee821cd2d9ed7c3879@linux-foundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=ilXjIsZj; dmarc=none; spf=none (imf25.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org X-Stat-Signature: qi9jhwdzysbwu4hfmzyedtussi9n7akb X-Rspamd-Queue-Id: 4293AB008892 X-Rspamd-Server: rspam05 X-HE-Tag: 1629299292-735555 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 Wed, Aug 18, 2021 at 10:02:46PM +0800, Muchun Song wrote: > On Tue, Aug 17, 2021 at 9:43 AM Matthew Wilcox wrote: > > > > + unsigned int target, nnodes; > > > > int i; > > > > int nid; > > > > + /* > > > > + * The barrier will stabilize the nodemask in a register or on > > > > + * the stack so that it will stop changing under the code. > > > > + * > > > > + * Between first_node() and next_node(), pol->nodes could be changed > > > > + * by other threads. So we put pol->nodes in a local stack. > > > > + */ > > > > + barrier(); > > > > I think this could be an smp_rmb()? > > Hi Matthew, > > I have a question. Why is barrier() not enough? I think barrier() may be more than is necessary. We don't need a barrier on non-SMP systems (or do we?) And we only need to order reads, not writes.