Skip to contentSkip to conversation

handle !SPARSEMEM_EX properly

PATCH In review Daisuke Nishimura 3 participants 4 messages Apr 6, 2010 9 messages not in the archive

Subsystems (2)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

#9 lore raw

PATCH 1/1 handle !SPARSEMEM_EX properly

In !SPARSEMEM_EX case, the symbol mem_section points a array of struct mem_section, doesn't point a array of pointer to mem_section[], so I think the check:

	if ((mem_sec[SECTION_NR_TO_ROOT(nr)] == 0) || 
	    !IS_KVADDR(mem_sec[SECTION_NR_TO_ROOT(nr)]))
		return 0;

in nr_to_section() is not a valid check in this case.

To make the matters worse, if CONFIG_CGROUP_MEM_RES_CTLR is enabled, the end of struct mem_section is padded with 0.

So, reading mem_section by "rd" will look like:

	crash> rd mem_section 128
	c08b71e0:  c9002003 c9001200 f7000000 00000000   . ..............
	c08b71f0:  c9002003 c9001260 f6980000 00000000   . ..`...........
	c08b7200:  c9002003 c90012c0 f6300000 00000000   . ........0.....
	c08b7210:  c9002003 c9001320 f5c80000 00000000   . .. ...........
	...

This means nr_to_section() will return 0 when "nr" is 3,7,11,... because it meets the condition(mem_sec[SECTION_NR_TO_ROOT(nr)] == mem_sec[nr] == 0).

As a result, mem_map for section 3,7,11,... cannot be handled properly. Actually, "kmem -n" doesn't show a mem_map for them.

	crash> kmem -n
	...
	NR  SECTION   CODED_MEM_MAP  MEM_MAP   PFN
	 0  c08b71e0  c9002000  c9002000  0
	 1  c08b71f0  c9002000  c9402000  131072
	 2  c08b7200  c9002000  c9802000  262144
	 4  c08b7220  c9002000  ca002000  524288
	 5  c08b7230  c9002000  ca402000  655360
	 6  c08b7240  c9002000  ca802000  786432
	 8  c08b7260  c8c02000  cac02000  1048576
	 9  c08b7270  c8c02000  cb002000  1179648
	10  c08b7280  c8c02000  cb402000  1310720
	12  c08b72a0  c8c02000  cbc02000  1572864
	...

This patch is a fix for this problem. nr_to_section() will check "addr" by IS_KVADDR() later anyway, so this patch just removes the problematic check.

---

memory.c +0 -4
diff -uprN crash-5.0.2.orig/memory.c crash-5.0.2/memory.c
@@ -13030,10 +13030,6 @@ nr_to_section(ulong nr)
 		}
 	}
 
-	if ((mem_sec[SECTION_NR_TO_ROOT(nr)] == 0) || 
-	    !IS_KVADDR(mem_sec[SECTION_NR_TO_ROOT(nr)]))
-		return 0;
-
 	if (IS_SPARSEMEM_EX())
 		addr = mem_sec[SECTION_NR_TO_ROOT(nr)] + 
 		    (nr & SECTION_ROOT_MASK()) * SIZE(mem_section);

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

#10 lore raw

PATCH 1/1 handle !SPARSEMEM_EX properly

In !SPARSEMEM_EX case, the symbol mem_section points a array of struct mem_section, doesn't point a array of pointer to mem_section[], so I think the check:

	if (!is_kvaddr(mem_sec[SECTION_NR_TO_ROOT(nr)]))
		return NOT_KV_ADDR;

in nr_to_section() is not a valid check in this case.

To make the matters worse, if CONFIG_CGROUP_MEM_RES_CTLR is enabled, the end of struct mem_section is padded with 0.

So, reading mem_section by "rd" of crash will look like:

	crash> rd mem_section 128
	c08b71e0:  c9002003 c9001200 f7000000 00000000   . ..............
	c08b71f0:  c9002003 c9001260 f6980000 00000000   . ..`...........
	c08b7200:  c9002003 c90012c0 f6300000 00000000   . ........0.....
	c08b7210:  c9002003 c9001320 f5c80000 00000000   . .. ...........
	...

This means nr_to_section() will return 0 when "nr" is 3,7,11,... because it meets the condition(mem_sec[SECTION_NR_TO_ROOT(nr)] == mem_sec[nr] == 0 == !is_kvaddr).

As a result, mem_map for section 3,7,11,... cannot be handled properly.

This patch is a fix for this problem. nr_to_section() will check "addr" by is_kvaddr() later anyway, so this patch just removes the problematic check.

---

makedumpfile.c +0 -3
index 855c718..73fa94f 100644
@@ -3547,9 +3547,6 @@ nr_to_section(unsigned long nr, unsigned long *mem_sec)
 {
 	unsigned long addr;
 
-	if (!is_kvaddr(mem_sec[SECTION_NR_TO_ROOT(nr)]))
-		return NOT_KV_ADDR;
-
 	if (is_sparsemem_extreme())
 		addr = mem_sec[SECTION_NR_TO_ROOT(nr)] +
 		    (nr & SECTION_ROOT_MASK()) * SIZE(mem_section);

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

#11 lore raw

Hi Nishimura-san,

Thank you for the patch.

Quoted 11 lines · Daisuke Nishimura

In !SPARSEMEM_EX case, the symbol mem_section points a array of struct mem_section, doesn't point a array of pointer to mem_section[], so I think the check:

	if (!is_kvaddr(mem_sec[SECTION_NR_TO_ROOT(nr)]))
		return NOT_KV_ADDR;

in nr_to_section() is not a valid check in this case.

To make the matters worse, if CONFIG_CGROUP_MEM_RES_CTLR is enabled, the end of struct mem_section is padded with 0.

Quoted 8 lines

So, reading mem_section by "rd" of crash will look like:

	crash> rd mem_section 128
	c08b71e0:  c9002003 c9001200 f7000000 00000000   . ..............
	c08b71f0:  c9002003 c9001260 f6980000 00000000   . ..`...........
	c08b7200:  c9002003 c90012c0 f6300000 00000000   . ........0.....
	c08b7210:  c9002003 c9001320 f5c80000 00000000   . .. ...........
	...

I see.

In !SPARSEMEM_EX case, nr_to_section() checked invalid area (pageblock_flags, page_cgroup, and pad) as section_mem_map.

linux-2.6.33/include/linux/mmzone.h:

  struct mem_section {
        unsigned long section_mem_map;
        unsigned long *pageblock_flags;
  #ifdef CONFIG_CGROUP_MEM_RES_CTLR
        struct page_cgroup *page_cgroup;
        unsigned long pad;

#endif
};

Quoted 16 lines

This means nr_to_section() will return 0 when "nr" is 3,7,11,... because it meets the condition(mem_sec[SECTION_NR_TO_ROOT(nr)] == mem_sec[nr] == 0 == !is_kvaddr).

As a result, mem_map for section 3,7,11,... cannot be handled properly.

This patch is a fix for this problem. nr_to_section() will check "addr" by is_kvaddr() later anyway, so this patch just removes the problematic check.

---

makedumpfile.c +0 -0
index 855c718..73fa94f 100644

makedumpfile.c nr_to_section(unsigned long nr, unsigned long *mem_sec) · line 3552

Quoted 9 lines
makedumpfile.c +0 -3
@@ -3547,9 +3547,6 @@ nr_to_section(unsigned long nr, unsigned long *mem_sec)
 {
 	unsigned long addr;
 
-	if (!is_kvaddr(mem_sec[SECTION_NR_TO_ROOT(nr)]))
-		return NOT_KV_ADDR;
-
 	if (is_sparsemem_extreme())
 		addr = mem_sec[SECTION_NR_TO_ROOT(nr)] +
 		    (nr & SECTION_ROOT_MASK()) * SIZE(mem_section);

The patch is good, and it has been merged to git tree of makedumpfile:

http://makedumpfile.git.sourceforge.net/git/gitweb.cgi?p=makedumpfile/makedumpfile;a=commit;h=27b71566ec11128c5b061a350e467546f2d26be6

Thanks
Ken'ichi Ohmichi

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

#12 lore raw
In reply to Daisuke Nishimura
Quoted 51 lines · Daisuke Nishimura

In !SPARSEMEM_EX case, the symbol mem_section points a array of struct mem_section, doesn't point a array of pointer to mem_section[], so I think the check:

	if ((mem_sec[SECTION_NR_TO_ROOT(nr)] == 0) || 
	    !IS_KVADDR(mem_sec[SECTION_NR_TO_ROOT(nr)]))
		return 0;

in nr_to_section() is not a valid check in this case.

To make the matters worse, if CONFIG_CGROUP_MEM_RES_CTLR is enabled, the end of struct mem_section is padded with 0.

So, reading mem_section by "rd" will look like:

	crash> rd mem_section 128
	c08b71e0:  c9002003 c9001200 f7000000 00000000   . ..............
	c08b71f0:  c9002003 c9001260 f6980000 00000000   . ..`...........
	c08b7200:  c9002003 c90012c0 f6300000 00000000   . ........0.....
	c08b7210:  c9002003 c9001320 f5c80000 00000000   . .. ...........
	...

This means nr_to_section() will return 0 when "nr" is 3,7,11,... because it meets the condition(mem_sec[SECTION_NR_TO_ROOT(nr)] == mem_sec[nr] == 0).

As a result, mem_map for section 3,7,11,... cannot be handled properly. Actually, "kmem -n" doesn't show a mem_map for them.

	crash> kmem -n
	...
	NR  SECTION   CODED_MEM_MAP  MEM_MAP   PFN
	 0  c08b71e0  c9002000  c9002000  0
	 1  c08b71f0  c9002000  c9402000  131072
	 2  c08b7200  c9002000  c9802000  262144
	 4  c08b7220  c9002000  ca002000  524288
	 5  c08b7230  c9002000  ca402000  655360
	 6  c08b7240  c9002000  ca802000  786432
	 8  c08b7260  c8c02000  cac02000  1048576
	 9  c08b7270  c8c02000  cb002000  1179648
	10  c08b7280  c8c02000  cb402000  1310720
	12  c08b72a0  c8c02000  cbc02000  1572864
	...

This patch is a fix for this problem. nr_to_section() will check "addr" by IS_KVADDR() later anyway, so this patch just removes the problematic check.

---
diff -uprN crash-5.0.2.orig/memory.c crash-5.0.2/memory.c

memory.c nr_to_section(ulong nr) · line 13035

Quoted 10 lines
memory.c +0 -4
@@ -13030,10 +13030,6 @@ nr_to_section(ulong nr)
 		}
 	}
 
-	if ((mem_sec[SECTION_NR_TO_ROOT(nr)] == 0) || 
-	    !IS_KVADDR(mem_sec[SECTION_NR_TO_ROOT(nr)]))
-		return 0;
-
 	if (IS_SPARSEMEM_EX())
 		addr = mem_sec[SECTION_NR_TO_ROOT(nr)] + 
 		    (nr & SECTION_ROOT_MASK()) * SIZE(mem_section);

This has been successfully tested here. Thanks!
Neil

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