From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Christoph Egger <chegger@amazon.de>, xen-devel@lists.xen.org
Cc: Keir Fraser <keir@xen.org>, Matt Wilson <msw@amazon.com>,
Jan Beulich <jbeulich@suse.com>
Subject: Re: [PATCH 1/2] gnttab: Introduce rwlock to protect updates to grant table state
Date: Tue, 2 Dec 2014 11:28:12 +0000 [thread overview]
Message-ID: <547DA24C.2050508@citrix.com> (raw)
In-Reply-To: <1417514784-15749-2-git-send-email-chegger@amazon.de>
On 02/12/14 10:06, Christoph Egger wrote:
> Rename lock to maptrack_lock and use it to protect maptrack state.
>
> The new rwlock is used to prevent readers from accessing
> inconsistent grant table state such as current
> version, partially initialized active table pages,
> etc.
I would suggest phrasing this slightly differently, as it isn't a simple
rename.
What you are doing is taking the existing grant table lock, splitting it
in two to separate the grant locking from the maptrack locking, and
changing the resulting grant lock to be a rwlock.
With this noted, it would certainly be easier to review if this patch
was split in two; one patch to split the spinlocks and one patch to
change the grant lock from a spinlock to a rwlock.
> diff --git a/xen/common/grant_table.c b/xen/common/grant_table.c
> index 8fba923..018b5b6 100644
> --- a/xen/common/grant_table.c
> +++ b/xen/common/grant_table.c
> @@ -2501,8 +2510,19 @@ gnttab_swap_grant_ref(XEN_GUEST_HANDLE_PARAM(gnttab_swap_grant_ref_t) uop,
> return i;
> if ( unlikely(__copy_from_guest(&op, uop, 1)) )
> return -EFAULT;
> - op.status = __gnttab_swap_grant_ref(op.ref_a, op.ref_b);
> - if ( unlikely(__copy_field_to_guest(uop, &op, status)) )
> + if ( unlikely(op.ref_a == op.ref_b) )
> + {
> + /* noop, so avoid acquiring the same active entry
> + * twice in __gnttab_swap_grant_ref(), which would
> + * case a deadlock.
> + */
> + op.status = GNTST_okay;
> + }
> + else
> + {
> + op.status = __gnttab_swap_grant_ref(op.ref_a, op.ref_b);
> + }
> + if ( unlikely(__copy_to_guest_offset(uop, i, &op, 1)) )
I believe this comment only applies to the changes in active locking
introduced in the subsequent patch?
Either way, I think the a == b check should be in
__gnttab_swap_grant_ref() make any caller safe, not just the this one.
~Andrew
next prev parent reply other threads:[~2014-12-02 11:28 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-02 10:06 [PATCH 0/2] gnttab: Improve scaleability Christoph Egger
2014-12-02 10:06 ` [PATCH 1/2] gnttab: Introduce rwlock to protect updates to grant table state Christoph Egger
2014-12-02 11:28 ` Andrew Cooper [this message]
2014-12-02 12:35 ` Julien Grall
2014-12-02 13:03 ` Egger, Christoph
2014-12-02 13:08 ` Julien Grall
2014-12-02 13:18 ` Egger, Christoph
2014-12-02 10:06 ` [PATCH 2/2] gnttab: refactor locking for scalability Christoph Egger
2014-12-02 11:00 ` [PATCH 0/2] gnttab: Improve scaleability Andrew Cooper
2014-12-02 11:08 ` Egger, Christoph
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=547DA24C.2050508@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=chegger@amazon.de \
--cc=jbeulich@suse.com \
--cc=keir@xen.org \
--cc=msw@amazon.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.