From: Yu Zhang <yu.c.zhang@linux.intel.com>
To: xen-devel@lists.xen.org
Cc: George Dunlap <george.dunlap@eu.citrix.com>,
Andrew Cooper <andrew.cooper3@citrix.com>,
zhiyuan.lv@intel.com, Jan Beulich <jbeulich@suse.com>
Subject: [PATCH RFC] x86/ioreq server: Optimize p2m cleaning up code in p2m_finish_type_change().
Date: Wed, 5 Apr 2017 16:59:50 +0800 [thread overview]
Message-ID: <1491382790-30066-1-git-send-email-yu.c.zhang@linux.intel.com> (raw)
Previously, p2m_finish_type_change() is triggered to iterate and
clean up the p2m table when an ioreq server unmaps from memory type
HVMMEM_ioreq_server. And the current iteration number is set to 256
And after these iterations, hypercall pre-emption is checked.
But it is likely that no p2m change is performed for the just finished
iterations, which means p2m_finish_type_change() will return quite
soon. So in such scenario, we can allow the p2m iteration to continue,
without checking the hypercall pre-emption.
Signed-off-by: Yu Zhang <yu.c.zhang@linux.intel.com>
---
Note: this patch shall only be accepted after previous x86/ioreq server
patches be merged.
Cc: Jan Beulich <jbeulich@suse.com>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: George Dunlap <george.dunlap@eu.citrix.com>
---
xen/arch/x86/hvm/dm.c | 5 ++++-
xen/arch/x86/mm/p2m.c | 9 ++++++++-
xen/include/asm-x86/p2m.h | 2 +-
3 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/xen/arch/x86/hvm/dm.c b/xen/arch/x86/hvm/dm.c
index d72b7bd..3aa1286 100644
--- a/xen/arch/x86/hvm/dm.c
+++ b/xen/arch/x86/hvm/dm.c
@@ -411,14 +411,17 @@ static int dm_op(domid_t domid,
while ( read_atomic(&p2m->ioreq.entry_count) &&
first_gfn <= p2m->max_mapped_pfn )
{
+ bool changed = false;
+
/* Iterate p2m table for 256 gfns each time. */
p2m_finish_type_change(d, _gfn(first_gfn), 256,
- p2m_ioreq_server, p2m_ram_rw);
+ p2m_ioreq_server, p2m_ram_rw, &changed);
first_gfn += 256;
/* Check for continuation if it's not the last iteration. */
if ( first_gfn <= p2m->max_mapped_pfn &&
+ changed &&
hypercall_preempt_check() )
{
rc = -ERESTART;
diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c
index 0daaa86..b171a4b 100644
--- a/xen/arch/x86/mm/p2m.c
+++ b/xen/arch/x86/mm/p2m.c
@@ -1034,12 +1034,13 @@ void p2m_change_type_range(struct domain *d,
/* Synchronously modify the p2m type for a range of gfns from ot to nt. */
void p2m_finish_type_change(struct domain *d,
gfn_t first_gfn, unsigned long max_nr,
- p2m_type_t ot, p2m_type_t nt)
+ p2m_type_t ot, p2m_type_t nt, bool *changed)
{
struct p2m_domain *p2m = p2m_get_hostp2m(d);
p2m_type_t t;
unsigned long gfn = gfn_x(first_gfn);
unsigned long last_gfn = gfn + max_nr - 1;
+ bool is_changed = false;
ASSERT(ot != nt);
ASSERT(p2m_is_changeable(ot) && p2m_is_changeable(nt));
@@ -1052,12 +1053,18 @@ void p2m_finish_type_change(struct domain *d,
get_gfn_query_unlocked(d, gfn, &t);
if ( t == ot )
+ {
p2m_change_type_one(d, gfn, t, nt);
+ is_changed = true;
+ }
gfn++;
}
p2m_unlock(p2m);
+
+ if ( changed )
+ *changed = is_changed;
}
/*
diff --git a/xen/include/asm-x86/p2m.h b/xen/include/asm-x86/p2m.h
index 0e670af..2e02538 100644
--- a/xen/include/asm-x86/p2m.h
+++ b/xen/include/asm-x86/p2m.h
@@ -615,7 +615,7 @@ int p2m_change_type_one(struct domain *d, unsigned long gfn,
void p2m_finish_type_change(struct domain *d,
gfn_t first_gfn,
unsigned long max_nr,
- p2m_type_t ot, p2m_type_t nt);
+ p2m_type_t ot, p2m_type_t nt, bool *changed);
/* Report a change affecting memory types. */
void p2m_memory_type_changed(struct domain *d);
--
1.9.1
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next reply other threads:[~2017-04-05 8:59 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-05 8:59 Yu Zhang [this message]
2017-04-05 15:10 ` [PATCH RFC] x86/ioreq server: Optimize p2m cleaning up code in p2m_finish_type_change() George Dunlap
2017-04-05 15:11 ` George Dunlap
2017-04-05 16:28 ` Yu Zhang
2017-05-09 16:29 ` Jan Beulich
2017-05-10 5:27 ` Yu Zhang
2017-05-09 16:30 ` 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=1491382790-30066-1-git-send-email-yu.c.zhang@linux.intel.com \
--to=yu.c.zhang@linux.intel.com \
--cc=andrew.cooper3@citrix.com \
--cc=george.dunlap@eu.citrix.com \
--cc=jbeulich@suse.com \
--cc=xen-devel@lists.xen.org \
--cc=zhiyuan.lv@intel.com \
/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).