From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from cantor2.suse.de ([195.135.220.15] helo=mx2.suse.de) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1T4w2h-0002Gs-CS for kexec@lists.infradead.org; Fri, 24 Aug 2012 15:43:28 +0000 Subject: [PATCHv3 8/9] Add support for filtering out user pages under Xen4 From: Petr Tesarik Date: Fri, 24 Aug 2012 17:43:23 +0200 MIME-Version: 1.0 Message-Id: <201208241743.23829.ptesarik@suse.cz> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: kexec-bounces@lists.infradead.org Errors-To: kexec-bounces+dwmw2=infradead.org@lists.infradead.org To: kexec@lists.infradead.org Cc: Norbert Trapp 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 Signed-off-by: Petr Tesarik --- makedumpfile.c | 102 +++++++++++++++++++++++++++++++++++++++++++++++++++++---- makedumpfile.h | 25 +++++++++++++ 2 files changed, 121 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<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 */ + } + + /* always keep Xen heap pages */ + if (count_info & PGC_xen_heap) + continue; + + /* delete free, offlined and broken pages */ + if (page_state_is(count_info, free) || + page_state_is(count_info, offlined) || + count_info & PGC_broken) { + clear_bit_on_2nd_bitmap(pfn); + continue; + } + + /* keep inuse pages not allocated to any domain + * this covers e.g. Xen static data + */ + if (! (count_info & PGC_allocated)) + continue; + + /* Need to check the domain + * keep: + * - anonymous (_domain == 0), or + * - selected domain page + */ + if (!readmem(VADDR_XEN, + page_info_addr + OFFSET(page_info._domain), + &_domain, sizeof(_domain))) { + ERRMSG("Can't get page_info._domain.\n"); + return FALSE; + } + + 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