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=-6.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,SPF_HELO_NONE 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 777E2C2B9F4 for ; Thu, 17 Jun 2021 14:07:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5FC36611CA for ; Thu, 17 Jun 2021 14:07:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233037AbhFQOJI (ORCPT ); Thu, 17 Jun 2021 10:09:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:43576 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231229AbhFQOI4 (ORCPT ); Thu, 17 Jun 2021 10:08:56 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C9CDE6128B; Thu, 17 Jun 2021 14:06:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1623938808; bh=USuNS66VwI9Dv2TF97Ch23upshZW3laFb5thOQmiS5I=; h=In-Reply-To:References:Date:From:To:Cc:Subject:From; b=HP9G5Cmithaedw7ZjqQwt9D7EP5IjN4Vkw0JZz5HUNnyo/YIERgzR72vovik6zBPf Loj9Co9AEPFh439dGun3u1skVv1GtH35fNPw6kexaLe4M9+pICx3+hxmcFqV4iol6b wFrfY3bcLCY7CrC5Udwjq8EsNr6PgYDDOFg9S6J/4k1cAkJkPlxxTPRhTa51wzQj+m eEx8lwF62p3ohEiu9aav+Cp+jGQ24Xr3hO09An6RUjowda5Q8RDKFfF7McsTlbgY/b TWy6O2BAAUXW1S5nuW2ZKKYLG+4IZ8uti+w4Uog9Hacs4f+eJ6ZieuDw47w+Kol1Ia lUqk/ZQ/qQz4Q== Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailauth.nyi.internal (Postfix) with ESMTP id D6CE327C005A; Thu, 17 Jun 2021 10:06:46 -0400 (EDT) Received: from imap21 ([10.202.2.71]) by compute2.internal (MEProxy); Thu, 17 Jun 2021 10:06:46 -0400 X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrfeefuddgjeduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvffutgesthdtredtreerjeenucfhrhhomhepfdetnhgu hicunfhuthhomhhirhhskhhifdcuoehluhhtoheskhgvrhhnvghlrdhorhhgqeenucggtf frrghtthgvrhhnpeegjefghfdtledvfeegfeelvedtgfevkeeugfekffdvveeffeetieeh ueetveekfeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhroh hmpegrnhguhidomhgvshhmthhprghuthhhphgvrhhsohhnrghlihhthidqudduiedukeeh ieefvddqvdeifeduieeitdekqdhluhhtoheppehkvghrnhgvlhdrohhrgheslhhinhhugi drlhhuthhordhush X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id E7E1A51C0060; Thu, 17 Jun 2021 10:06:45 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.5.0-alpha0-526-gf020ecf851-fm-20210616.001-gf020ecf8 Mime-Version: 1.0 Message-Id: In-Reply-To: References: <1623816595.myt8wbkcar.astroid@bobo.none> <617cb897-58b1-8266-ecec-ef210832e927@kernel.org> <1623893358.bbty474jyy.astroid@bobo.none> <58b949fb-663e-4675-8592-25933a3e361c@www.fastmail.com> Date: Thu, 17 Jun 2021 07:06:24 -0700 From: "Andy Lutomirski" To: "Peter Zijlstra (Intel)" Cc: "Nicholas Piggin" , "Rik van Riel" , "Andrew Morton" , "Dave Hansen" , "Linux Kernel Mailing List" , linux-mm@kvack.org, "Mathieu Desnoyers" , "the arch/x86 maintainers" , "Paul E. McKenney" Subject: =?UTF-8?Q?Re:_[RFC][PATCH]_sched:_Use_lightweight_hazard_pointers_to_gra?= =?UTF-8?Q?b_lazy_mms?= Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 17, 2021, at 2:13 AM, Peter Zijlstra wrote: > On Thu, Jun 17, 2021 at 11:08:03AM +0200, Peter Zijlstra wrote: > > +static void mmdrop_lazy(struct rq *rq) > > +{ > > + struct mm_struct *old_mm; > > + > > + if (likely(!READ_ONCE(rq->drop_mm))) > > + return; > > + > > + /* > > + * Slow path. This only happens when we recently stopped using > > + * an mm that is exiting. > > + */ > > + old_mm = xchg(&rq->drop_mm, NULL); > > + if (old_mm) > > + mmdrop(old_mm); > > +} > > AFAICT if we observe a !NULL value on the load, the xchg() *MUST* also > see !NULL (although it might see a different !NULL value). So do we want > to write it something like so instead? Like so? > > static void mmdrop_lazy(struct rq *rq) > { > struct mm_struct *old_mm; > > if (likely(!READ_ONCE(rq->drop_mm))) > return; > > /* > * Slow path. This only happens when we recently stopped using > * an mm that is exiting. * This xchg is the only thing that can change rq->drop_mm from non-NULL to NULL, and * multiple mmdrop_lazy() calls can't run concurrently on the same CPU. > */ > old_mm = xchg(&rq->drop_mm, NULL); > if (WARN_ON_ONCE(!old_mm)) > return; > > mmdrop(old_mm); > } > --Andy