From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Jan Beulich <JBeulich@suse.com>
Cc: xen-devel <xen-devel@lists.xenproject.org>,
Tim Deegan <tim@xen.org>,
Andres Lagar-Cavilla <andres@lagarcavilla.org>
Subject: Re: [PATCH] x86/memshr: fix preemption in relinquish_shared_pages()
Date: Tue, 17 Dec 2013 10:43:39 +0000 [thread overview]
Message-ID: <52B02ADB.2050002@citrix.com> (raw)
In-Reply-To: <52B0224B020000780010E067@nat28.tlf.novell.com>
[-- Attachment #1.1: Type: text/plain, Size: 1763 bytes --]
On 17/12/13 09:07, Jan Beulich wrote:
> For one, should hypercall_preempt_check() return false the first time
> it gets called, it would never have got called again (because count,
> being checked for equality, didn't get reset to zero).
>
> And then, if there were a huge range of unshared pages, with count not
> getting incremented at all in that case there would also not be any
> preemption.
>
> Fix this by using a biased increment (ratio 1:16 for unshared vs shared
> pages), and check for certain bits in count to be clear rather than for
> a specific value (the alternative would be to do a greater-or-equal
> comparison and flush the value to zero in case of a "false" return from
> hypercall_preempt_check()).
>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
>
> --- a/xen/arch/x86/mm/mem_sharing.c
> +++ b/xen/arch/x86/mm/mem_sharing.c
> @@ -1290,11 +1290,13 @@ int relinquish_shared_pages(struct domai
> set_rc = p2m->set_entry(p2m, gfn, _mfn(0), PAGE_ORDER_4K,
> p2m_invalid, p2m_access_rwx);
> ASSERT(set_rc != 0);
> - count++;
> + count += 0x10;
> }
> + else
> + ++count;
>
> - /* Preempt every 2MiB. Arbitrary */
> - if ( (count == 512) && hypercall_preempt_check() )
> + /* Preempt every 2MiB (shared) or 32MiB (unshared) - arbitrary. */
> + if ( !(count & 0x1ff0) && hypercall_preempt_check() )
> {
> p2m->next_shared_gfn_to_relinquish = gfn + 1;
> rc = -EAGAIN;
>
>
>
>
>
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org
> http://lists.xen.org/xen-devel
[-- Attachment #1.2: Type: text/html, Size: 2645 bytes --]
[-- Attachment #2: Type: text/plain, Size: 126 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
next prev parent reply other threads:[~2013-12-17 10:43 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-17 9:07 [PATCH] x86/memshr: fix preemption in relinquish_shared_pages() Jan Beulich
2013-12-17 10:43 ` Andrew Cooper [this message]
2013-12-17 14:44 ` Tim Deegan
2013-12-17 15:23 ` [PATCH v2] " Jan Beulich
2013-12-17 15:26 ` Tim Deegan
2013-12-17 16:40 ` Andrés Lagar-Cavilla
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=52B02ADB.2050002@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=JBeulich@suse.com \
--cc=andres@lagarcavilla.org \
--cc=tim@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.