All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Jan Beulich <JBeulich@suse.com>,
	xen-devel <xen-devel@lists.xenproject.org>
Cc: Juergen Gross <jgross@suse.com>, Manuel Bouyer <bouyer@antioche.eu.org>
Subject: Re: [PATCH] x86: correct vCPU dirty CPU handling
Date: Thu, 26 Apr 2018 10:51:32 +0100	[thread overview]
Message-ID: <15b39884-c5b5-c672-752c-4d0cff2b5f1d@citrix.com> (raw)
In-Reply-To: <5AE19EC002000078001BEABB@prv1-mh.provo.novell.com>

On 26/04/18 10:41, Jan Beulich wrote:
> --- a/xen/arch/x86/mm.c
> +++ b/xen/arch/x86/mm.c
> @@ -1202,11 +1202,23 @@ void put_page_from_l1e(l1_pgentry_t l1e,
>               unlikely(((page->u.inuse.type_info & PGT_count_mask) != 0)) &&
>               (l1e_owner == pg_owner) )
>          {
> +            cpumask_t *mask = this_cpu(scratch_cpumask);
> +
> +            cpumask_clear(mask);
> +
>              for_each_vcpu ( pg_owner, v )
>              {
> -                if ( pv_destroy_ldt(v) )
> -                    flush_tlb_mask(cpumask_of(v->dirty_cpu));
> +                unsigned int cpu;
> +
> +                if ( !pv_destroy_ldt(v) )
> +                    continue;
> +                cpu = read_atomic(&v->dirty_cpu);
> +                if ( is_vcpu_dirty_cpu(cpu) )
> +                    __cpumask_set_cpu(cpu, mask);
>              }
> +
> +            if ( !cpumask_empty(mask) )
> +                flush_tlb_mask(mask);

Thinking about this, what is wrong with:

bool flush;

for_each_vcpu ( pg_owner, v )
    if ( pv_destroy_ldt(v) )
        flush = true;

if ( flush )
   flush_tlb_mask(pg_owner->dirty_cpumask);

This is far less complicated cpumask handling.  As the loop may be long,
it avoids flushing pcpus which have subsequently switched away from
pg_owner context.  It also avoids all playing with v->dirty_cpu.

~Andrew

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  reply	other threads:[~2018-04-26  9:51 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-26  9:41 [PATCH] x86: correct vCPU dirty CPU handling Jan Beulich
2018-04-26  9:51 ` Andrew Cooper [this message]
2018-04-26 10:52   ` Jan Beulich
2018-05-15  8:25     ` Ping: " Jan Beulich
2018-05-22 12:29       ` Andrew Cooper
2018-05-22 12:38         ` Juergen Gross
2018-04-26 12:39 ` Manuel Bouyer
2018-05-22 11:02 ` Manuel Bouyer
2018-05-22 11:08   ` Jan Beulich

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=15b39884-c5b5-c672-752c-4d0cff2b5f1d@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=JBeulich@suse.com \
    --cc=bouyer@antioche.eu.org \
    --cc=jgross@suse.com \
    --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.