All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tim Deegan <tim@xen.org>
To: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: George Dunlap <george.dunlap@eu.citrix.com>,
	Jan Beulich <JBeulich@suse.com>,
	Xen-devel <xen-devel@lists.xen.org>
Subject: Re: [PATCH v2 8/9] x86/pagewalk: Improve the logic behind setting access and dirty bits
Date: Thu, 23 Mar 2017 17:09:24 +0000	[thread overview]
Message-ID: <20170323170924.GF8166@deinos.phlegethon.org> (raw)
In-Reply-To: <1489681903-28119-9-git-send-email-andrew.cooper3@citrix.com>

At 16:31 +0000 on 16 Mar (1489681902), Andrew Cooper wrote:
> --- a/xen/arch/x86/mm/guest_walk.c
> +++ b/xen/arch/x86/mm/guest_walk.c
> @@ -32,24 +32,28 @@ asm(".file \"" __OBJECT_FILE__ "\"");
>  #include <asm/page.h>
>  #include <asm/guest_pt.h>
>  
> -/* Modify a guest pagetable entry to set the Accessed and Dirty bits.
> - * Returns non-zero if it actually writes to guest memory. */
> -static uint32_t set_ad_bits(void *guest_p, void *walk_p, int set_dirty)
> +/*
> + * Modify a guest pagetable entry to set the Accessed and Dirty bits.
> + * Returns non-zero if it actually writes to guest memory.

s/non-zero/true/.

> + */
> +static bool set_ad_bits(void *_guest_p, void *_walk_p, bool set_dirty)

Would it work to have this take guest_intpte_t * and have the caller
pass e.g. &l4p[guest_l4_table_offset(va)].l4 ?  Not very much prettier, I
suppose. :)

>  {
> -    guest_intpte_t old, new;
> +    guest_intpte_t *guest_p = _guest_p, *walk_p = _walk_p;
> +    guest_intpte_t new, old = ACCESS_ONCE(*walk_p);

Why ACCESS_ONCE?  The walk is unlikely to change underfoot.

>  
> -    old = *(guest_intpte_t *)walk_p;
>      new = old | _PAGE_ACCESSED | (set_dirty ? _PAGE_DIRTY : 0);
> -    if ( old != new ) 
> +    if ( old != new )
>      {
> -        /* Write the new entry into the walk, and try to write it back
> +        /*
> +         * Write the new entry into the walk, and try to write it back
>           * into the guest table as well.  If the guest table has changed
> -         * under out feet then leave it alone. */
> -        *(guest_intpte_t *)walk_p = new;
> -        if ( cmpxchg(((guest_intpte_t *)guest_p), old, new) == old ) 
> -            return 1;
> +         * under out feet then leave it alone.

s/out/our/ while we're here. 

The rest of this LGTM, thanks.

Cheers,

Tim.

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

  parent reply	other threads:[~2017-03-23 17:09 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-16 16:31 [PATCH v2 0/9] Fixes to pagetable handling Andrew Cooper
2017-03-16 16:31 ` [PATCH v2 1/9] x86/cpuid: Sort cpu_has_* predicates by feature number Andrew Cooper
2017-03-17 16:08   ` Jan Beulich
2017-03-16 16:31 ` [PATCH v2 2/9] x86/pagewalk: Use pointer syntax for pfec parameter Andrew Cooper
2017-03-17 16:09   ` Jan Beulich
2017-03-20 11:29   ` George Dunlap
2017-03-23 16:28   ` Tim Deegan
2017-03-16 16:31 ` [PATCH v2 3/9] x86/shadow: Drop VALID_GFN() Andrew Cooper
2017-03-23 16:30   ` Tim Deegan
2017-03-16 16:31 ` [PATCH v2 4/9] x86/pagewalk: Clean up guest_supports_* predicates Andrew Cooper
2017-03-20  8:45   ` Jan Beulich
2017-03-20 13:36     ` Andrew Cooper
2017-03-20 13:59       ` Jan Beulich
2017-03-23 17:32         ` Andrew Cooper
2017-03-24  7:19           ` Jan Beulich
2017-03-23 16:34   ` Tim Deegan
2017-03-16 16:31 ` [PATCH v2 5/9] x86/pagewalk: Helpers for reserved bit handling Andrew Cooper
2017-03-20  8:48   ` Jan Beulich
2017-03-23 16:55   ` Tim Deegan
2017-03-23 17:02     ` Andrew Cooper
2017-03-23 17:12       ` Tim Deegan
2017-03-23 17:35         ` Andrew Cooper
2017-03-24  5:45           ` Juergen Gross
2017-03-24  7:51             ` Jan Beulich
     [not found]             ` <58D4DDFF0200007800147138@suse.com>
2017-03-24  7:58               ` Juergen Gross
2017-03-24  8:25                 ` Jan Beulich
2017-03-24  9:06             ` Andrew Cooper
2017-03-24  7:47           ` Jan Beulich
2017-03-24  8:36             ` Andrew Cooper
2017-03-16 16:31 ` [PATCH v2 6/9] x86/pagewalk: Re-implement the pagetable walker Andrew Cooper
2017-03-16 16:31 ` [PATCH v2 7/9] x86/shadow: Use the pagewalk reserved bits helpers Andrew Cooper
2017-03-16 17:25   ` Andrew Cooper
2017-03-20  8:53   ` Jan Beulich
2017-03-23 16:57   ` Tim Deegan
2017-03-16 16:31 ` [PATCH v2 8/9] x86/pagewalk: Improve the logic behind setting access and dirty bits Andrew Cooper
2017-03-20  9:03   ` Jan Beulich
2017-03-23 17:09   ` Tim Deegan [this message]
2017-03-23 17:40     ` Andrew Cooper
2017-03-16 16:31 ` [PATCH v2 9/9] x86/pagewalk: non-functional cleanup Andrew Cooper
2017-03-20  9:04   ` Jan Beulich
2017-03-23 17:10   ` Tim Deegan

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=20170323170924.GF8166@deinos.phlegethon.org \
    --to=tim@xen.org \
    --cc=JBeulich@suse.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=george.dunlap@eu.citrix.com \
    --cc=xen-devel@lists.xen.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.