From: Andres Lagar-Cavilla <andres@lagarcavilla.org>
To: xen-devel@lists.xensource.com
Cc: ian.campbell@citrix.com, andres@gridcentric.ca, tim@xen.org,
keir.xen@gmail.com, JBeulich@suse.com, ian.jackson@citrix.com,
adin@gridcentric.ca
Subject: [PATCH 2 of 9] x86/mm: Don't trigger unnecessary shadow scans on p2m entry update
Date: Tue, 29 Nov 2011 15:21:39 -0500 [thread overview]
Message-ID: <1b241f9841675a8aaa55.1322598099@xdev.gridcentric.ca> (raw)
In-Reply-To: <patchbomb.1322598097@xdev.gridcentric.ca>
xen/arch/x86/mm/shadow/common.c | 6 ++----
xen/arch/x86/mm/shadow/multi.c | 2 +-
xen/arch/x86/mm/shadow/private.h | 7 +++++++
3 files changed, 10 insertions(+), 5 deletions(-)
When updating a p2m entry, the hypervisor scans all shadow pte's to find
mappings of that gfn and tear them down. This is avoided if the page count
reveals that there are no additional mappings. The current test ignores the
PGC_allocated flag and its effect on the page count.
Signed-off-by: Andres Lagar-Cavilla <andres@lagarcavilla.org>
Signed-off-by: Adin Scannell <adin@scannell.ca>
diff -r 47bfc8f8c0be -r 1b241f984167 xen/arch/x86/mm/shadow/common.c
--- a/xen/arch/x86/mm/shadow/common.c
+++ b/xen/arch/x86/mm/shadow/common.c
@@ -2464,7 +2464,6 @@ int sh_remove_write_access_from_sl1p(str
int sh_remove_all_mappings(struct vcpu *v, mfn_t gmfn)
{
struct page_info *page = mfn_to_page(gmfn);
- int expected_count;
/* Dispatch table for getting per-type functions */
static const hash_callback_t callbacks[SH_type_unused] = {
@@ -2501,7 +2500,7 @@ int sh_remove_all_mappings(struct vcpu *
;
perfc_incr(shadow_mappings);
- if ( (page->count_info & PGC_count_mask) == 0 )
+ if ( __check_page_no_refs(page) )
return 0;
/* Although this is an externally visible function, we do not know
@@ -2517,8 +2516,7 @@ int sh_remove_all_mappings(struct vcpu *
hash_foreach(v, callback_mask, callbacks, gmfn);
/* If that didn't catch the mapping, something is very wrong */
- expected_count = (page->count_info & PGC_allocated) ? 1 : 0;
- if ( (page->count_info & PGC_count_mask) != expected_count )
+ if ( !__check_page_no_refs(page) )
{
/* Don't complain if we're in HVM and there are some extra mappings:
* The qemu helper process has an untyped mapping of this dom's RAM
diff -r 47bfc8f8c0be -r 1b241f984167 xen/arch/x86/mm/shadow/multi.c
--- a/xen/arch/x86/mm/shadow/multi.c
+++ b/xen/arch/x86/mm/shadow/multi.c
@@ -4591,7 +4591,7 @@ int sh_rm_mappings_from_l1(struct vcpu *
{
(void) shadow_set_l1e(v, sl1e, shadow_l1e_empty(),
p2m_invalid, sl1mfn);
- if ( (mfn_to_page(target_mfn)->count_info & PGC_count_mask) == 0 )
+ if ( __check_page_no_refs(mfn_to_page(target_mfn)) )
/* This breaks us cleanly out of the FOREACH macro */
done = 1;
}
diff -r 47bfc8f8c0be -r 1b241f984167 xen/arch/x86/mm/shadow/private.h
--- a/xen/arch/x86/mm/shadow/private.h
+++ b/xen/arch/x86/mm/shadow/private.h
@@ -30,6 +30,7 @@
#include <xen/domain_page.h>
#include <asm/x86_emulate.h>
#include <asm/hvm/support.h>
+#include <asm/atomic.h>
#include "../mm-locks.h"
@@ -815,6 +816,12 @@ static inline unsigned long vtlb_lookup(
}
#endif /* (SHADOW_OPTIMIZATIONS & SHOPT_VIRTUAL_TLB) */
+static inline int __check_page_no_refs(struct page_info *page)
+{
+ unsigned long __count = read_atomic(&page->count_info);
+ return ( (__count & PGC_count_mask) ==
+ ((__count & PGC_allocated) ? 1 : 0) );
+}
#endif /* _XEN_SHADOW_PRIVATE_H */
next prev parent reply other threads:[~2011-11-29 20:21 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-29 20:21 [PATCH 0 of 9] MM Bug fixes Andres Lagar-Cavilla
2011-11-29 20:21 ` [PATCH 1 of 9] Tools: When passing no bitmap for the shadow log dirty bitmap clean up, we should not get EFAULT Andres Lagar-Cavilla
2011-11-30 14:39 ` Ian Jackson
2011-11-29 20:21 ` Andres Lagar-Cavilla [this message]
2011-11-29 20:21 ` [PATCH 3 of 9] x86/mm: Don't lose track of the log dirty bitmap Andres Lagar-Cavilla
2011-11-29 20:21 ` [PATCH 4 of 9] x86: Add conversion from a xen map to an mfn Andres Lagar-Cavilla
2011-11-30 10:06 ` Jan Beulich
2011-11-29 20:21 ` [PATCH 5 of 9] x86/mm: Ensure maps used by nested hvm code cannot be paged out Andres Lagar-Cavilla
2011-11-30 10:10 ` Jan Beulich
2011-12-01 14:27 ` Tim Deegan
2011-12-01 14:29 ` Andres Lagar-Cavilla
2011-12-01 14:36 ` Tim Deegan
2011-11-29 20:21 ` [PATCH 6 of 9] x86/mm: Rework stale p2m auditing Andres Lagar-Cavilla
2011-12-02 8:28 ` Jan Beulich
2011-12-02 10:33 ` [PATCH] " Tim Deegan
2011-12-02 11:12 ` Jan Beulich
2011-11-29 20:21 ` [PATCH 7 of 9] Tools: Add libxc wrapper for p2m audit domctl Andres Lagar-Cavilla
2011-11-30 14:43 ` Ian Jackson
2011-11-29 20:21 ` [PATCH 8 of 9] x86/mm: Fix checks during foreign mapping of paged pages Andres Lagar-Cavilla
2011-11-30 12:46 ` Olaf Hering
2011-11-30 13:38 ` Olaf Hering
2011-11-30 15:02 ` Andres Lagar-Cavilla
2011-11-30 15:08 ` Olaf Hering
2011-11-29 20:21 ` [PATCH 9 of 9] x86/mm: Allow pages typed as log dirty to also be shared Andres Lagar-Cavilla
2011-12-01 15:09 ` [PATCH 0 of 9] MM Bug fixes Tim Deegan
2011-12-01 15:25 ` Andres 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=1b241f9841675a8aaa55.1322598099@xdev.gridcentric.ca \
--to=andres@lagarcavilla.org \
--cc=JBeulich@suse.com \
--cc=adin@gridcentric.ca \
--cc=andres@gridcentric.ca \
--cc=ian.campbell@citrix.com \
--cc=ian.jackson@citrix.com \
--cc=keir.xen@gmail.com \
--cc=tim@xen.org \
--cc=xen-devel@lists.xensource.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 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.