Skip to contentSkip to conversation

makedumpfile: support _count -> _refcount rename in struct page

PATCH In review Vitaly Kuznetsov 3 participants 7 messages Jun 17, 2016 – Jun 22, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

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

_count member was renamed to _refcount in linux 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.

---
Changes since 'v1':
- Make '_refcount' the default [Atsushi Kumagai]

---
 makedumpfile.c | 26 +++++++++++++++++++++-----
 makedumpfile.h |  3 ++-
 2 files changed, 23 insertions(+), 6 deletions(-)
makedumpfile.c +21 -5
index 853b999..fd884d3 100644
@@ -1579,7 +1579,14 @@ get_structure_info(void)
 	 */
 	SIZE_INIT(page, "page");
 	OFFSET_INIT(page.flags, "page", "flags");
-	OFFSET_INIT(page._count, "page", "_count");
+	OFFSET_INIT(page._refcount, "page", "_refcount");
+	if (OFFSET(page._refcount) == NOT_FOUND_STRUCTURE) {
+		info->flag_use_count = TRUE;
+		OFFSET_INIT(page._refcount, "page", "_count");
+	} else {
+		info->flag_use_count = FALSE;
+	}
+
 	OFFSET_INIT(page.mapping, "page", "mapping");
 	OFFSET_INIT(page._mapcount, "page", "_mapcount");
 	OFFSET_INIT(page.private, "page", "private");
@@ -2044,7 +2051,7 @@ get_mem_type(void)
 
 	if ((SIZE(page) == NOT_FOUND_STRUCTURE)
 	    || (OFFSET(page.flags) == NOT_FOUND_STRUCTURE)
-	    || (OFFSET(page._count) == NOT_FOUND_STRUCTURE)
+	    || (OFFSET(page._refcount) == NOT_FOUND_STRUCTURE)
 	    || (OFFSET(page.mapping) == NOT_FOUND_STRUCTURE)) {
 		ret = NOT_FOUND_MEMTYPE;
 	} else if ((((SYMBOL(node_data) != NOT_FOUND_SYMBOL)
@@ -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_use_count)
+		WRITE_MEMBER_OFFSET("page._count", page._refcount);
+	else
+		WRITE_MEMBER_OFFSET("page._refcount", page._refcount);
 	WRITE_MEMBER_OFFSET("page.mapping", page.mapping);
 	WRITE_MEMBER_OFFSET("page.lru", page.lru);
 	WRITE_MEMBER_OFFSET("page._mapcount", page._mapcount);
@@ -2491,7 +2501,13 @@ read_vmcoreinfo(void)
 
 
 	READ_MEMBER_OFFSET("page.flags", page.flags);
-	READ_MEMBER_OFFSET("page._count", page._count);
+	READ_MEMBER_OFFSET("page._refcount", page._refcount);
+	if (OFFSET(page._refcount) == NOT_FOUND_STRUCTURE) {
+		info->flag_use_count = TRUE;
+		READ_MEMBER_OFFSET("page._count", page._refcount);
+	} else {
+		info->flag_use_count = FALSE;
+	}
 	READ_MEMBER_OFFSET("page.mapping", page.mapping);
 	READ_MEMBER_OFFSET("page.lru", page.lru);
 	READ_MEMBER_OFFSET("page._mapcount", page._mapcount);
@@ -5615,7 +5631,7 @@ __exclude_unnecessary_pages(unsigned long mem_map,
 		pcache  = page_cache + (index_pg * SIZE(page));
 
 		flags   = ULONG(pcache + OFFSET(page.flags));
-		_count  = UINT(pcache + OFFSET(page._count));
+		_count  = UINT(pcache + OFFSET(page._refcount));
 		mapping = ULONG(pcache + OFFSET(page.mapping));
 
 		if (OFFSET(page.compound_order) != NOT_FOUND_STRUCTURE) {
makedumpfile.h +2 -1
index 251d4bf..533e5b8 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_use_count;      /* _refcount is named _count in struct page */
 	unsigned long	vaddr_for_vtop;      /* virtual address for debugging */
 	long		page_size;           /* size of page */
 	long		page_shift;
@@ -1483,7 +1484,7 @@ struct size_table {
 struct offset_table {
 	struct page {
 		long	flags;
-		long	_count;
+		long	_refcount;
 		long	mapping;
 		long	lru;
 		long	_mapcount;
Signature · 7 lines
2.5.5


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

Hello Vitaly,

Quoted 11 lines

_count member was renamed to _refcount in linux 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.

---
Changes since 'v1':
- Make '_refcount' the default [Atsushi Kumagai]

Good fix, I'll merge this into v1.6.1.

Thanks,
Atsushi Kumagai

Quoted 92 lines

---
makedumpfile.c | 26 +++++++++++++++++++++-----
makedumpfile.h | 3 ++-

2 files changed, 23 insertions(+), 6 deletions(-)
makedumpfile.c +21 -5
index 853b999..fd884d3 100644
@@ -1579,7 +1579,14 @@ get_structure_info(void)
 	 */
 	SIZE_INIT(page, "page");
 	OFFSET_INIT(page.flags, "page", "flags");
-	OFFSET_INIT(page._count, "page", "_count");
+	OFFSET_INIT(page._refcount, "page", "_refcount");
+	if (OFFSET(page._refcount) == NOT_FOUND_STRUCTURE) {
+		info->flag_use_count = TRUE;
+		OFFSET_INIT(page._refcount, "page", "_count");
+	} else {
+		info->flag_use_count = FALSE;
+	}
+
 	OFFSET_INIT(page.mapping, "page", "mapping");
 	OFFSET_INIT(page._mapcount, "page", "_mapcount");
 	OFFSET_INIT(page.private, "page", "private");
@@ -2044,7 +2051,7 @@ get_mem_type(void)
 
 	if ((SIZE(page) == NOT_FOUND_STRUCTURE)
 	    || (OFFSET(page.flags) == NOT_FOUND_STRUCTURE)
-	    || (OFFSET(page._count) == NOT_FOUND_STRUCTURE)
+	    || (OFFSET(page._refcount) == NOT_FOUND_STRUCTURE)
 	    || (OFFSET(page.mapping) == NOT_FOUND_STRUCTURE)) {
 		ret = NOT_FOUND_MEMTYPE;
 	} else if ((((SYMBOL(node_data) != NOT_FOUND_SYMBOL)
@@ -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_use_count)
+		WRITE_MEMBER_OFFSET("page._count", page._refcount);
+	else
+		WRITE_MEMBER_OFFSET("page._refcount", page._refcount);
 	WRITE_MEMBER_OFFSET("page.mapping", page.mapping);
 	WRITE_MEMBER_OFFSET("page.lru", page.lru);
 	WRITE_MEMBER_OFFSET("page._mapcount", page._mapcount);
@@ -2491,7 +2501,13 @@ read_vmcoreinfo(void)
 
 
 	READ_MEMBER_OFFSET("page.flags", page.flags);
-	READ_MEMBER_OFFSET("page._count", page._count);
+	READ_MEMBER_OFFSET("page._refcount", page._refcount);
+	if (OFFSET(page._refcount) == NOT_FOUND_STRUCTURE) {
+		info->flag_use_count = TRUE;
+		READ_MEMBER_OFFSET("page._count", page._refcount);
+	} else {
+		info->flag_use_count = FALSE;
+	}
 	READ_MEMBER_OFFSET("page.mapping", page.mapping);
 	READ_MEMBER_OFFSET("page.lru", page.lru);
 	READ_MEMBER_OFFSET("page._mapcount", page._mapcount);
@@ -5615,7 +5631,7 @@ __exclude_unnecessary_pages(unsigned long mem_map,
 		pcache  = page_cache + (index_pg * SIZE(page));
 
 		flags   = ULONG(pcache + OFFSET(page.flags));
-		_count  = UINT(pcache + OFFSET(page._count));
+		_count  = UINT(pcache + OFFSET(page._refcount));
 		mapping = ULONG(pcache + OFFSET(page.mapping));
 
 		if (OFFSET(page.compound_order) != NOT_FOUND_STRUCTURE) {
makedumpfile.h +2 -2
index 251d4bf..533e5b8 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_use_count;      /* _refcount is named _count in struct page */
 	unsigned long	vaddr_for_vtop;      /* virtual address for debugging */
 	long		page_size;           /* size of page */
 	long		page_shift;
@@ -1483,7 +1484,7 @@ struct size_table {
 struct offset_table {
 	struct page {
 		long	flags;
-		long	_count;
+		long	_refcount;
 		long	mapping;
 		long	lru;
 		long	_mapcount;
--
Quoted 1 line

2.5.5

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

#2 lore raw
Quoted 13 lines · Atsushi Kumagai

Hello Vitaly,

Quoted 11 lines

_count member was renamed to _refcount in linux 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.

---
Changes since 'v1':
- Make '_refcount' the default [Atsushi Kumagai]

Sorry, I missed this conversation earlier.

Quoted 11 lines

Good fix, I'll merge this into v1.6.1.

Thanks,
Atsushi Kumagai

Quoted 5 lines

---
makedumpfile.c | 26 +++++++++++++++++++++-----
makedumpfile.h | 3 ++-

2 files changed, 23 insertions(+), 6 deletions(-)
Quoted 15 lines
Quoted 5 lines
makedumpfile.c +0 -0
index 853b999..fd884d3 100644

makedumpfile.c get_structure_info(void) · line 1587

Quoted 10 lines
makedumpfile.c +6 -1
@@ -1579,7 +1579,14 @@ get_structure_info(void)
 	 */
 	SIZE_INIT(page, "page");
 	OFFSET_INIT(page.flags, "page", "flags");
-	OFFSET_INIT(page._count, "page", "_count");
+	OFFSET_INIT(page._refcount, "page", "_refcount");
+	if (OFFSET(page._refcount) == NOT_FOUND_STRUCTURE) {
+		info->flag_use_count = TRUE;
+		OFFSET_INIT(page._refcount, "page", "_count");
+	} else {
+		info->flag_use_count = FALSE;

Probably we could have avoided this flag and could have solved it same way as we have solved for other such kernel changes, like that of "module.module_core". Infact, we do not need to add "_refcount" in makedumpfile's page struct.

See:
https://github.com/pratyushanand/makedumpfile/commit/8c58c177d27d4ac31db2ee42442ef056dbbd2c93

~Pratyush

Quoted 71 lines
Quoted 71 lines
makedumpfile.c +15 -4
+	}
+
 	OFFSET_INIT(page.mapping, "page", "mapping");
 	OFFSET_INIT(page._mapcount, "page", "_mapcount");
 	OFFSET_INIT(page.private, "page", "private");
@@ -2044,7 +2051,7 @@ get_mem_type(void)
 
 	if ((SIZE(page) == NOT_FOUND_STRUCTURE)
 	    || (OFFSET(page.flags) == NOT_FOUND_STRUCTURE)
-	    || (OFFSET(page._count) == NOT_FOUND_STRUCTURE)
+	    || (OFFSET(page._refcount) == NOT_FOUND_STRUCTURE)
 	    || (OFFSET(page.mapping) == NOT_FOUND_STRUCTURE)) {
 		ret = NOT_FOUND_MEMTYPE;
 	} else if ((((SYMBOL(node_data) != NOT_FOUND_SYMBOL)
@@ -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_use_count)
+		WRITE_MEMBER_OFFSET("page._count", page._refcount);
+	else
+		WRITE_MEMBER_OFFSET("page._refcount", page._refcount);
 	WRITE_MEMBER_OFFSET("page.mapping", page.mapping);
 	WRITE_MEMBER_OFFSET("page.lru", page.lru);
 	WRITE_MEMBER_OFFSET("page._mapcount", page._mapcount);
@@ -2491,7 +2501,13 @@ read_vmcoreinfo(void)
 
 
 	READ_MEMBER_OFFSET("page.flags", page.flags);
-	READ_MEMBER_OFFSET("page._count", page._count);
+	READ_MEMBER_OFFSET("page._refcount", page._refcount);
+	if (OFFSET(page._refcount) == NOT_FOUND_STRUCTURE) {
+		info->flag_use_count = TRUE;
+		READ_MEMBER_OFFSET("page._count", page._refcount);
+	} else {
+		info->flag_use_count = FALSE;
+	}
 	READ_MEMBER_OFFSET("page.mapping", page.mapping);
 	READ_MEMBER_OFFSET("page.lru", page.lru);
 	READ_MEMBER_OFFSET("page._mapcount", page._mapcount);
@@ -5615,7 +5631,7 @@ __exclude_unnecessary_pages(unsigned long mem_map,
 		pcache  = page_cache + (index_pg * SIZE(page));
 
 		flags   = ULONG(pcache + OFFSET(page.flags));
-		_count  = UINT(pcache + OFFSET(page._count));
+		_count  = UINT(pcache + OFFSET(page._refcount));
 		mapping = ULONG(pcache + OFFSET(page.mapping));
 
 		if (OFFSET(page.compound_order) != NOT_FOUND_STRUCTURE) {
makedumpfile.h +2 -1
index 251d4bf..533e5b8 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_use_count;      /* _refcount is named _count in struct page */
 	unsigned long	vaddr_for_vtop;      /* virtual address for debugging */
 	long		page_size;           /* size of page */
 	long		page_shift;
@@ -1483,7 +1484,7 @@ struct size_table {
 struct offset_table {
 	struct page {
 		long	flags;
-		long	_count;
+		long	_refcount;
 		long	mapping;
 		long	lru;
 		long	_mapcount;
Quoted 8 lines
Quoted 2 lines

--
2.5.5

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

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

#3 lore raw
Quoted 39 lines · Pratyush Anand
Quoted 13 lines · Atsushi Kumagai

Hello Vitaly,

Quoted 11 lines

_count member was renamed to _refcount in linux 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.

---
Changes since 'v1':
- Make '_refcount' the default [Atsushi Kumagai]

Sorry, I missed this conversation earlier.

Quoted 22 lines

Good fix, I'll merge this into v1.6.1.

Thanks,
Atsushi Kumagai

Quoted 16 lines

---
makedumpfile.c | 26 +++++++++++++++++++++-----
makedumpfile.h | 3 ++-

2 files changed, 23 insertions(+), 6 deletions(-)
makedumpfile.c +2 -1
index 853b999..fd884d3 100644
@@ -1579,7 +1579,14 @@ get_structure_info(void)
 	 */
 	SIZE_INIT(page, "page");
 	OFFSET_INIT(page.flags, "page", "flags");
-	OFFSET_INIT(page._count, "page", "_count");
+	OFFSET_INIT(page._refcount, "page", "_refcount");
+	if (OFFSET(page._refcount) == NOT_FOUND_STRUCTURE) {
Quoted 9 lines
Quoted 4 lines

makedumpfile.c get_structure_info(void) · line 1587

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

Probably we could have avoided this flag and could have solved it same way as we have solved for other such kernel changes, like that of "module.module_core". Infact, we do not need to add "_refcount" in makedumpfile's page struct.

Yes, the flag is only needed to do the write. Why do you think we don't need it?

Quoted 84 lines

See:
https://github.com/pratyushanand/makedumpfile/commit/8c58c177d27d4ac31db2ee42442ef056dbbd2c93

~Pratyush

Quoted 79 lines
Quoted 72 lines
makedumpfile.c +15 -4
+	}
+
 	OFFSET_INIT(page.mapping, "page", "mapping");
 	OFFSET_INIT(page._mapcount, "page", "_mapcount");
 	OFFSET_INIT(page.private, "page", "private");
@@ -2044,7 +2051,7 @@ get_mem_type(void)
 
 	if ((SIZE(page) == NOT_FOUND_STRUCTURE)
 	    || (OFFSET(page.flags) == NOT_FOUND_STRUCTURE)
-	    || (OFFSET(page._count) == NOT_FOUND_STRUCTURE)
+	    || (OFFSET(page._refcount) == NOT_FOUND_STRUCTURE)
 	    || (OFFSET(page.mapping) == NOT_FOUND_STRUCTURE)) {
 		ret = NOT_FOUND_MEMTYPE;
 	} else if ((((SYMBOL(node_data) != NOT_FOUND_SYMBOL)
@@ -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_use_count)
+		WRITE_MEMBER_OFFSET("page._count", page._refcount);
+	else
+		WRITE_MEMBER_OFFSET("page._refcount", page._refcount);
 	WRITE_MEMBER_OFFSET("page.mapping", page.mapping);
 	WRITE_MEMBER_OFFSET("page.lru", page.lru);
 	WRITE_MEMBER_OFFSET("page._mapcount", page._mapcount);
@@ -2491,7 +2501,13 @@ read_vmcoreinfo(void)
 
 
 	READ_MEMBER_OFFSET("page.flags", page.flags);
-	READ_MEMBER_OFFSET("page._count", page._count);
+	READ_MEMBER_OFFSET("page._refcount", page._refcount);
+	if (OFFSET(page._refcount) == NOT_FOUND_STRUCTURE) {
+		info->flag_use_count = TRUE;
+		READ_MEMBER_OFFSET("page._count", page._refcount);
+	} else {
+		info->flag_use_count = FALSE;
+	}
 	READ_MEMBER_OFFSET("page.mapping", page.mapping);
 	READ_MEMBER_OFFSET("page.lru", page.lru);
 	READ_MEMBER_OFFSET("page._mapcount", page._mapcount);
@@ -5615,7 +5631,7 @@ __exclude_unnecessary_pages(unsigned long mem_map,
 		pcache  = page_cache + (index_pg * SIZE(page));
 
 		flags   = ULONG(pcache + OFFSET(page.flags));
-		_count  = UINT(pcache + OFFSET(page._count));
+		_count  = UINT(pcache + OFFSET(page._refcount));
 		mapping = ULONG(pcache + OFFSET(page.mapping));
 
 		if (OFFSET(page.compound_order) != NOT_FOUND_STRUCTURE) {
makedumpfile.h +2 -2
index 251d4bf..533e5b8 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_use_count;      /* _refcount is named _count in struct page */
 	unsigned long	vaddr_for_vtop;      /* virtual address for debugging */
 	long		page_size;           /* size of page */
 	long		page_shift;
@@ -1483,7 +1484,7 @@ struct size_table {
 struct offset_table {
 	struct page {
 		long	flags;
-		long	_count;
+		long	_refcount;
 		long	mapping;
 		long	lru;
 		long	_mapcount;
--
Quoted 1 line

2.5.5

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

Signature · 6 lines
  Vitaly

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
#4 lore raw
Quoted 51 lines · Vitaly Kuznetsov
Quoted 39 lines · Pratyush Anand
Quoted 13 lines · Atsushi Kumagai

Hello Vitaly,

Quoted 11 lines

_count member was renamed to _refcount in linux 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.

---
Changes since 'v1':
- Make '_refcount' the default [Atsushi Kumagai]

Sorry, I missed this conversation earlier.

Quoted 22 lines

Good fix, I'll merge this into v1.6.1.

Thanks,
Atsushi Kumagai

Quoted 16 lines

---
makedumpfile.c | 26 +++++++++++++++++++++-----
makedumpfile.h | 3 ++-

2 files changed, 23 insertions(+), 6 deletions(-)
makedumpfile.c +2 -1
index 853b999..fd884d3 100644
@@ -1579,7 +1579,14 @@ get_structure_info(void)
 	 */
 	SIZE_INIT(page, "page");
 	OFFSET_INIT(page.flags, "page", "flags");
-	OFFSET_INIT(page._count, "page", "_count");
+	OFFSET_INIT(page._refcount, "page", "_refcount");
+	if (OFFSET(page._refcount) == NOT_FOUND_STRUCTURE) {
Quoted 9 lines
Quoted 4 lines

makedumpfile.c get_structure_info(void) · line 1587

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

Probably we could have avoided this flag and could have solved it same way as we have solved for other such kernel changes, like that of "module.module_core". Infact, we do not need to add "_refcount" in makedumpfile's page struct.

Quoted 2 lines

Yes, the flag is only needed to do the write. Why do you think we don't need it?

IMHO, even if we write with "page._count", we would be able to get correct value in next read, because we prefer reading with "page._count" over "page._refcount". I think "crash utility" also gives priority for reading with _count, so things should work without any issue.

~Pratyush

Quoted 77 lines
Quoted 77 lines

See:
https://github.com/pratyushanand/makedumpfile/commit/8c58c177d27d4ac31db2ee42442ef056dbbd2c93

~Pratyush

Quoted 71 lines
Quoted 71 lines
makedumpfile.c +15 -4
+	}
+
 	OFFSET_INIT(page.mapping, "page", "mapping");
 	OFFSET_INIT(page._mapcount, "page", "_mapcount");
 	OFFSET_INIT(page.private, "page", "private");
@@ -2044,7 +2051,7 @@ get_mem_type(void)
 
 	if ((SIZE(page) == NOT_FOUND_STRUCTURE)
 	    || (OFFSET(page.flags) == NOT_FOUND_STRUCTURE)
-	    || (OFFSET(page._count) == NOT_FOUND_STRUCTURE)
+	    || (OFFSET(page._refcount) == NOT_FOUND_STRUCTURE)
 	    || (OFFSET(page.mapping) == NOT_FOUND_STRUCTURE)) {
 		ret = NOT_FOUND_MEMTYPE;
 	} else if ((((SYMBOL(node_data) != NOT_FOUND_SYMBOL)
@@ -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_use_count)
+		WRITE_MEMBER_OFFSET("page._count", page._refcount);
+	else
+		WRITE_MEMBER_OFFSET("page._refcount", page._refcount);
 	WRITE_MEMBER_OFFSET("page.mapping", page.mapping);
 	WRITE_MEMBER_OFFSET("page.lru", page.lru);
 	WRITE_MEMBER_OFFSET("page._mapcount", page._mapcount);
@@ -2491,7 +2501,13 @@ read_vmcoreinfo(void)
 
 
 	READ_MEMBER_OFFSET("page.flags", page.flags);
-	READ_MEMBER_OFFSET("page._count", page._count);
+	READ_MEMBER_OFFSET("page._refcount", page._refcount);
+	if (OFFSET(page._refcount) == NOT_FOUND_STRUCTURE) {
+		info->flag_use_count = TRUE;
+		READ_MEMBER_OFFSET("page._count", page._refcount);
+	} else {
+		info->flag_use_count = FALSE;
+	}
 	READ_MEMBER_OFFSET("page.mapping", page.mapping);
 	READ_MEMBER_OFFSET("page.lru", page.lru);
 	READ_MEMBER_OFFSET("page._mapcount", page._mapcount);
@@ -5615,7 +5631,7 @@ __exclude_unnecessary_pages(unsigned long mem_map,
 		pcache  = page_cache + (index_pg * SIZE(page));
 
 		flags   = ULONG(pcache + OFFSET(page.flags));
-		_count  = UINT(pcache + OFFSET(page._count));
+		_count  = UINT(pcache + OFFSET(page._refcount));
 		mapping = ULONG(pcache + OFFSET(page.mapping));
 
 		if (OFFSET(page.compound_order) != NOT_FOUND_STRUCTURE) {
makedumpfile.h +2 -1
index 251d4bf..533e5b8 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_use_count;      /* _refcount is named _count in struct page */
 	unsigned long	vaddr_for_vtop;      /* virtual address for debugging */
 	long		page_size;           /* size of page */
 	long		page_shift;
@@ -1483,7 +1484,7 @@ struct size_table {
 struct offset_table {
 	struct page {
 		long	flags;
-		long	_count;
+		long	_refcount;
 		long	mapping;
 		long	lru;
 		long	_mapcount;
Quoted 11 lines
Quoted 8 lines
Quoted 8 lines
Quoted 2 lines

--
2.5.5

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

Signature · 1 line
  Vitaly

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

#5 lore raw
Quoted 52 lines · Pratyush Anand
Quoted 51 lines · Vitaly Kuznetsov
Quoted 48 lines · Pratyush Anand
Quoted 13 lines · Atsushi Kumagai

Hello Vitaly,

Quoted 11 lines

_count member was renamed to _refcount in linux 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.

---
Changes since 'v1':
- Make '_refcount' the default [Atsushi Kumagai]

Sorry, I missed this conversation earlier.

Quoted 11 lines

Good fix, I'll merge this into v1.6.1.

Thanks,
Atsushi Kumagai

Quoted 5 lines

---
makedumpfile.c | 26 +++++++++++++++++++++-----
makedumpfile.h | 3 ++-

2 files changed, 23 insertions(+), 6 deletions(-)
Quoted 15 lines
Quoted 5 lines
makedumpfile.c +0 -0
index 853b999..fd884d3 100644

makedumpfile.c get_structure_info(void) · line 1587

Quoted 10 lines
makedumpfile.c +6 -1
@@ -1579,7 +1579,14 @@ get_structure_info(void)
 	 */
 	SIZE_INIT(page, "page");
 	OFFSET_INIT(page.flags, "page", "flags");
-	OFFSET_INIT(page._count, "page", "_count");
+	OFFSET_INIT(page._refcount, "page", "_refcount");
+	if (OFFSET(page._refcount) == NOT_FOUND_STRUCTURE) {
+		info->flag_use_count = TRUE;
+		OFFSET_INIT(page._refcount, "page", "_count");
+	} else {
+		info->flag_use_count = FALSE;

Probably we could have avoided this flag and could have solved it same way as we have solved for other such kernel changes, like that of "module.module_core". Infact, we do not need to add "_refcount" in makedumpfile's page struct.

Quoted 7 lines
Quoted 2 lines

Yes, the flag is only needed to do the write. Why do you think we don't need it?

IMHO, even if we write with "page._count", we would be able to get correct value in next read, because we prefer reading with "page._count" over "page._refcount". I think "crash utility" also gives priority for reading with _count, so things should work without any issue.

While things will probably work now while everyone still remembers the old "_count" name it may happen that some tool will drop this support in future and this will lead to an awkward situation when everythin works with /proc/vmcore but doesn't work with makedumpfile's output. Said that I think it makes sense for makedumpfile to be precise and write what we read. IMO, of course, I'm not a regular makedumpfile contributor.

<skip>

Signature · 6 lines
  Vitaly

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
#6 lore raw
Quoted 62 lines
Quoted 52 lines · Pratyush Anand
Quoted 51 lines · Vitaly Kuznetsov
Quoted 48 lines · Pratyush Anand
Quoted 13 lines · Atsushi Kumagai

Hello Vitaly,

Quoted 11 lines

_count member was renamed to _refcount in linux 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.

---
Changes since 'v1':
- Make '_refcount' the default [Atsushi Kumagai]

Sorry, I missed this conversation earlier.

Quoted 11 lines

Good fix, I'll merge this into v1.6.1.

Thanks,
Atsushi Kumagai

Quoted 5 lines

---
makedumpfile.c | 26 +++++++++++++++++++++-----
makedumpfile.h | 3 ++-

2 files changed, 23 insertions(+), 6 deletions(-)
Quoted 15 lines
Quoted 5 lines
makedumpfile.c +0 -0
index 853b999..fd884d3 100644

makedumpfile.c get_structure_info(void) · line 1587

Quoted 10 lines
makedumpfile.c +6 -1
@@ -1579,7 +1579,14 @@ get_structure_info(void)
 	 */
 	SIZE_INIT(page, "page");
 	OFFSET_INIT(page.flags, "page", "flags");
-	OFFSET_INIT(page._count, "page", "_count");
+	OFFSET_INIT(page._refcount, "page", "_refcount");
+	if (OFFSET(page._refcount) == NOT_FOUND_STRUCTURE) {
+		info->flag_use_count = TRUE;
+		OFFSET_INIT(page._refcount, "page", "_count");
+	} else {
+		info->flag_use_count = FALSE;

Probably we could have avoided this flag and could have solved it same way as we have solved for other such kernel changes, like that of "module.module_core". Infact, we do not need to add "_refcount" in makedumpfile's page struct.

Quoted 7 lines
Quoted 2 lines

Yes, the flag is only needed to do the write. Why do you think we don't need it?

IMHO, even if we write with "page._count", we would be able to get correct value in next read, because we prefer reading with "page._count" over "page._refcount". I think "crash utility" also gives priority for reading with _count, so things should work without any issue.

Quoted 6 lines

While things will probably work now while everyone still remembers the old "_count" name it may happen that some tool will drop this support in future and this will lead to an awkward situation when everythin works with /proc/vmcore but doesn't work with makedumpfile's output. Said that I think it makes sense for makedumpfile to be precise and write what we read. IMO, of course, I'm not a regular makedumpfile contributor.

Yeah, I think it would be better to write down the correct current name even if the code gets a bit more complicated, thus I accepted the Vitaly's patch.

Thanks,
Atsushi Kumagai

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