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=-12.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham 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 0C201C64E7A for ; Wed, 2 Dec 2020 02:50:03 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 65A0220C56 for ; Wed, 2 Dec 2020 02:50:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 65A0220C56 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 55FAF6B005C; Tue, 1 Dec 2020 21:50:01 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4E30B6B005D; Tue, 1 Dec 2020 21:50:01 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3ABEB8D0001; Tue, 1 Dec 2020 21:50:01 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0053.hostedemail.com [216.40.44.53]) by kanga.kvack.org (Postfix) with ESMTP id 1D8586B005C for ; Tue, 1 Dec 2020 21:50:01 -0500 (EST) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id D899C180AD815 for ; Wed, 2 Dec 2020 02:50:00 +0000 (UTC) X-FDA: 77546812560.01.board47_360a243273af Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin01.hostedemail.com (Postfix) with ESMTP id B64891004D5BB for ; Wed, 2 Dec 2020 02:50:00 +0000 (UTC) X-HE-Tag: board47_360a243273af X-Filterd-Recvd-Size: 5998 Received: from mail-pl1-f195.google.com (mail-pl1-f195.google.com [209.85.214.195]) by imf31.hostedemail.com (Postfix) with ESMTP for ; Wed, 2 Dec 2020 02:50:00 +0000 (UTC) Received: by mail-pl1-f195.google.com with SMTP id b23so280130pls.11 for ; Tue, 01 Dec 2020 18:50:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:subject:to:cc:references:in-reply-to:mime-version :message-id:content-transfer-encoding; bh=kK3Q9wTcGhoxGEIMY0Ll+QkOAdyw6ggQzHJw4qOuYBo=; b=pdL+rHdqu9vZr8iSAMFhpbbe1/kXYhSgOjwbgZIvhE/l3SVZzO1LhnQjnoaLWGVZl4 M8c+NjJu2tub2F6H8k8gWWjXcgbDJp4gKUa4j1+U9N4XPzuCaWDIyztRbcztPyG3ztJx mnbn7XKo0qZCxNPxMHgwUJS8r+TtX0KOSXD/9QAArw2VisEk5mEtscjd6SeBtv9b4Hoi tWCCSUMhpeKm5oCwErlUeXm/kxSr524TEn1wjfLo4B+EYEAh1va4Ji9yppYQNEQsxMEY jCWQmFaKYEiI2A51naOLEBqu4aXSWyKOU2W+ekS9bj9SLU21fHSjE8JrSZY0g8CxoJ5Z PMzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:subject:to:cc:references:in-reply-to :mime-version:message-id:content-transfer-encoding; bh=kK3Q9wTcGhoxGEIMY0Ll+QkOAdyw6ggQzHJw4qOuYBo=; b=ulq63SUNWpt5mkAOjpusbWGZWgRV94S4w/YuNrtmFL2O+9HApbgeSNw2ZUibakf3D9 BVPW6RIEPgKqQxkIpKa7FTtyXiYb0o1HTxJWQJAcq1WSdCmb2YO1yu3L8qJnGhKmXShM al6KrAOKvSCZ8aW/jXSQX2RBmHerA7MovNCF7wEulr1eS/a6OcDIw7rMTszKlrp1msRr FXxVnQrYQCb2DKUTxMjM/+3cwfYgdMWCluSyPuAJFR7K80rS5SSRYgKevohmh+E+xLJw RujH3D+siU7ORn3T6gtjZN5OBi9rVr3VvulNU+e+DIa0UVf+0Fvvbr7ZGwcA4G0Gseqx 6aZw== X-Gm-Message-State: AOAM532a7Yui+f/mCJIg5rsrigyUUug2NFbto6og6u0P45JbgMgVG0+U ucqP2XFC8NXS2rGp+D0vp0M= X-Google-Smtp-Source: ABdhPJyWh9QiGaql1Lp94BlZmVG3HCxLBZGBrbL9Z7xBftB8HeziAbVbGnP4a+X0o3l7pddCcYYVEA== X-Received: by 2002:a17:902:fe05:b029:da:7345:c773 with SMTP id g5-20020a170902fe05b02900da7345c773mr664641plj.20.1606877399319; Tue, 01 Dec 2020 18:49:59 -0800 (PST) Received: from localhost ([1.132.177.56]) by smtp.gmail.com with ESMTPSA id h8sm223576pgg.79.2020.12.01.18.49.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Dec 2020 18:49:58 -0800 (PST) Date: Wed, 02 Dec 2020 12:49:51 +1000 From: Nicholas Piggin Subject: Re: [PATCH 5/8] lazy tlb: allow lazy tlb mm switching to be configurable To: Andy Lutomirski Cc: Anton Blanchard , Arnd Bergmann , linux-arch , LKML , Linux-MM , linuxppc-dev , Mathieu Desnoyers , Peter Zijlstra , X86 ML References: <20201128160141.1003903-1-npiggin@gmail.com> <20201128160141.1003903-6-npiggin@gmail.com> In-Reply-To: MIME-Version: 1.0 Message-Id: <1606876546.8oyicax8hw.astroid@bobo.none> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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: Excerpts from Andy Lutomirski's message of November 29, 2020 10:36 am: > On Sat, Nov 28, 2020 at 8:02 AM Nicholas Piggin wrote= : >> >> NOMMU systems could easily go without this and save a bit of code >> and the refcount atomics, because their mm switch is a no-op. I >> haven't flipped them over because haven't audited all arch code to >> convert over to using the _lazy_tlb refcounting. >> >> Signed-off-by: Nicholas Piggin >> --- >> arch/Kconfig | 11 +++++++ >> include/linux/sched/mm.h | 13 ++++++-- >> kernel/sched/core.c | 68 +++++++++++++++++++++++++++++----------- >> kernel/sched/sched.h | 4 ++- >> 4 files changed, 75 insertions(+), 21 deletions(-) >> >> diff --git a/arch/Kconfig b/arch/Kconfig >> index 56b6ccc0e32d..596bf589d74b 100644 >> --- a/arch/Kconfig >> +++ b/arch/Kconfig >> @@ -430,6 +430,17 @@ config ARCH_WANT_IRQS_OFF_ACTIVATE_MM >> irqs disabled over activate_mm. Architectures that do IPI base= d TLB >> shootdowns should enable this. >> >> +# Should make this depend on MMU, because there is little use for lazy = mm switching >> +# with NOMMU. Must audit NOMMU architecture code for lazy mm refcountin= g first. >> +config MMU_LAZY_TLB >> + def_bool y >> + help >> + Enable "lazy TLB" mmu context switching for kernel threads. >> + >> +config MMU_LAZY_TLB_REFCOUNT >> + def_bool y >> + depends on MMU_LAZY_TLB >> + >=20 > This could use some documentation as to what "no" means. Sure I can add a bit more. >=20 >> config ARCH_HAVE_NMI_SAFE_CMPXCHG >> bool >> >> diff --git a/include/linux/sched/mm.h b/include/linux/sched/mm.h >> index 7157c0f6fef8..bd0f27402d4b 100644 >> --- a/include/linux/sched/mm.h >> +++ b/include/linux/sched/mm.h >> @@ -51,12 +51,21 @@ static inline void mmdrop(struct mm_struct *mm) >> /* Helpers for lazy TLB mm refcounting */ >> static inline void mmgrab_lazy_tlb(struct mm_struct *mm) >> { >> - mmgrab(mm); >> + if (IS_ENABLED(CONFIG_MMU_LAZY_TLB_REFCOUNT)) >> + mmgrab(mm); >> } >> >> static inline void mmdrop_lazy_tlb(struct mm_struct *mm) >> { >> - mmdrop(mm); >> + if (IS_ENABLED(CONFIG_MMU_LAZY_TLB_REFCOUNT)) { >> + mmdrop(mm); >> + } else { >> + /* >> + * mmdrop_lazy_tlb must provide a full memory barrier, s= ee the >> + * membarrier comment finish_task_switch. >=20 > "membarrier comment in finish_task_switch()", perhaps? Sure. Thanks, Nick