All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Roger Pau Monné" <roger.pau@citrix.com>
To: Jan Beulich <jbeulich@suse.com>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>, Wei Liu <wl@xen.org>,
	xen-devel@lists.xenproject.org
Subject: Re: [PATCH] x86/flushtlb: remove flush_area check on system state
Date: Mon, 23 May 2022 16:37:31 +0200	[thread overview]
Message-ID: <YoucK13m0y3CqDl1@Air-de-Roger> (raw)
In-Reply-To: <c7878c92-41e7-4628-34b1-1cb409335bf1@suse.com>

On Wed, May 18, 2022 at 10:49:22AM +0200, Jan Beulich wrote:
> On 16.05.2022 16:31, Roger Pau Monne wrote:
> > --- a/xen/arch/x86/include/asm/flushtlb.h
> > +++ b/xen/arch/x86/include/asm/flushtlb.h
> > @@ -146,7 +146,8 @@ void flush_area_mask(const cpumask_t *, const void *va, unsigned int flags);
> >  #define flush_mask(mask, flags) flush_area_mask(mask, NULL, flags)
> >  
> >  /* Flush all CPUs' TLBs/caches */
> > -#define flush_area_all(va, flags) flush_area_mask(&cpu_online_map, va, flags)
> > +#define flush_area(va, flags) \
> > +    flush_area_mask(&cpu_online_map, (const void *)(va), flags)
> 
> I have to admit that I would prefer if we kept the "_all" name suffix,
> to continue to clearly express the scope of the flush. I'm also not
> really happy to see the cast being added globally now.

But there where no direct callers of flush_area_all(), so the name was
just relevant for it's use in flush_area().  With that now gone I
don't see a need for a flush_area_all(), as flush_area_mask() is more
appropriate.

> > --- a/xen/arch/x86/smp.c
> > +++ b/xen/arch/x86/smp.c
> > @@ -262,7 +262,8 @@ void flush_area_mask(const cpumask_t *mask, const void *va, unsigned int flags)
> >  {
> >      unsigned int cpu = smp_processor_id();
> >  
> > -    ASSERT(local_irq_is_enabled());
> > +    /* Local flushes can be performed with interrupts disabled. */
> > +    ASSERT(local_irq_is_enabled() || cpumask_equal(mask, cpumask_of(cpu)));
> 
> Further down we use cpumask_subset(mask, cpumask_of(cpu)),
> apparently to also cover the case where mask is empty. I think
> you want to do so here as well.

Hm, yes.  I guess that's cheaper than adding an extra:

if ( cpumask_empty() )
    return;

check at the start of the function.

> >      if ( (flags & ~(FLUSH_VCPU_STATE | FLUSH_ORDER_MASK)) &&
> >           cpumask_test_cpu(cpu, mask) )
> 
> I suppose we want a further precaution here: Despite the
> !cpumask_subset(mask, cpumask_of(cpu)) below I think we want to
> extend what c64bf2d2a625 ("x86: make CPU state flush requests
> explicit") and later changes (isolating uses of FLUSH_VCPU_STATE
> from other FLUSH_*) did and exclude the use of FLUSH_VCPU_STATE
> for the local CPU altogether.

If we really want to exclude the use of FLUSH_VCPU_STATE for the local
CPU, we might wish to add this as a separate ASSERT, so that such
checking doesn't depend on !local_irq_is_enabled():

ASSERT(local_irq_is_enabled() || cpumask_subset(mask, cpumask_of(cpu));
ASSERT(!cpumask_subset(mask, cpumask_of(cpu)) || !(flags & FLUSH_VCPU_STATE));


> That's because if such somehow made
> it into the conditional below here, it would still involve an IPI.

Sorry, I'm confused by this: if the mask is empty there should be no
IPI involved at all?  And we shouldn't even get into the second
conditional on the function.

Thanks, Roger.


  reply	other threads:[~2022-05-23 14:38 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-16 14:31 [PATCH] x86/flushtlb: remove flush_area check on system state Roger Pau Monne
2022-05-16 14:47 ` Andrew Cooper
2022-05-18  8:49 ` Jan Beulich
2022-05-23 14:37   ` Roger Pau Monné [this message]
2022-05-23 15:13     ` Jan Beulich
2022-05-23 16:24       ` Roger Pau Monné
2022-05-24 10:48         ` Roger Pau Monné
2022-05-24  7:32       ` Roger Pau Monné

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=YoucK13m0y3CqDl1@Air-de-Roger \
    --to=roger.pau@citrix.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=jbeulich@suse.com \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.