Skip to contentSkip to conversation

makedumpfile: support _count -> _refcount rename in struct page

PATCH Superseded Vitaly Kuznetsov 3 participants 5 messages Jun 16, 2016 – Jun 17, 2016

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 makedumpfile: support _count -> _refcount rename in struct page

_count member was renamed to _refcount in linux commit commit 0139aa7b7fa12 ("mm: rename _count, field of the struct page, to _refcount") and this broke makedumpfile. The reason for making the change was to find all users accessing it directly and not through the recommended API. I tried suggesting to revert the change but failed, I see no other choice than to start supporting both _count and _refcount in makedumpfile.

---
- 'crash' tool is now broken as well.

---
 makedumpfile.c | 18 +++++++++++++++++-
 makedumpfile.h |  1 +
 2 files changed, 18 insertions(+), 1 deletion(-)
makedumpfile.c +17 -1
index 853b999..96dfe39 100644
@@ -1580,6 +1580,13 @@ get_structure_info(void)
 	SIZE_INIT(page, "page");
 	OFFSET_INIT(page.flags, "page", "flags");
 	OFFSET_INIT(page._count, "page", "_count");
+	if (OFFSET(page._count) == NOT_FOUND_STRUCTURE) {
+		info->flag_refcount = TRUE;
+		OFFSET_INIT(page._count, "page", "_refcount");
+	} else {
+		info->flag_refcount = FALSE;
+	}
+
 	OFFSET_INIT(page.mapping, "page", "mapping");
 	OFFSET_INIT(page._mapcount, "page", "_mapcount");
 	OFFSET_INIT(page.private, "page", "private");
@@ -2151,7 +2158,10 @@ write_vmcoreinfo_data(void)
 	 * write the member offset of 1st kernel
 	 */
 	WRITE_MEMBER_OFFSET("page.flags", page.flags);
-	WRITE_MEMBER_OFFSET("page._count", page._count);
+	if (info->flag_refcount)
+		WRITE_MEMBER_OFFSET("page._refcount", page._count);
+	else
+		WRITE_MEMBER_OFFSET("page._count", page._count);
 	WRITE_MEMBER_OFFSET("page.mapping", page.mapping);
 	WRITE_MEMBER_OFFSET("page.lru", page.lru);
 	WRITE_MEMBER_OFFSET("page._mapcount", page._mapcount);
@@ -2492,6 +2502,12 @@ read_vmcoreinfo(void)
 
 	READ_MEMBER_OFFSET("page.flags", page.flags);
 	READ_MEMBER_OFFSET("page._count", page._count);
+	if (OFFSET(page._count) == NOT_FOUND_STRUCTURE) {
+		info->flag_refcount = TRUE;
+		READ_MEMBER_OFFSET("page._refcount", page._count);
+	} else {
+		info->flag_refcount = FALSE;
+	}
 	READ_MEMBER_OFFSET("page.mapping", page.mapping);
 	READ_MEMBER_OFFSET("page.lru", page.lru);
 	READ_MEMBER_OFFSET("page._mapcount", page._mapcount);
makedumpfile.h +1 -0
index 251d4bf..3742389 100644
@@ -1100,6 +1100,7 @@ struct DumpInfo {
 	int		flag_nospace;	     /* the flag of "No space on device" error */
 	int		flag_vmemmap;        /* kernel supports vmemmap address space */
 	int		flag_excludevm;      /* -e - excluding unused vmemmap pages */
+	int		flag_refcount;       /* _count is renamed to _refcount */
 	unsigned long	vaddr_for_vtop;      /* virtual address for debugging */
 	long		page_size;           /* size of page */
 	long		page_shift;
Signature · 7 lines
2.5.5


_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
#1 lore raw

----- Original Message -----

Quoted 10 lines

_count member was renamed to _refcount in linux commit commit 0139aa7b7fa12 ("mm: rename _count, field of the struct page, to _refcount") and this broke makedumpfile. The reason for making the change was to find all users accessing it directly and not through the recommended API. I tried suggesting to revert the change but failed, I see no other choice than to start supporting both _count and _refcount in makedumpfile.

---
- 'crash' tool is now broken as well.

FYI, crash was fixed upstream a few weeks ago:

commit 8ceb1ac628bf6a0a7f0bbfff030ec93081bca4cd
Author: Dave Anderson <[email protected]>
Date: Mon May 23 11:23:01 2016 -0400

Fix for Linux commit 0139aa7b7fa12ceef095d99dc36606a5b10ab83a, which renamed the page._count member to page._refcount. Without the patch, certain "kmem" commands fail with the "kmem: invalid structure member
offset: page_count".
([email protected])

Dave

Quoted 61 lines
---
 makedumpfile.c | 18 +++++++++++++++++-
 makedumpfile.h |  1 +
 2 files changed, 18 insertions(+), 1 deletion(-)
makedumpfile.c +17 -1
index 853b999..96dfe39 100644
@@ -1580,6 +1580,13 @@ get_structure_info(void)
 	SIZE_INIT(page, "page");
 	OFFSET_INIT(page.flags, "page", "flags");
 	OFFSET_INIT(page._count, "page", "_count");
+	if (OFFSET(page._count) == NOT_FOUND_STRUCTURE) {
+		info->flag_refcount = TRUE;
+		OFFSET_INIT(page._count, "page", "_refcount");
+	} else {
+		info->flag_refcount = FALSE;
+	}
+
 	OFFSET_INIT(page.mapping, "page", "mapping");
 	OFFSET_INIT(page._mapcount, "page", "_mapcount");
 	OFFSET_INIT(page.private, "page", "private");
@@ -2151,7 +2158,10 @@ write_vmcoreinfo_data(void)
 	 * write the member offset of 1st kernel
 	 */
 	WRITE_MEMBER_OFFSET("page.flags", page.flags);
-	WRITE_MEMBER_OFFSET("page._count", page._count);
+	if (info->flag_refcount)
+		WRITE_MEMBER_OFFSET("page._refcount", page._count);
+	else
+		WRITE_MEMBER_OFFSET("page._count", page._count);
 	WRITE_MEMBER_OFFSET("page.mapping", page.mapping);
 	WRITE_MEMBER_OFFSET("page.lru", page.lru);
 	WRITE_MEMBER_OFFSET("page._mapcount", page._mapcount);
@@ -2492,6 +2502,12 @@ read_vmcoreinfo(void)
 
 	READ_MEMBER_OFFSET("page.flags", page.flags);
 	READ_MEMBER_OFFSET("page._count", page._count);
+	if (OFFSET(page._count) == NOT_FOUND_STRUCTURE) {
+		info->flag_refcount = TRUE;
+		READ_MEMBER_OFFSET("page._refcount", page._count);
+	} else {
+		info->flag_refcount = FALSE;
+	}
 	READ_MEMBER_OFFSET("page.mapping", page.mapping);
 	READ_MEMBER_OFFSET("page.lru", page.lru);
 	READ_MEMBER_OFFSET("page._mapcount", page._mapcount);
makedumpfile.h +1 -1
index 251d4bf..3742389 100644
@@ -1100,6 +1100,7 @@ struct DumpInfo {
 	int		flag_nospace;	     /* the flag of "No space on device" error */
 	int		flag_vmemmap;        /* kernel supports vmemmap address space */
 	int		flag_excludevm;      /* -e - excluding unused vmemmap pages */
+	int		flag_refcount;       /* _count is renamed to _refcount */
 	unsigned long	vaddr_for_vtop;      /* virtual address for debugging */
 	long		page_size;           /* size of page */
 	long		page_shift;
--
Quoted 3 lines

2.5.5

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#2 lore raw
Quoted 18 lines · Dave Anderson

----- Original Message -----

Quoted 10 lines

_count member was renamed to _refcount in linux commit commit 0139aa7b7fa12 ("mm: rename _count, field of the struct page, to _refcount") and this broke makedumpfile. The reason for making the change was to find all users accessing it directly and not through the recommended API. I tried suggesting to revert the change but failed, I see no other choice than to start supporting both _count and _refcount in makedumpfile.

---
- 'crash' tool is now broken as well.

FYI, crash was fixed upstream a few weeks ago:

commit 8ceb1ac628bf6a0a7f0bbfff030ec93081bca4cd
Author: Dave Anderson <[email protected]>
Date: Mon May 23 11:23:01 2016 -0400

Quoted 5 lines

Fix for Linux commit 0139aa7b7fa12ceef095d99dc36606a5b10ab83a, which renamed the page._count member to page._refcount. Without the patch, certain "kmem" commands fail with the "kmem: invalid structure member
offset: page_count".
([email protected])

Missed that, thanks for the heads up!

Signature · 6 lines
  Vitaly

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
#3 lore raw
In reply to Vitaly Kuznetsov

Hello Vitaly,

Quoted 8 lines

_count member was renamed to _refcount in linux commit commit 0139aa7b7fa12 ("mm: rename _count, field of the struct page, to _refcount") and this broke makedumpfile. The reason for making the change was to find all users accessing it directly and not through the recommended API. I tried suggesting to revert the change but failed, I see no other choice than to start supporting both _count and _refcount in makedumpfile.

Thanks for your report and fixing it.

Quoted 12 lines

---
- 'crash' tool is now broken as well.
---
makedumpfile.c | 18 +++++++++++++++++-
makedumpfile.h | 1 +

2 files changed, 18 insertions(+), 1 deletion(-)
makedumpfile.c +0 -0
index 853b999..96dfe39 100644

makedumpfile.c get_structure_info(void) · line 1589

Quoted 10 lines
makedumpfile.c +7 -0
@@ -1580,6 +1580,13 @@ get_structure_info(void)
 	SIZE_INIT(page, "page");
 	OFFSET_INIT(page.flags, "page", "flags");
 	OFFSET_INIT(page._count, "page", "_count");
+	if (OFFSET(page._count) == NOT_FOUND_STRUCTURE) {
+		info->flag_refcount = TRUE;
+		OFFSET_INIT(page._count, "page", "_refcount");
+	} else {
+		info->flag_refcount = FALSE;
+	}
+

I prefer to check the new symbol name first since it's likely from now on.

Quoted 16 lines
makedumpfile.c +4 -1
 	OFFSET_INIT(page.mapping, "page", "mapping");
 	OFFSET_INIT(page._mapcount, "page", "_mapcount");
 	OFFSET_INIT(page.private, "page", "private");
@@ -2151,7 +2158,10 @@ write_vmcoreinfo_data(void)
 	 * write the member offset of 1st kernel
 	 */
 	WRITE_MEMBER_OFFSET("page.flags", page.flags);
-	WRITE_MEMBER_OFFSET("page._count", page._count);
+	if (info->flag_refcount)
+		WRITE_MEMBER_OFFSET("page._refcount", page._count);
+	else
+		WRITE_MEMBER_OFFSET("page._count", page._count);
 	WRITE_MEMBER_OFFSET("page.mapping", page.mapping);
 	WRITE_MEMBER_OFFSET("page.lru", page.lru);
 	WRITE_MEMBER_OFFSET("page._mapcount", page._mapcount);

makedumpfile.c read_vmcoreinfo(void) · line 2510

Quoted 9 lines
makedumpfile.c +6 -0
@@ -2492,6 +2502,12 @@ read_vmcoreinfo(void)
 
 	READ_MEMBER_OFFSET("page.flags", page.flags);
 	READ_MEMBER_OFFSET("page._count", page._count);
+	if (OFFSET(page._count) == NOT_FOUND_STRUCTURE) {
+		info->flag_refcount = TRUE;
+		READ_MEMBER_OFFSET("page._refcount", page._count);
+	} else {
+		info->flag_refcount = FALSE;
+	}

same as OFFSET_INIT.

Thanks,
Atsushi Kumagai

Quoted 16 lines
makedumpfile.c +0 -0
 	READ_MEMBER_OFFSET("page.mapping", page.mapping);
 	READ_MEMBER_OFFSET("page.lru", page.lru);
 	READ_MEMBER_OFFSET("page._mapcount", page._mapcount);
makedumpfile.h +1 -1
index 251d4bf..3742389 100644
@@ -1100,6 +1100,7 @@ struct DumpInfo {
 	int		flag_nospace;	     /* the flag of "No space on device" error */
 	int		flag_vmemmap;        /* kernel supports vmemmap address space */
 	int		flag_excludevm;      /* -e - excluding unused vmemmap pages */
+	int		flag_refcount;       /* _count is renamed to _refcount */
 	unsigned long	vaddr_for_vtop;      /* virtual address for debugging */
 	long		page_size;           /* size of page */
 	long		page_shift;
--
Quoted 1 line

2.5.5

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#4 lore raw
Quoted 30 lines · Atsushi Kumagai

Hello Vitaly,

Quoted 8 lines

_count member was renamed to _refcount in linux commit commit 0139aa7b7fa12 ("mm: rename _count, field of the struct page, to _refcount") and this broke makedumpfile. The reason for making the change was to find all users accessing it directly and not through the recommended API. I tried suggesting to revert the change but failed, I see no other choice than to start supporting both _count and _refcount in makedumpfile.

Thanks for your report and fixing it.

Quoted 17 lines

---
- 'crash' tool is now broken as well.
---
makedumpfile.c | 18 +++++++++++++++++-
makedumpfile.h | 1 +

2 files changed, 18 insertions(+), 1 deletion(-)
makedumpfile.c +2 -0
index 853b999..96dfe39 100644
@@ -1580,6 +1580,13 @@ get_structure_info(void)
 	SIZE_INIT(page, "page");
 	OFFSET_INIT(page.flags, "page", "flags");
 	OFFSET_INIT(page._count, "page", "_count");
+	if (OFFSET(page._count) == NOT_FOUND_STRUCTURE) {
+		info->flag_refcount = TRUE;
Quoted 9 lines

makedumpfile.c get_structure_info(void) · line 1589

Quoted 5 lines
makedumpfile.c +5 -0
+		OFFSET_INIT(page._count, "page", "_refcount");
+	} else {
+		info->flag_refcount = FALSE;
+	}
+

I prefer to check the new symbol name first since it's likely from now on.

In that case I suggest we also rename '_count' filed to '_refcount' and 'flag_refcount' to 'flag_count' to support this default. I'll send v2.

Quoted 48 lines
Quoted 16 lines
makedumpfile.c +4 -1
 	OFFSET_INIT(page.mapping, "page", "mapping");
 	OFFSET_INIT(page._mapcount, "page", "_mapcount");
 	OFFSET_INIT(page.private, "page", "private");
@@ -2151,7 +2158,10 @@ write_vmcoreinfo_data(void)
 	 * write the member offset of 1st kernel
 	 */
 	WRITE_MEMBER_OFFSET("page.flags", page.flags);
-	WRITE_MEMBER_OFFSET("page._count", page._count);
+	if (info->flag_refcount)
+		WRITE_MEMBER_OFFSET("page._refcount", page._count);
+	else
+		WRITE_MEMBER_OFFSET("page._count", page._count);
 	WRITE_MEMBER_OFFSET("page.mapping", page.mapping);
 	WRITE_MEMBER_OFFSET("page.lru", page.lru);
 	WRITE_MEMBER_OFFSET("page._mapcount", page._mapcount);

makedumpfile.c read_vmcoreinfo(void) · line 2510

Quoted 9 lines
makedumpfile.c +6 -0
@@ -2492,6 +2502,12 @@ read_vmcoreinfo(void)
 
 	READ_MEMBER_OFFSET("page.flags", page.flags);
 	READ_MEMBER_OFFSET("page._count", page._count);
+	if (OFFSET(page._count) == NOT_FOUND_STRUCTURE) {
+		info->flag_refcount = TRUE;
+		READ_MEMBER_OFFSET("page._refcount", page._count);
+	} else {
+		info->flag_refcount = FALSE;
+	}

same as OFFSET_INIT.

Thanks,
Atsushi Kumagai

Quoted 17 lines
makedumpfile.c +0 -0
 	READ_MEMBER_OFFSET("page.mapping", page.mapping);
 	READ_MEMBER_OFFSET("page.lru", page.lru);
 	READ_MEMBER_OFFSET("page._mapcount", page._mapcount);
makedumpfile.h +1 -1
index 251d4bf..3742389 100644
@@ -1100,6 +1100,7 @@ struct DumpInfo {
 	int		flag_nospace;	     /* the flag of "No space on device" error */
 	int		flag_vmemmap;        /* kernel supports vmemmap address space */
 	int		flag_excludevm;      /* -e - excluding unused vmemmap pages */
+	int		flag_refcount;       /* _count is renamed to _refcount */
 	unsigned long	vaddr_for_vtop;      /* virtual address for debugging */
 	long		page_size;           /* size of page */
 	long		page_shift;
--

2.5.5

Signature · 6 lines
  Vitaly

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec