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 A536CC64E8A for ; Wed, 2 Dec 2020 02:50:09 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E98BE206F9 for ; Wed, 2 Dec 2020 02:50:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E98BE206F9 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 77FCF6B0068; Tue, 1 Dec 2020 21:50:08 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 72E158D0001; Tue, 1 Dec 2020 21:50:08 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5A8DF6B006E; Tue, 1 Dec 2020 21:50:08 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0107.hostedemail.com [216.40.44.107]) by kanga.kvack.org (Postfix) with ESMTP id 3EB046B0068 for ; Tue, 1 Dec 2020 21:50:08 -0500 (EST) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 080703637 for ; Wed, 2 Dec 2020 02:50:08 +0000 (UTC) X-FDA: 77546812896.22.juice22_3911a6f273af Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin22.hostedemail.com (Postfix) with ESMTP id CFBC518038E87 for ; Wed, 2 Dec 2020 02:50:07 +0000 (UTC) X-HE-Tag: juice22_3911a6f273af X-Filterd-Recvd-Size: 7515 Received: from mail-pg1-f195.google.com (mail-pg1-f195.google.com [209.85.215.195]) by imf29.hostedemail.com (Postfix) with ESMTP for ; Wed, 2 Dec 2020 02:50:07 +0000 (UTC) Received: by mail-pg1-f195.google.com with SMTP id k11so186438pgq.2 for ; Tue, 01 Dec 2020 18:50:07 -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=rrxTVjl50w/hvvFu6753KKn1qpO44MFkmA/m2ENQPW0=; b=U3Sz0euxPXDrCmFLKwiYimm6yyBF1CGZXzT+k7baShme0K69SttxGDVElTYP7xD81J 2NwdKEYT3Zs9274B6kIHynUHQPZ00KgUdGXc5ha6W25qHfVhMjyjdck0nx62b5X0C5To 1P9o/31CYlfFtSMNCjiOGhQYR+PUawAmO+HbR9rqzp7uxjtqn81AbD7uKh21gQTcRclr sKwpc0TgjomEW3W/Rh8pgDEiycq5f03ojFi19mo+lIT5VM/sT2AJ3raUjTw0OeqLxxxI DeTkpxfBTV9HwMT81IfJ5wjehPhqTvkZsBC5tEDMDQr4JcEUe4akPkazAtZiJqIKHcrf R1uQ== 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=rrxTVjl50w/hvvFu6753KKn1qpO44MFkmA/m2ENQPW0=; b=oy9V1Dbh0BbWqacH47+FCnoOOKkWjwHT0K3BjCyPWP5tkhCMMN/ZxPUac1040wSLZW 62vFvIcL/rji5HkMx1P82kPum+g38bk0aasRa0c5mHzVqBZSaYkExf/F2edx1sPnW8nj PULgRm+K3ZCrEV/sWXpWbtNTU9AI2Yn5SOK6vO1guwG+y4/qPH4dLDT5uGkuIvO4fCRX bRNz6MOH3Vu4U6fZVJI9aoLRNthoMVp3TE/Umlh5XvlxM34FrlyjA54Pd8b//IH7L8+N XFmMkk6PAJ/rL0IalO5xb0rGGMkkmPx7eW8w+6gbHTJ5Hbi+T91Du0RYjn7ZaipP6pj0 k2EQ== X-Gm-Message-State: AOAM531IjlH1hfFGn6J6JxdM7vBqtQ3jw4yXGJD6IgtMP9g38sj5Wmvo +M7F0EFpb8KN699nuWzgys4= X-Google-Smtp-Source: ABdhPJx49rJhgYL4DLrmhR3Y7knh5z14lnmGYVTfXlFaVAba7Ker02/OzbTVZiRE1EQln20cmYd6WQ== X-Received: by 2002:a62:188a:0:b029:19a:cdab:9841 with SMTP id 132-20020a62188a0000b029019acdab9841mr496648pfy.12.1606877406324; Tue, 01 Dec 2020 18:50:06 -0800 (PST) Received: from localhost ([1.132.177.56]) by smtp.gmail.com with ESMTPSA id z17sm100444pjn.46.2020.12.01.18.50.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Dec 2020 18:50:05 -0800 (PST) Date: Wed, 02 Dec 2020 12:49:58 +1000 From: Nicholas Piggin Subject: Re: [PATCH 1/8] lazy tlb: introduce exit_lazy_tlb 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-2-npiggin@gmail.com> In-Reply-To: MIME-Version: 1.0 Message-Id: <1606876111.f9oqzur49r.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:38 am: > On Sat, Nov 28, 2020 at 8:01 AM Nicholas Piggin wrote= : >> >> This is called at points where a lazy mm is switched away or made not >> lazy (by its owner switching back). >> >> Signed-off-by: Nicholas Piggin >> --- >> arch/arm/mach-rpc/ecard.c | 1 + >> arch/powerpc/mm/book3s64/radix_tlb.c | 1 + >> fs/exec.c | 6 ++++-- >> include/asm-generic/mmu_context.h | 21 +++++++++++++++++++++ >> kernel/kthread.c | 1 + >> kernel/sched/core.c | 2 ++ >> 6 files changed, 30 insertions(+), 2 deletions(-) >> >> diff --git a/arch/arm/mach-rpc/ecard.c b/arch/arm/mach-rpc/ecard.c >> index 827b50f1c73e..43eb1bfba466 100644 >> --- a/arch/arm/mach-rpc/ecard.c >> +++ b/arch/arm/mach-rpc/ecard.c >> @@ -253,6 +253,7 @@ static int ecard_init_mm(void) >> current->mm =3D mm; >> current->active_mm =3D mm; >> activate_mm(active_mm, mm); >> + exit_lazy_tlb(active_mm, current); >> mmdrop(active_mm); >> ecard_init_pgtables(mm); >> return 0; >> diff --git a/arch/powerpc/mm/book3s64/radix_tlb.c b/arch/powerpc/mm/book= 3s64/radix_tlb.c >> index b487b489d4b6..ac3fec03926a 100644 >> --- a/arch/powerpc/mm/book3s64/radix_tlb.c >> +++ b/arch/powerpc/mm/book3s64/radix_tlb.c >> @@ -661,6 +661,7 @@ static void do_exit_flush_lazy_tlb(void *arg) >> mmgrab(&init_mm); >> current->active_mm =3D &init_mm; >> switch_mm_irqs_off(mm, &init_mm, current); >> + exit_lazy_tlb(mm, current); >> mmdrop(mm); >> } >> >> diff --git a/fs/exec.c b/fs/exec.c >> index 547a2390baf5..4b4dea1bb7ba 100644 >> --- a/fs/exec.c >> +++ b/fs/exec.c >> @@ -1017,6 +1017,8 @@ static int exec_mmap(struct mm_struct *mm) >> if (!IS_ENABLED(CONFIG_ARCH_WANT_IRQS_OFF_ACTIVATE_MM)) >> local_irq_enable(); >> activate_mm(active_mm, mm); >> + if (!old_mm) >> + exit_lazy_tlb(active_mm, tsk); >> if (IS_ENABLED(CONFIG_ARCH_WANT_IRQS_OFF_ACTIVATE_MM)) >> local_irq_enable(); >> tsk->mm->vmacache_seqnum =3D 0; >> @@ -1028,9 +1030,9 @@ static int exec_mmap(struct mm_struct *mm) >> setmax_mm_hiwater_rss(&tsk->signal->maxrss, old_mm); >> mm_update_next_owner(old_mm); >> mmput(old_mm); >> - return 0; >> + } else { >> + mmdrop(active_mm); >> } >> - mmdrop(active_mm); >=20 > This looks like an unrelated change. I thought the old style was pointless and made me look twice to make=20 sure we weren't mmdrop()ing the lazy. >=20 >> return 0; >> } >> >> diff --git a/include/asm-generic/mmu_context.h b/include/asm-generic/mmu= _context.h >> index 91727065bacb..4626d0020e65 100644 >> --- a/include/asm-generic/mmu_context.h >> +++ b/include/asm-generic/mmu_context.h >> @@ -24,6 +24,27 @@ static inline void enter_lazy_tlb(struct mm_struct *m= m, >> } >> #endif >> >> +/* >> + * exit_lazy_tlb - Called after switching away from a lazy TLB mode mm. >> + * >> + * mm: the lazy mm context that was switched >> + * tsk: the task that was switched to (with a non-lazy mm) >> + * >> + * mm may equal tsk->mm. >> + * mm and tsk->mm will not be NULL. >> + * >> + * Note this is not symmetrical to enter_lazy_tlb, this is not >> + * called when tasks switch into the lazy mm, it's called after the >> + * lazy mm becomes non-lazy (either switched to a different mm or the >> + * owner of the mm returns). >> + */ >> +#ifndef exit_lazy_tlb >> +static inline void exit_lazy_tlb(struct mm_struct *mm, >=20 > Maybe name this parameter prev_lazy_mm? >=20 mm is better because it's the mm that we're "exiting lazy" from, the=20 function name gives the context. prev might suggest it was the previous but it's the current one, or that we're switching to another mm but we may not be at all. Thanks, Nick