* [patch 8/9] Add support for filtering out user pages under Xen4
2012-08-21 8:44 [patch 0/9] Support Xen versions up to xen-4.1 Petr Tesarik
@ 2012-08-21 8:44 ` Petr Tesarik
0 siblings, 0 replies; 2+ messages in thread
From: Petr Tesarik @ 2012-08-21 8:44 UTC (permalink / raw)
To: kexec; +Cc: Petr Tesarik, Norbert Trapp
[-- Attachment #1: 08-xen4-exclude-user.patch --]
[-- Type: text/plain, Size: 5014 bytes --]
In Xen-4.0+, usage of a page must be determined from its PGC_xxx
flags, which are stored in the highest bits of the _count field
of struct page_info.
Let's keep the original function for Xen3 only and add a new
function for walking the pages under Xen4. This avoids adding many
new conditionals to the inner loop and also makes the logic easier
to follow for all Xen versions.
Signed-off-by: Norbert Trapp <norbert.trapp@ts.fujitsu.com>
Signed-off-by: Petr Tesarik <ptesarik@suse.cz>
---
makedumpfile.c | 103 +++++++++++++++++++++++++++++++++++++++++++++++++++++----
makedumpfile.h | 25 +++++++++++++
2 files changed, 122 insertions(+), 6 deletions(-)
--- a/makedumpfile.h
+++ b/makedumpfile.h
@@ -78,6 +78,31 @@ int get_mem_type(void);
#define LSEEKED_PDATA (3)
/*
+ * Xen page flags
+ */
+#define BITS_PER_BYTE (8)
+#define BITS_PER_LONG (BITS_PER_BYTE * sizeof(long))
+#define PG_shift(idx) (BITS_PER_LONG - (idx))
+#define PG_mask(x, idx) (x ## UL << PG_shift(idx))
+ /* Cleared when the owning guest 'frees' this page. */
+#define PGC_allocated PG_mask(1, 1)
+ /* Page is Xen heap? */
+#define PGC_xen_heap PG_mask(1, 2)
+ /* Page is broken? */
+#define PGC_broken PG_mask(1, 7)
+ /* Mutually-exclusive page states: { inuse, offlining, offlined, free }. */
+#define PGC_state PG_mask(3, 9)
+#define PGC_state_inuse PG_mask(0, 9)
+#define PGC_state_offlining PG_mask(1, 9)
+#define PGC_state_offlined PG_mask(2, 9)
+#define PGC_state_free PG_mask(3, 9)
+#define page_state_is(ci, st) (((ci)&PGC_state) == PGC_state_##st)
+
+ /* Count of references to this frame. */
+#define PGC_count_width PG_shift(9)
+#define PGC_count_mask ((1UL<<PGC_count_width)-1)
+
+/*
* Memory flags
*/
#define MEMORY_PAGETABLE_4L (1 << 0)
--- a/makedumpfile.c
+++ b/makedumpfile.c
@@ -5719,7 +5719,7 @@ is_select_domain(unsigned int id)
}
int
-exclude_xen_user_domain(void)
+exclude_xen3_user_domain(void)
{
int i;
unsigned int count_info, _domain;
@@ -5728,9 +5728,6 @@ exclude_xen_user_domain(void)
unsigned long long phys_start, phys_end;
unsigned long long pfn, pfn_end;
unsigned long long j, size;
- struct timeval tv_start;
-
- gettimeofday(&tv_start, NULL);
/*
* NOTE: the first half of bitmap is not used for Xen extraction
@@ -5781,13 +5778,107 @@ exclude_xen_user_domain(void)
}
}
+ return TRUE;
+}
+
+int
+exclude_xen4_user_domain(void)
+{
+ int i;
+ unsigned long count_info;
+ unsigned int _domain;
+ unsigned int num_pt_loads = get_num_pt_loads();
+ unsigned long page_info_addr;
+ unsigned long long phys_start, phys_end;
+ unsigned long long pfn, pfn_end;
+ unsigned long long j, size;
+
+ /*
+ * NOTE: the first half of bitmap is not used for Xen extraction
+ */
+ for (i = 0; get_pt_load(i, &phys_start, &phys_end, NULL, NULL); i++) {
+
+ print_progress(PROGRESS_XEN_DOMAIN, i, num_pt_loads);
+
+ pfn = paddr_to_pfn(phys_start);
+ pfn_end = paddr_to_pfn(phys_end);
+ size = pfn_end - pfn;
+
+ for (j = 0; pfn < pfn_end; pfn++, j++) {
+ print_progress(PROGRESS_XEN_DOMAIN, j + (size * i),
+ size * num_pt_loads);
+
+ page_info_addr = info->frame_table_vaddr + pfn * SIZE(page_info);
+ if (!readmem(VADDR_XEN,
+ page_info_addr + OFFSET(page_info.count_info),
+ &count_info, sizeof(count_info))) {
+ clear_bit_on_2nd_bitmap(pfn);
+ continue; /* page_info may not exist */
+ }
+
+ /* delete free and offlined pages
+ * Note: Broken pages also get offlined
+ */
+ if (page_state_is(count_info, free) ||
+ page_state_is(count_info, offlined)) {
+ clear_bit_on_2nd_bitmap(pfn);
+ continue;
+ }
+
+ /* always keep Xen heap pages */
+ if (count_info & PGC_xen_heap)
+ continue;
+
+ /* delete pages not allocated to any domain */
+ if (! (count_info & PGC_allocated)) {
+ clear_bit_on_2nd_bitmap(pfn);
+ continue;
+ }
+
+ if (!readmem(VADDR_XEN,
+ page_info_addr + OFFSET(page_info._domain),
+ &_domain, sizeof(_domain))) {
+ ERRMSG("Can't get page_info._domain.\n");
+ return FALSE;
+ }
+
+ /*
+ * keep:
+ * - anonymous (_domain == 0), or
+ * - selected domain page
+ */
+ if (_domain == 0)
+ continue;
+ if (is_select_domain(_domain))
+ continue;
+ clear_bit_on_2nd_bitmap(pfn);
+ }
+ }
+
+ return TRUE;
+}
+
+int
+exclude_xen_user_domain(void)
+{
+ struct timeval tv_start;
+ int ret;
+
+ gettimeofday(&tv_start, NULL);
+
+ if (info->xen_crash_info.com &&
+ info->xen_crash_info.com->xen_major_version >= 4)
+ ret = exclude_xen4_user_domain();
+ else
+ ret = exclude_xen3_user_domain();
+
/*
* print [100 %]
*/
- print_progress(PROGRESS_XEN_DOMAIN, num_pt_loads, num_pt_loads);
+ print_progress(PROGRESS_XEN_DOMAIN, 1, 1);
print_execution_time(PROGRESS_XEN_DOMAIN, &tv_start);
- return TRUE;
+ return ret;
}
int
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [patch 8/9] Add support for filtering out user pages under Xen4
[not found] ` <201208231410.21324.ptesarik@suse.cz>
@ 2012-08-23 15:49 ` Petr Tesarik
0 siblings, 0 replies; 2+ messages in thread
From: Petr Tesarik @ 2012-08-23 15:49 UTC (permalink / raw)
To: Trapp, Norbert; +Cc: kexec
Dne Čt 23. srpna 2012 14:10:21 jste napsal(a):
> Dne Čt 23. srpna 2012 12:00:41 jste napsal(a):
> > Hello Petr,
> >
> > Actually we didn't need to patch the crash utility for the SLES11 SP1
> > version we use. When I call the crash utility with the vmcore.d0 argument
> >
> > that your current makedumpfile version produces, I see:
> > WARNING: crashing_cpu not found.
> > crash: invalid kernel virtual address: 0 type: "opt_sched,"
> >
> > crash: cannot read opt_sched,.
Hello Norbert once again,
I've investigated the logic once more, and we should probably rethink what
we're filtering out for "-X". The manual page says:
-X Exclude all the user domain pages from Xen kdump's VMCORE, and
extracts the part of xen and domain-0.
So, depending on how I read it, it should either:
a. throw away anything but dom_xen, dom_io and dom0, or
b. keep everything except domU
I vote for a, because it should give the smallest dump. Now, all such pages
will have:
1. PGC_allocated (it is allocated to a domain)
2. one of the 3 known values for _domain
All else only adds unnecessary complexity. But even that does not cover all
cases. For example the "opt_sched" (actually ops.opt_name) is stored at
physical address 0x3fa38b28 (PFN 0x3fa38), but frame_table[0x3fa38] is:
struct page_info {
{
list = {
next = 0,
prev = 0
},
up = 0,
shr_handle = 0
},
count_info = 0,
u = {
inuse = {
type_info = 0
},
sh = {
type = 0,
pinned = 0,
count = 0
},
free = {
need_tlbflush = 0 '\000'
}
},
v = {
inuse = {
_domain = 0
},
sh = {
back = 0
},
free = {
order = 0
}
},
{
tlbflush_timestamp = 0,
{
nr_validated_ptes = 0,
partial_pte = 0 '\000'
},
shadow_flags = 0,
next_shadow = 0
}
}
This looks pretty uninitialized to me. Your patch keeps this page, because you
don't filter out anything that has PGC_allocated==0 and PGC_state_inuse
(numerically 0), but I'm not sure that's right.
I'll try asking on the Xen mailing list about the intended hierarchy of the
various PGC_xxx flags.
Petr Tesarik
SUSE Linux
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-08-23 15:49 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <0E9227E8EFCFF54EA493F6C0399C015D3996033588@ABGEX70E.FSC.NET>
[not found] ` <0E9227E8EFCFF54EA493F6C0399C015D39960338DA@ABGEX70E.FSC.NET>
[not found] ` <201208231410.21324.ptesarik@suse.cz>
2012-08-23 15:49 ` [patch 8/9] Add support for filtering out user pages under Xen4 Petr Tesarik
2012-08-21 8:44 [patch 0/9] Support Xen versions up to xen-4.1 Petr Tesarik
2012-08-21 8:44 ` [patch 8/9] Add support for filtering out user pages under Xen4 Petr Tesarik
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox