qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: Richard Henderson <richard.henderson@linaro.org>, qemu-devel@nongnu.org
Cc: Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [Qemu-devel] [RFC/PATCH] i386: Atomically update PTEs with mttcg
Date: Fri, 30 Nov 2018 13:18:51 +1100	[thread overview]
Message-ID: <3689b566fb9de9f95af1993299e5d5f1df23c91f.camel@kernel.crashing.org> (raw)
In-Reply-To: <b8130aae-5158-bb31-73c0-82beee0ad176@linaro.org>

On Thu, 2018-11-29 at 16:12 -0800, Richard Henderson wrote:
> On 11/29/18 2:54 PM, Benjamin Herrenschmidt wrote:
> > >      pdpe_addr = (pml4e & PG_ADDRESS_MASK) +
> > >                  (((gphys >> 30) & 0x1ff) << 3);
> > >      pdpe = x86_ldq_phys(cs, pdpe_addr);
> > >      do {
> > >          if (!(pdpe & PG_PRESENT_MASK)) {
> > >              goto do_fault;
> > >          }
> > >          if (pdpe & rsvd_mask) {
> > >              goto do_fault_rsvd;
> > >          }
> > >          if (pdpe & PG_ACCESSED_MASK) {
> > >              break;
> > >          }
> > >      } while (!update_entry(cs, pdpe_addr, &pdpe, PG_ACCESSED_MASK));
> > >      ptep &= pdpe ^ PG_NX_MASK;
> > > 
> > > ....
> > 
> > Hrm.. I see. So not re-do the full walk. Not sure it's really worth it
> > though, how often do we expect to hit the failing case ?
> 
> It is probably rare-ish, I admit.
> 
> I suppose we could also signal "success" from update_entry if the cmpxchg
> fails, but the value that was reloaded only differs in setting PG_ACCESSED_MASK

The latter optimization is trivial. As for the former, replacing my
"goto restart" with those loops, it will make the patch significantly
bigger, though not adding another goto has its perks and the end result
might be slightly nicer ...

What way do you prefer ?

Cheers,
Ben.

  parent reply	other threads:[~2018-11-30  2:19 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-28 23:15 [Qemu-devel] [RFC/PATCH] i386: Atomically update PTEs with mttcg Benjamin Herrenschmidt
2018-11-29  9:26 ` Paolo Bonzini
2018-11-29 10:04   ` Benjamin Herrenschmidt
2018-11-29 10:10     ` Paolo Bonzini
2018-11-29 19:04 ` Richard Henderson
2018-11-29 22:54   ` Benjamin Herrenschmidt
2018-11-30  0:12     ` Richard Henderson
2018-11-30  2:12       ` Benjamin Herrenschmidt
2018-11-30  2:18       ` Benjamin Herrenschmidt [this message]
2018-12-13 23:39   ` Benjamin Herrenschmidt
2018-12-13 23:47     ` Richard Henderson

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=3689b566fb9de9f95af1993299e5d5f1df23c91f.camel@kernel.crashing.org \
    --to=benh@kernel.crashing.org \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.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 NNTP newsgroup(s).