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.8 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=unavailable 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 A5557C47082 for ; Tue, 8 Jun 2021 03:15:40 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1D9BA61351 for ; Tue, 8 Jun 2021 03:15:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1D9BA61351 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 94B3B6B006C; Mon, 7 Jun 2021 23:15:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8FB606B006E; Mon, 7 Jun 2021 23:15:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7745E6B0070; Mon, 7 Jun 2021 23:15:39 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0007.hostedemail.com [216.40.44.7]) by kanga.kvack.org (Postfix) with ESMTP id 41FD96B006C for ; Mon, 7 Jun 2021 23:15:39 -0400 (EDT) Received: from smtpin16.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id D65F1180AD802 for ; Tue, 8 Jun 2021 03:15:38 +0000 (UTC) X-FDA: 78229091556.16.2881CBD Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) by imf19.hostedemail.com (Postfix) with ESMTP id 6B3209001E40 for ; Tue, 8 Jun 2021 03:15:35 +0000 (UTC) Received: by mail-pl1-f176.google.com with SMTP id h1so2201725plt.1 for ; Mon, 07 Jun 2021 20:15:38 -0700 (PDT) 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=7QJgmeOZHxm1wlCHFZhavmAZLKz2FF5Hv428G3b4qiw=; b=VTIEVOTLyXhOQe/MeRuSpN2ald0aymOH2UckQUkbGDMCnIWpLofhC3CcsWGO6G81jD rWunxyEAy2ZhgLcYR00X4AbEZk1j5BC/8NcRbdVVuKOD8+KnUn4/TCpILr7C32XqRToY sin0OyeSbpzbkoBpqneBi8GdLH2Z7/N18b3kF0Ps+Lk4MDwRPpFjSfRySdvw6C4c1DfX Van3r+hqrc3s2QAHIpTEOn5FTzL+QTW3T7TGMuWjY6i4MKtL9dFITUqB5EOQSBq4DvSD 6h+x27wIC4NFr5GL5Id6MGuwBKIi02sjXx+buHb6JeURZXK6LtzNm0Ul+ax1Ar08t1bR Sqmg== 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=7QJgmeOZHxm1wlCHFZhavmAZLKz2FF5Hv428G3b4qiw=; b=PXnRr7RYUxzMs/EcFk2Nm6J0P2KqOEg5xITcq9gePQD+6m+Gbw03TvaaMocaKLLLQD FMyueaEm3iIyuLW9CXOUvTfgkqbROPgWGfKp7T6gNffzg7Jc422zAp4BfccWW1HjvLBM UL4bHI/PKOJ4PtZPuPZdbdCZflmNEgV6MsQP+i4x9jI9Smvgm8CcGCrSQQQ04/JzvfuE 12frneQsdauyQfjKMp6H+gmXukORlrHIL7KSKEREoW9BM8uqL3S6X5u2C+oPn4n1H7As c4okgzkRErjTVXar2zzn85qv91BoLqvFz/Bjy17FUw6qi/bPzp3xBh4dSlJWhfWK2axL Ggtw== X-Gm-Message-State: AOAM530+uVs6lK8PAv5q10vP9zF8lAhF7XZRedyRPd1ge4rozhU/hUza bNMHyJHT+rjDuz6F0buvb14= X-Google-Smtp-Source: ABdhPJyEpZ9jHgeUSsOnRiilTupzYo+aah3Y5D06OH682oRgr8S6Jdcc4g/fCCW+4iV8GPHoxi4iMw== X-Received: by 2002:a17:90b:46c3:: with SMTP id jx3mr16570209pjb.206.1623122137531; Mon, 07 Jun 2021 20:15:37 -0700 (PDT) Received: from localhost (60-242-147-73.tpgi.com.au. [60.242.147.73]) by smtp.gmail.com with ESMTPSA id z17sm9264539pfq.218.2021.06.07.20.15.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Jun 2021 20:15:37 -0700 (PDT) Date: Tue, 08 Jun 2021 13:15:32 +1000 From: Nicholas Piggin Subject: Re: [PATCH v4 3/4] lazy tlb: shoot lazies, a non-refcounting lazy tlb option To: Andrew Morton Cc: Anton Blanchard , linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, Andy Lutomirski , Randy Dunlap References: <20210605014216.446867-1-npiggin@gmail.com> <20210605014216.446867-4-npiggin@gmail.com> In-Reply-To: <20210605014216.446867-4-npiggin@gmail.com> MIME-Version: 1.0 Message-Id: <1623121901.mszkmmum0n.astroid@bobo.none> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=VTIEVOTL; spf=pass (imf19.hostedemail.com: domain of npiggin@gmail.com designates 209.85.214.176 as permitted sender) smtp.mailfrom=npiggin@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 6B3209001E40 X-Stat-Signature: jw4zgugy57tas9x5gq1pkw76d1q6tmon X-HE-Tag: 1623122135-360665 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 Nicholas Piggin's message of June 5, 2021 11:42 am: > On big systems, the mm refcount can become highly contented when doing > a lot of context switching with threaded applications (particularly > switching between the idle thread and an application thread). >=20 > Abandoning lazy tlb slows switching down quite a bit in the important > user->idle->user cases, so instead implement a non-refcounted scheme > that causes __mmdrop() to IPI all CPUs in the mm_cpumask and shoot down > any remaining lazy ones. >=20 > Shootdown IPIs are some concern, but they have not been observed to be > a big problem with this scheme (the powerpc implementation generated > 314 additional interrupts on a 144 CPU system during a kernel compile). > There are a number of strategies that could be employed to reduce IPIs > if they turn out to be a problem for some workload. >=20 > Signed-off-by: Nicholas Piggin > --- Update the comment to be clearer, and account for the improvement to MMU_LAZY_TLB_REFCOUNT comment. Signed-off-by: Nicholas Piggin --- arch/Kconfig | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/arch/Kconfig b/arch/Kconfig index 2ad1a505ca55..cf468c9777d8 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -433,15 +433,16 @@ config MMU_LAZY_TLB_REFCOUNT def_bool y depends on !MMU_LAZY_TLB_SHOOTDOWN =20 -# Instead of refcounting the lazy mm struct for kernel thread references -# (which can cause contention with multi-threaded apps on large multiproce= ssor -# systems), this option causes __mmdrop to IPI all CPUs in the mm_cpumask = and -# switch to init_mm if they were using the to-be-freed mm as the lazy tlb.= To -# implement this, architectures must use _lazy_tlb variants of mm refcount= ing -# when releasing kernel thread mm references, and mm_cpumask must include = at -# least all possible CPUs in which the mm might be lazy, at the time of th= e -# final mmdrop. mmgrab/mmdrop in arch/ code must be switched to _lazy_tlb -# postfix as necessary. +# This option allows MMU_LAZY_TLB_REFCOUNT=3Dn. It ensures no CPUs are usi= ng an +# mm as a lazy tlb beyond its last reference count, by shooting down these +# users before the mm is deallocated. __mmdrop() first IPIs all CPUs that = may +# be using the mm as a lazy tlb, so that they may switch themselves to usi= ng +# init_mm for their active mm. mm_cpumask(mm) is used to determine which C= PUs +# may be using mm as a lazy tlb mm. +# +# To implement this, an arch must ensure mm_cpumask(mm) contains at least = all +# possible CPUs in which the mm is lazy, and it must meet the requirements= for +# MMU_LAZY_TLB_REFCOUNT=3Dn (see above). config MMU_LAZY_TLB_SHOOTDOWN bool =20 --=20 2.23.0