linux-alpha.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Matt Turner <mattst88@gmail.com>
To: Nicholas Piggin <npiggin@gmail.com>
Cc: linux-alpha@vger.kernel.org,
	Richard Henderson <richard.henderson@linaro.org>,
	Ivan Kokshaysky <ink@jurassic.park.msu.ru>,
	Linus Torvalds <torvalds@linux-foundation.org>
Subject: Re: [RFC PATCH 4/6] alpha: clean mm_cpumask when flushing TLBs
Date: Tue, 5 Sep 2023 21:39:49 -0400	[thread overview]
Message-ID: <CAEdQ38EXOpqxKhqH=AN3uLnbJX2S5d+2sXS0EXU38H6exD=nUQ@mail.gmail.com> (raw)
In-Reply-To: <CAEdQ38F6LqYbmAt+-NeV0gmsC+bYynmgBb8CPhHFNDzhcwC3Kg@mail.gmail.com>

On Fri, Jun 2, 2023 at 6:33 PM Matt Turner <mattst88@gmail.com> wrote:
>
> On Wed, May 24, 2023 at 1:18 PM Nicholas Piggin <npiggin@gmail.com> wrote:
> >
> > mm_cpumask is a map of the CPUs which must be IPIed to flush TLBs,
> > and/or IPIed to shootdown lazy TLB mms at exit time.
> >
> > When flushing TLBs on the CPU, trim it from mm_cpumask if the mm is not
> > currently active on the CPU. TLBs will have been flush, and the mm is
> > not active, so there is no more reason to get IPIs.
> >
> > Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
> > ---
> >  arch/alpha/include/asm/tlbflush.h |  3 +++
> >  arch/alpha/kernel/smp.c           | 29 +++++++++++++++++++++++++++--
> >  2 files changed, 30 insertions(+), 2 deletions(-)
> >
> > diff --git a/arch/alpha/include/asm/tlbflush.h b/arch/alpha/include/asm/tlbflush.h
> > index 94dc37cf873a..7c4e719ac9e7 100644
> > --- a/arch/alpha/include/asm/tlbflush.h
> > +++ b/arch/alpha/include/asm/tlbflush.h
> > @@ -12,6 +12,7 @@
> >  #endif
> >
> >  extern void __load_new_mm_context(struct mm_struct *);
> > +extern void try_clear_mm_cpumask(struct mm_struct *);
> >
> >
> >  /* Use a few helper functions to hide the ugly broken ASN
> > @@ -106,6 +107,7 @@ static inline void flush_tlb_all(void)
> >  static inline void
> >  flush_tlb_mm(struct mm_struct *mm)
> >  {
> > +       try_clear_mm_cpumask(mm);
> >         if (mm == current->active_mm)
> >                 flush_tlb_current(mm);
> >         else
> > @@ -118,6 +120,7 @@ flush_tlb_page(struct vm_area_struct *vma, unsigned long addr)
> >  {
> >         struct mm_struct *mm = vma->vm_mm;
> >
> > +       try_clear_mm_cpumask(mm);
> >         if (mm == current->active_mm)
> >                 flush_tlb_current_page(mm, vma, addr);
> >         else
> > diff --git a/arch/alpha/kernel/smp.c b/arch/alpha/kernel/smp.c
> > index e436c056267d..d668b9d319af 100644
> > --- a/arch/alpha/kernel/smp.c
> > +++ b/arch/alpha/kernel/smp.c
> > @@ -610,6 +610,28 @@ smp_imb(void)
> >  }
> >  EXPORT_SYMBOL(smp_imb);
> >
> > +#define asn_locked() (cpu_data[smp_processor_id()].asn_lock)
> > +
> > +/*
> > + * If the mm_cpumask bit is cleared, the caller *must* flush the TLB for the
> > + * mm on this CPU. It is only cleared when the mm is not active, in which
> > + * case the flushing always performs flush_tlb_other that flushes everything.
> > + * If that changes in callers, they will have to arrange to always do a full
> > + * flush if mm_cpumask is cleared by this function.
> > + */
> > +void
> > +try_clear_mm_cpumask(struct mm_struct *mm)
> > +{
> > +       int cpu;
> > +
> > +       if (current->active_mm == mm || asn_locked())
> > +               return;
> > +
> > +       cpu = smp_processor_id();
> > +       if (cpumask_test_cpu(cpu, mm_cpumask(mm)))
> > +               cpumask_clear_cpu(cpu, mm_cpumask(mm));
> > +}
>
> Since this is implemented in smp.c, the function is not available in
> !CONFIG_SMP:
>
> ld: kernel/fork.o: in function `dup_mmap':
> (.text+0x1734): undefined reference to `try_clear_mm_cpumask'
> ld: (.text+0x1738): undefined reference to `try_clear_mm_cpumask'
> ld: mm/memory.o: in function `unmap_page_range':
> (.text+0x1934): undefined reference to `try_clear_mm_cpumask'
> ld: (.text+0x193c): undefined reference to `try_clear_mm_cpumask'
> ld: (.text+0x1a28): undefined reference to `try_clear_mm_cpumask'
> ld: mm/memory.o:(.text+0x1a30): more undefined references to
> `try_clear_mm_cpumask' follow
> make[1]: *** [scripts/Makefile.vmlinux:35: vmlinux] Error 1
> make: *** [Makefile:1249: vmlinux] Error 2

Anything I can do to help?

  reply	other threads:[~2023-09-06  1:39 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-24 17:18 [RFC PATCH 0/6] Implement MMU_LAZY_TLB_SHOOTDOWN for alpha Nicholas Piggin
2023-05-24 17:18 ` [RFC PATCH 1/6] alpha: remove extern inline from mmu_context Nicholas Piggin
2023-05-24 17:18 ` [RFC PATCH 2/6] alpha: implement simple mm_cpumask TLB flush filter Nicholas Piggin
2023-05-24 17:18 ` [RFC PATCH 3/6] alpha: remove TLB flushing mm_users special case Nicholas Piggin
2023-05-24 17:18 ` [RFC PATCH 4/6] alpha: clean mm_cpumask when flushing TLBs Nicholas Piggin
2023-06-02 22:33   ` Matt Turner
2023-09-06  1:39     ` Matt Turner [this message]
2023-05-24 17:18 ` [RFC PATCH 5/6] alpha: enable MMU_LAZY_TLB_SHOOTDOWN Nicholas Piggin
2023-05-24 17:18 ` [RFC PATCH 6/6] alpha: shoot the lazy tlb mm when flushing TLBs Nicholas Piggin
2023-05-24 17:27 ` [RFC PATCH 0/6] Implement MMU_LAZY_TLB_SHOOTDOWN for alpha Linus Torvalds
2023-05-24 17:52   ` Matt Turner
2023-05-29  1:45     ` Nicholas Piggin

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='CAEdQ38EXOpqxKhqH=AN3uLnbJX2S5d+2sXS0EXU38H6exD=nUQ@mail.gmail.com' \
    --to=mattst88@gmail.com \
    --cc=ink@jurassic.park.msu.ru \
    --cc=linux-alpha@vger.kernel.org \
    --cc=npiggin@gmail.com \
    --cc=richard.henderson@linaro.org \
    --cc=torvalds@linux-foundation.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).