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 6F623C49EA6 for ; Thu, 17 Jun 2021 14:06:51 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 15E1E611CA for ; Thu, 17 Jun 2021 14:06:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 15E1E611CA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id A81126B0073; Thu, 17 Jun 2021 10:06:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A57C86B0074; Thu, 17 Jun 2021 10:06:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8F90E6B0075; Thu, 17 Jun 2021 10:06:50 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0223.hostedemail.com [216.40.44.223]) by kanga.kvack.org (Postfix) with ESMTP id 5DDC96B0073 for ; Thu, 17 Jun 2021 10:06:50 -0400 (EDT) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id EDC6E82FAD78 for ; Thu, 17 Jun 2021 14:06:49 +0000 (UTC) X-FDA: 78263391738.06.1DF7A36 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf09.hostedemail.com (Postfix) with ESMTP id 2C7C1600014F for ; Thu, 17 Jun 2021 14:06:43 +0000 (UTC) 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 X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 2C7C1600014F Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=HP9G5Cmi; spf=pass (imf09.hostedemail.com: domain of luto@kernel.org designates 198.145.29.99 as permitted sender) smtp.mailfrom=luto@kernel.org; dmarc=pass (policy=none) header.from=kernel.org X-Stat-Signature: y5kpqpssftteqoj5fh3xgaerd9qsmz8p X-HE-Tag: 1623938803-578400 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 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