From: Catalin Marinas <catalin.marinas@arm.com>
To: Andrea Arcangeli <aarcange@redhat.com>
Cc: Will Deacon <will@kernel.org>, Jon Masters <jcm@jonmasters.org>,
Rafael Aquini <aquini@redhat.com>,
Mark Salter <msalter@redhat.com>,
linux-kernel@vger.kernel.org, linux-mm@kvack.org,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH 2/2] arm64: tlb: skip tlbi broadcast for single threaded TLB flushes
Date: Tue, 11 Feb 2020 14:00:25 +0000 [thread overview]
Message-ID: <20200211140025.GB153117@arrakis.emea.arm.com> (raw)
In-Reply-To: <20200210201411.GC3699@redhat.com>
Hi Andrea,
On Mon, Feb 10, 2020 at 03:14:11PM -0500, Andrea Arcangeli wrote:
> On Mon, Feb 10, 2020 at 05:51:06PM +0000, Catalin Marinas wrote:
> > It may be better if you used mm_cpumask to mark wherever an mm ever ran
> > than relying on mm_users.
>
> Agreed.
>
> If we can use mm_cpumask to track where the mm ever run, then if I'm
> not mistaken we could optimize also multithreaded processes in the
> same way: if only one thread is running frequently and the others are
> frequently sleeping, we could issue a single tlbi broadcast (modulo
> invalidates of small virtual ranges).
Possibly, though not sure how you'd detect such scenario.
> In the meantime the below should be enough to address the concern you
> raised of the proof of concept RFC patch.
>
> I already experimented with mm_users == 1 earlier and it doesn't
> change the benchmark results for the "best case" below.
>
> (untested)
>
> diff --git a/arch/arm64/include/asm/tlbflush.h b/arch/arm64/include/asm/tlbflush.h
> index 772bbc45b867..a2d53b301f22 100644
> --- a/arch/arm64/include/asm/tlbflush.h
> +++ b/arch/arm64/include/asm/tlbflush.h
[...]
> @@ -212,7 +215,8 @@ static inline void flush_tlb_page(struct vm_area_struct *vma,
> unsigned long addr = __TLBI_VADDR(uaddr, ASID(mm));
>
> /* avoid TLB-i broadcast to remote NUMA nodes if it's a local flush */
> - if (current->mm == mm && atomic_read(&mm->mm_users) <= 1) {
> + if (current->mm == mm && atomic_read(&mm->mm_users) <= 1 &&
> + (system_uses_ttbr0_pan() || atomic_read(&mm->mm_count) == 1)) {
> int cpu = get_cpu();
>
> cpumask_setall(mm_cpumask(mm));
I think there is another race here. IIUC, the assumption you make is
that when mm_users <= 1 && mm_count == 1, the only active user of this
pgd/ASID is on the CPU doing the TLBI. This is not the case for
try_to_unmap() where the above condition may be true but the active
thread on a different CPU won't notice the local TLBI.
> > That's a pretty artificial test and it is indeed improved by this patch.
> > However, it would be nice to have some real-world scenarios where this
> > matters.
[...]
> Still your question if it'll make a difference in practice is a good
> one and I don't have a sure answer yet. I suppose before doing more
> benchmarking it's better to make a new version of this that uses
> mm_cpumask to track where the asid was ever loaded as you suggested,
> so that it will also optimize away tlbi broadcasts from multithreaded
> processes where only one thread is running frequently?
I was actually curious what triggered this patch series, whether you've
seen a real use-case where the TLBI was a bottleneck.
--
Catalin
next prev parent reply other threads:[~2020-02-11 14:00 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-03 20:17 [RFC] [PATCH 0/2] " Andrea Arcangeli
2020-02-03 20:17 ` [PATCH 1/2] mm: use_mm: fix for arches checking mm_users to optimize " Andrea Arcangeli
2020-02-18 11:31 ` Michal Hocko
2020-02-18 18:56 ` Andrea Arcangeli
2020-02-19 11:58 ` Michal Hocko
2020-02-19 20:04 ` Andrea Arcangeli
2020-02-03 20:17 ` [PATCH 2/2] arm64: tlb: skip tlbi broadcast for single threaded " Andrea Arcangeli
2020-02-10 17:51 ` Catalin Marinas
2020-02-10 20:14 ` Andrea Arcangeli
2020-02-11 14:00 ` Catalin Marinas [this message]
2020-02-12 12:57 ` Andrea Arcangeli
2020-02-12 14:13 ` qi.fuli
2020-02-12 15:26 ` Catalin Marinas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200211140025.GB153117@arrakis.emea.arm.com \
--to=catalin.marinas@arm.com \
--cc=aarcange@redhat.com \
--cc=aquini@redhat.com \
--cc=jcm@jonmasters.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=msalter@redhat.com \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®