kfan / rpms / kexec-tools

Forked from rpms/kexec-tools 3 years ago
Clone
Pratyush Anand 5d1e6f1
From 2c21d4656e8d3c2af2b1e14809d076941ae69e96 Mon Sep 17 00:00:00 2001
Pratyush Anand 5d1e6f1
Message-Id: <2c21d4656e8d3c2af2b1e14809d076941ae69e96.1468205827.git.panand@redhat.com>
Pratyush Anand 5d1e6f1
From: Vitaly Kuznetsov <vkuznets@redhat.com>
Pratyush Anand 5d1e6f1
Date: Fri, 17 Jun 2016 18:41:26 +0900
Pratyush Anand 5d1e6f1
Subject: [PATCH] [PATCH v2] Support _count -> _refcount rename in struct page
Pratyush Anand 5d1e6f1
Pratyush Anand 5d1e6f1
_count member was renamed to _refcount in linux commit 0139aa7b7fa12
Pratyush Anand 5d1e6f1
("mm: rename _count, field of the struct page, to _refcount") and this
Pratyush Anand 5d1e6f1
broke makedumpfile. The reason for making the change was to find all users
Pratyush Anand 5d1e6f1
accessing it directly and not through the recommended API. I tried
Pratyush Anand 5d1e6f1
suggesting to revert the change but failed, I see no other choice than to
Pratyush Anand 5d1e6f1
start supporting both _count and _refcount in makedumpfile.
Pratyush Anand 5d1e6f1
Pratyush Anand 5d1e6f1
Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Pratyush Anand 5d1e6f1
---
Pratyush Anand 5d1e6f1
 makedumpfile-1.6.0/makedumpfile.c | 26 +++++++++++++++++++++-----
Pratyush Anand 5d1e6f1
 makedumpfile-1.6.0/makedumpfile.h |  3 ++-
Pratyush Anand 5d1e6f1
 2 files changed, 23 insertions(+), 6 deletions(-)
Pratyush Anand 5d1e6f1
Pratyush Anand 5d1e6f1
diff --git a/makedumpfile-1.6.0/makedumpfile.c b/makedumpfile-1.6.0/makedumpfile.c
Pratyush Anand 5d1e6f1
index 853b99951706..fd884d3796be 100644
Pratyush Anand 5d1e6f1
--- a/makedumpfile-1.6.0/makedumpfile.c
Pratyush Anand 5d1e6f1
+++ b/makedumpfile-1.6.0/makedumpfile.c
Pratyush Anand 5d1e6f1
@@ -1579,7 +1579,14 @@ get_structure_info(void)
Pratyush Anand 5d1e6f1
 	 */
Pratyush Anand 5d1e6f1
 	SIZE_INIT(page, "page");
Pratyush Anand 5d1e6f1
 	OFFSET_INIT(page.flags, "page", "flags");
Pratyush Anand 5d1e6f1
-	OFFSET_INIT(page._count, "page", "_count");
Pratyush Anand 5d1e6f1
+	OFFSET_INIT(page._refcount, "page", "_refcount");
Pratyush Anand 5d1e6f1
+	if (OFFSET(page._refcount) == NOT_FOUND_STRUCTURE) {
Pratyush Anand 5d1e6f1
+		info->flag_use_count = TRUE;
Pratyush Anand 5d1e6f1
+		OFFSET_INIT(page._refcount, "page", "_count");
Pratyush Anand 5d1e6f1
+	} else {
Pratyush Anand 5d1e6f1
+		info->flag_use_count = FALSE;
Pratyush Anand 5d1e6f1
+	}
Pratyush Anand 5d1e6f1
+
Pratyush Anand 5d1e6f1
 	OFFSET_INIT(page.mapping, "page", "mapping");
Pratyush Anand 5d1e6f1
 	OFFSET_INIT(page._mapcount, "page", "_mapcount");
Pratyush Anand 5d1e6f1
 	OFFSET_INIT(page.private, "page", "private");
Pratyush Anand 5d1e6f1
@@ -2044,7 +2051,7 @@ get_mem_type(void)
Pratyush Anand 5d1e6f1
 
Pratyush Anand 5d1e6f1
 	if ((SIZE(page) == NOT_FOUND_STRUCTURE)
Pratyush Anand 5d1e6f1
 	    || (OFFSET(page.flags) == NOT_FOUND_STRUCTURE)
Pratyush Anand 5d1e6f1
-	    || (OFFSET(page._count) == NOT_FOUND_STRUCTURE)
Pratyush Anand 5d1e6f1
+	    || (OFFSET(page._refcount) == NOT_FOUND_STRUCTURE)
Pratyush Anand 5d1e6f1
 	    || (OFFSET(page.mapping) == NOT_FOUND_STRUCTURE)) {
Pratyush Anand 5d1e6f1
 		ret = NOT_FOUND_MEMTYPE;
Pratyush Anand 5d1e6f1
 	} else if ((((SYMBOL(node_data) != NOT_FOUND_SYMBOL)
Pratyush Anand 5d1e6f1
@@ -2151,7 +2158,10 @@ write_vmcoreinfo_data(void)
Pratyush Anand 5d1e6f1
 	 * write the member offset of 1st kernel
Pratyush Anand 5d1e6f1
 	 */
Pratyush Anand 5d1e6f1
 	WRITE_MEMBER_OFFSET("page.flags", page.flags);
Pratyush Anand 5d1e6f1
-	WRITE_MEMBER_OFFSET("page._count", page._count);
Pratyush Anand 5d1e6f1
+	if (info->flag_use_count)
Pratyush Anand 5d1e6f1
+		WRITE_MEMBER_OFFSET("page._count", page._refcount);
Pratyush Anand 5d1e6f1
+	else
Pratyush Anand 5d1e6f1
+		WRITE_MEMBER_OFFSET("page._refcount", page._refcount);
Pratyush Anand 5d1e6f1
 	WRITE_MEMBER_OFFSET("page.mapping", page.mapping);
Pratyush Anand 5d1e6f1
 	WRITE_MEMBER_OFFSET("page.lru", page.lru);
Pratyush Anand 5d1e6f1
 	WRITE_MEMBER_OFFSET("page._mapcount", page._mapcount);
Pratyush Anand 5d1e6f1
@@ -2491,7 +2501,13 @@ read_vmcoreinfo(void)
Pratyush Anand 5d1e6f1
 
Pratyush Anand 5d1e6f1
 
Pratyush Anand 5d1e6f1
 	READ_MEMBER_OFFSET("page.flags", page.flags);
Pratyush Anand 5d1e6f1
-	READ_MEMBER_OFFSET("page._count", page._count);
Pratyush Anand 5d1e6f1
+	READ_MEMBER_OFFSET("page._refcount", page._refcount);
Pratyush Anand 5d1e6f1
+	if (OFFSET(page._refcount) == NOT_FOUND_STRUCTURE) {
Pratyush Anand 5d1e6f1
+		info->flag_use_count = TRUE;
Pratyush Anand 5d1e6f1
+		READ_MEMBER_OFFSET("page._count", page._refcount);
Pratyush Anand 5d1e6f1
+	} else {
Pratyush Anand 5d1e6f1
+		info->flag_use_count = FALSE;
Pratyush Anand 5d1e6f1
+	}
Pratyush Anand 5d1e6f1
 	READ_MEMBER_OFFSET("page.mapping", page.mapping);
Pratyush Anand 5d1e6f1
 	READ_MEMBER_OFFSET("page.lru", page.lru);
Pratyush Anand 5d1e6f1
 	READ_MEMBER_OFFSET("page._mapcount", page._mapcount);
Pratyush Anand 5d1e6f1
@@ -5615,7 +5631,7 @@ __exclude_unnecessary_pages(unsigned long mem_map,
Pratyush Anand 5d1e6f1
 		pcache  = page_cache + (index_pg * SIZE(page));
Pratyush Anand 5d1e6f1
 
Pratyush Anand 5d1e6f1
 		flags   = ULONG(pcache + OFFSET(page.flags));
Pratyush Anand 5d1e6f1
-		_count  = UINT(pcache + OFFSET(page._count));
Pratyush Anand 5d1e6f1
+		_count  = UINT(pcache + OFFSET(page._refcount));
Pratyush Anand 5d1e6f1
 		mapping = ULONG(pcache + OFFSET(page.mapping));
Pratyush Anand 5d1e6f1
 
Pratyush Anand 5d1e6f1
 		if (OFFSET(page.compound_order) != NOT_FOUND_STRUCTURE) {
Pratyush Anand 5d1e6f1
diff --git a/makedumpfile-1.6.0/makedumpfile.h b/makedumpfile-1.6.0/makedumpfile.h
Pratyush Anand 5d1e6f1
index 251d4bfac060..533e5b89f345 100644
Pratyush Anand 5d1e6f1
--- a/makedumpfile-1.6.0/makedumpfile.h
Pratyush Anand 5d1e6f1
+++ b/makedumpfile-1.6.0/makedumpfile.h
Pratyush Anand 5d1e6f1
@@ -1100,6 +1100,7 @@ struct DumpInfo {
Pratyush Anand 5d1e6f1
 	int		flag_nospace;	     /* the flag of "No space on device" error */
Pratyush Anand 5d1e6f1
 	int		flag_vmemmap;        /* kernel supports vmemmap address space */
Pratyush Anand 5d1e6f1
 	int		flag_excludevm;      /* -e - excluding unused vmemmap pages */
Pratyush Anand 5d1e6f1
+	int		flag_use_count;      /* _refcount is named _count in struct page */
Pratyush Anand 5d1e6f1
 	unsigned long	vaddr_for_vtop;      /* virtual address for debugging */
Pratyush Anand 5d1e6f1
 	long		page_size;           /* size of page */
Pratyush Anand 5d1e6f1
 	long		page_shift;
Pratyush Anand 5d1e6f1
@@ -1483,7 +1484,7 @@ struct size_table {
Pratyush Anand 5d1e6f1
 struct offset_table {
Pratyush Anand 5d1e6f1
 	struct page {
Pratyush Anand 5d1e6f1
 		long	flags;
Pratyush Anand 5d1e6f1
-		long	_count;
Pratyush Anand 5d1e6f1
+		long	_refcount;
Pratyush Anand 5d1e6f1
 		long	mapping;
Pratyush Anand 5d1e6f1
 		long	lru;
Pratyush Anand 5d1e6f1
 		long	_mapcount;
Pratyush Anand 5d1e6f1
-- 
Pratyush Anand 5d1e6f1
2.5.5
Pratyush Anand 5d1e6f1