Skip to contentSkip to conversation

mm/ia64: fix a memory block size bug

PATCH Superseded wujianguo 2 participants 3 messages Aug 21, 2012 – Aug 24, 2012

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

wujianguo

author
#0 lore raw

PATCH 1/1 mm/ia64: fix a memory block size bug

From: Jianguo Wu <[email protected]>

Hi all,
I found following definition in include/linux/memory.h, in my IA64
platform, SECTION_SIZE_BITS is equal to 32, and MIN_MEMORY_BLOCK_SIZE will be 0.

	#define MIN_MEMORY_BLOCK_SIZE     (1 << SECTION_SIZE_BITS)

	Because MIN_MEMORY_BLOCK_SIZE is 32bits, so MIN_MEMORY_BLOCK_SIZE(1 << 32)
will equal to 0. This will cause wrong system memory infomation in sysfs. I think
it should be:
	#define MIN_MEMORY_BLOCK_SIZE     (1UL << SECTION_SIZE_BITS)

linux-drf:/sys/devices/system/memory # ll
total 0
-r--r--r-- 1 root root 65536 Aug 20 02:35 block_size_bytes
drwxr-xr-x 3 root root 0 Aug 20 02:19 memory0
drwxr-xr-x 2 root root 0 Aug 20 02:35 power
-rw-r--r-- 1 root root 65536 Aug 20 02:35 uevent

linux-drf:/sys/devices/system/memory # cat block_size_bytes 0

linux-drf:/sys/devices/system/memory/memory0 # cat * 8000000000000000
cat: node0: Is a directory
cat: node1: Is a directory
cat: node2: Is a directory
cat: node3: Is a directory
0
8000000000000000
cat: power: Is a directory
1
online
cat: subsystem: Is a directory

And "echo offline > memory0/state" will cause following call trace:

kernel BUG at mm/memory_hotplug.c:885!
sh[6455]: bugcheck! 0 [1]

Pid: 6455, CPU 0, comm: sh
psr : 0000101008526030 ifs : 8000000000000fa4 ip : [<a0000001008c40f0>] Not tainted (3.6.0-rc1)
ip is at offline_pages+0x210/0xee0
unat: 0000000000000000 pfs : 0000000000000fa4 rsc : 0000000000000003
rnat: a0000001008f2d50 bsps: 0000000000000000 pr : 65519a96659a9565
ldrs: 0000000000000000 ccv : 0000010b9263f310 fpsr: 0009804c0270033f csd : 0000000000000000 ssd : 0000000000000000
b0 : a0000001008c40f0 b6 : a000000100473980 b7 : a0000001000106d0 f6 : 000000000000000000000 f7 : 1003e0000000085c9354c f8 : 1003e0044b82fa09b5a53 f9 : 1003e000000d65cd62abf f10 : 1003efd02efdec682803d f11 : 1003e0000000000000042 r1 : a00000010152c2e0 r2 : 0000000000006ada r3 : 000000000000fffe r8 : 0000000000000026 r9 : a00000010121cc18 r10 : a0000001013309f0 r11 : 65519a96659a19e9 r12 : e00000070a91fdf0 r13 : e00000070a910000 r14 : 0000000000006ada r15 : 0000000000004000 r16 : 000000006ad8356c r17 : a0000001019a525e r18 : 0000000000007fff r19 : 0000000000000000 r20 : 0000000000006ad6 r21 : 0000000000006ad6 r22 : a00000010133bec8 r23 : 0000000000006ad4 r24 : 0000000000000002 r25 : 8200000000260038 r26 : 00000000000004f9 r27 : 00000000000004f8 r28 : 000000000001cf98 r29 : 0000000000000038 r30 : a0000001019a5ae0 r31 : 000000000001cf60

Call Trace:
 [<a0000001000163e0>] show_stack+0x80/0xa0
                                spà0000070a91f9b0 bspà0000070a9115e0
 [<a000000100016a40>] show_regs+0x640/0x920
                                spà0000070a91fb80 bspà0000070a911588
 [<a000000100040590>] die+0x190/0x2c0
                                spà0000070a91fb90 bspà0000070a911548
 [<a000000100040710>] die_if_kernel+0x50/0x80
                                spà0000070a91fb90 bspà0000070a911518
 [<a0000001008f8030>] ia64_bad_break+0x3d0/0x6e0
                                spà0000070a91fb90 bspà0000070a9114f0
 [<a00000010000c0c0>] ia64_native_leave_kernel+0x0/0x270
                                spà0000070a91fc20 bspà0000070a9114f0
 [<a0000001008c40f0>] offline_pages+0x210/0xee0
                                spà0000070a91fdf0 bspà0000070a9113c8
 [<a00000010022d580>] alloc_pages_current+0x180/0x2a0
                                spà0000070a91fe20 bspà0000070a9113a

This patch is trying to fix the bug.

---
 include/linux/memory.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
include/linux/memory.h +1 -1
index 1ac7f6e..ff9a9f8 100644
@@ -19,7 +19,7 @@
 #include <linux/compiler.h>
 #include <linux/mutex.h>
 
-#define MIN_MEMORY_BLOCK_SIZE     (1 << SECTION_SIZE_BITS)
+#define MIN_MEMORY_BLOCK_SIZE     (1UL << SECTION_SIZE_BITS)
 
 struct memory_block {
 	unsigned long start_section_nr;
Signature · 6 lines
1.7.6.1




.
Reviewed-by on v1 1/1
#1 lore raw

[Fixed gregkh email address]

Quoted 6 lines · wujianguo

From: Jianguo Wu <[email protected]>

Hi all,
I found following definition in include/linux/memory.h, in my IA64
platform, SECTION_SIZE_BITS is equal to 32, and MIN_MEMORY_BLOCK_SIZE will be 0.

	#define MIN_MEMORY_BLOCK_SIZE     (1 << SECTION_SIZE_BITS)

OK, so I assume you have CONFIG_FORCE_MAX_ZONEORDER 17 and PAGE_SHIFT 16, right? But even CONFIG_FORCE_MAX_ZONEORDER 16 would be a problem.

Quoted 5 lines

Because MIN_MEMORY_BLOCK_SIZE is 32bits, so MIN_MEMORY_BLOCK_SIZE(1 << 32)
will equal to 0. This will cause wrong system memory infomation in sysfs. I think it should be:

	#define MIN_MEMORY_BLOCK_SIZE     (1UL << SECTION_SIZE_BITS)

I guess the part below is not necessary for the changelog

Quoted 10 lines

linux-drf:/sys/devices/system/memory # ll
total 0
-r--r--r-- 1 root root 65536 Aug 20 02:35 block_size_bytes
drwxr-xr-x 3 root root 0 Aug 20 02:19 memory0
drwxr-xr-x 2 root root 0 Aug 20 02:35 power
-rw-r--r-- 1 root root 65536 Aug 20 02:35 uevent

linux-drf:/sys/devices/system/memory # cat block_size_bytes 0

Quoted 13 lines

linux-drf:/sys/devices/system/memory/memory0 # cat * 8000000000000000
cat: node0: Is a directory
cat: node1: Is a directory
cat: node2: Is a directory
cat: node3: Is a directory
0
8000000000000000
cat: power: Is a directory
1
online
cat: subsystem: Is a directory

Up to here.

Quoted 44 lines

And "echo offline > memory0/state" will cause following call trace:

kernel BUG at mm/memory_hotplug.c:885!
sh[6455]: bugcheck! 0 [1]

Pid: 6455, CPU 0, comm: sh
psr : 0000101008526030 ifs : 8000000000000fa4 ip : [<a0000001008c40f0>] Not tainted (3.6.0-rc1)
ip is at offline_pages+0x210/0xee0
unat: 0000000000000000 pfs : 0000000000000fa4 rsc : 0000000000000003
rnat: a0000001008f2d50 bsps: 0000000000000000 pr : 65519a96659a9565
ldrs: 0000000000000000 ccv : 0000010b9263f310 fpsr: 0009804c0270033f csd : 0000000000000000 ssd : 0000000000000000
b0 : a0000001008c40f0 b6 : a000000100473980 b7 : a0000001000106d0 f6 : 000000000000000000000 f7 : 1003e0000000085c9354c f8 : 1003e0044b82fa09b5a53 f9 : 1003e000000d65cd62abf f10 : 1003efd02efdec682803d f11 : 1003e0000000000000042 r1 : a00000010152c2e0 r2 : 0000000000006ada r3 : 000000000000fffe r8 : 0000000000000026 r9 : a00000010121cc18 r10 : a0000001013309f0 r11 : 65519a96659a19e9 r12 : e00000070a91fdf0 r13 : e00000070a910000 r14 : 0000000000006ada r15 : 0000000000004000 r16 : 000000006ad8356c r17 : a0000001019a525e r18 : 0000000000007fff r19 : 0000000000000000 r20 : 0000000000006ad6 r21 : 0000000000006ad6 r22 : a00000010133bec8 r23 : 0000000000006ad4 r24 : 0000000000000002 r25 : 8200000000260038 r26 : 00000000000004f9 r27 : 00000000000004f8 r28 : 000000000001cf98 r29 : 0000000000000038 r30 : a0000001019a5ae0 r31 : 000000000001cf60

Call Trace:
 [<a0000001000163e0>] show_stack+0x80/0xa0
                                spà0000070a91f9b0 bspà0000070a9115e0
 [<a000000100016a40>] show_regs+0x640/0x920
                                spà0000070a91fb80 bspà0000070a911588
 [<a000000100040590>] die+0x190/0x2c0
                                spà0000070a91fb90 bspà0000070a911548
 [<a000000100040710>] die_if_kernel+0x50/0x80
                                spà0000070a91fb90 bspà0000070a911518
 [<a0000001008f8030>] ia64_bad_break+0x3d0/0x6e0
                                spà0000070a91fb90 bspà0000070a9114f0
 [<a00000010000c0c0>] ia64_native_leave_kernel+0x0/0x270
                                spà0000070a91fc20 bspà0000070a9114f0
 [<a0000001008c40f0>] offline_pages+0x210/0xee0
                                spà0000070a91fdf0 bspà0000070a9113c8
 [<a00000010022d580>] alloc_pages_current+0x180/0x2a0
                                spà0000070a91fe20 bspà0000070a9113a
Quoted 1 line

This patch is trying to fix the bug.

not just trying ;)

Quoted 2 lines
Quoted 17 lines
---
 include/linux/memory.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
include/linux/memory.h +1 -1
index 1ac7f6e..ff9a9f8 100644
@@ -19,7 +19,7 @@
 #include <linux/compiler.h>
 #include <linux/mutex.h>
 
-#define MIN_MEMORY_BLOCK_SIZE     (1 << SECTION_SIZE_BITS)
+#define MIN_MEMORY_BLOCK_SIZE     (1UL << SECTION_SIZE_BITS)
 
 struct memory_block {
 	unsigned long start_section_nr;
Signature · 2 lines
Michal Hocko
SUSE Labs
author
#2 lore raw

Hi Michal,
Thanks for your comments and review.

Quoted 5 lines · Michal Hocko

[Fixed gregkh email address]

Quoted 2 lines · wujianguo

From: Jianguo Wu <[email protected]>

Quoted 8 lines
Quoted 4 lines

Hi all,
I found following definition in include/linux/memory.h, in my IA64
platform, SECTION_SIZE_BITS is equal to 32, and MIN_MEMORY_BLOCK_SIZE will be 0.

	#define MIN_MEMORY_BLOCK_SIZE     (1 << SECTION_SIZE_BITS)

OK, so I assume you have CONFIG_FORCE_MAX_ZONEORDER 17 and PAGE_SHIFT 16, right? But even CONFIG_FORCE_MAX_ZONEORDER 16 would be a problem.

Yes, you are right, CONFIG_FORCE_MAX_ZONEORDER 16 would be a problem too.

Quoted 8 lines
Quoted 5 lines

Because MIN_MEMORY_BLOCK_SIZE is 32bits, so MIN_MEMORY_BLOCK_SIZE(1 << 32)
will equal to 0. This will cause wrong system memory infomation in sysfs. I think it should be:

	#define MIN_MEMORY_BLOCK_SIZE     (1UL << SECTION_SIZE_BITS)

I guess the part below is not necessary for the changelog

Thanks for your suggestion, I will delete them in version 2.

Quoted 97 lines
Quoted 10 lines

linux-drf:/sys/devices/system/memory # ll
total 0
-r--r--r-- 1 root root 65536 Aug 20 02:35 block_size_bytes
drwxr-xr-x 3 root root 0 Aug 20 02:19 memory0
drwxr-xr-x 2 root root 0 Aug 20 02:35 power
-rw-r--r-- 1 root root 65536 Aug 20 02:35 uevent

linux-drf:/sys/devices/system/memory # cat block_size_bytes 0

Quoted 13 lines

linux-drf:/sys/devices/system/memory/memory0 # cat * 8000000000000000
cat: node0: Is a directory
cat: node1: Is a directory
cat: node2: Is a directory
cat: node3: Is a directory
0
8000000000000000
cat: power: Is a directory
1
online
cat: subsystem: Is a directory

Up to here.

Quoted 44 lines

And "echo offline > memory0/state" will cause following call trace:

kernel BUG at mm/memory_hotplug.c:885!
sh[6455]: bugcheck! 0 [1]

Pid: 6455, CPU 0, comm: sh
psr : 0000101008526030 ifs : 8000000000000fa4 ip : [<a0000001008c40f0>] Not tainted (3.6.0-rc1)
ip is at offline_pages+0x210/0xee0
unat: 0000000000000000 pfs : 0000000000000fa4 rsc : 0000000000000003
rnat: a0000001008f2d50 bsps: 0000000000000000 pr : 65519a96659a9565
ldrs: 0000000000000000 ccv : 0000010b9263f310 fpsr: 0009804c0270033f csd : 0000000000000000 ssd : 0000000000000000
b0 : a0000001008c40f0 b6 : a000000100473980 b7 : a0000001000106d0 f6 : 000000000000000000000 f7 : 1003e0000000085c9354c f8 : 1003e0044b82fa09b5a53 f9 : 1003e000000d65cd62abf f10 : 1003efd02efdec682803d f11 : 1003e0000000000000042 r1 : a00000010152c2e0 r2 : 0000000000006ada r3 : 000000000000fffe r8 : 0000000000000026 r9 : a00000010121cc18 r10 : a0000001013309f0 r11 : 65519a96659a19e9 r12 : e00000070a91fdf0 r13 : e00000070a910000 r14 : 0000000000006ada r15 : 0000000000004000 r16 : 000000006ad8356c r17 : a0000001019a525e r18 : 0000000000007fff r19 : 0000000000000000 r20 : 0000000000006ad6 r21 : 0000000000006ad6 r22 : a00000010133bec8 r23 : 0000000000006ad4 r24 : 0000000000000002 r25 : 8200000000260038 r26 : 00000000000004f9 r27 : 00000000000004f8 r28 : 000000000001cf98 r29 : 0000000000000038 r30 : a0000001019a5ae0 r31 : 000000000001cf60

Call Trace:
 [<a0000001000163e0>] show_stack+0x80/0xa0
                                spà0000070a91f9b0 bspà0000070a9115e0
 [<a000000100016a40>] show_regs+0x640/0x920
                                spà0000070a91fb80 bspà0000070a911588
 [<a000000100040590>] die+0x190/0x2c0
                                spà0000070a91fb90 bspà0000070a911548
 [<a000000100040710>] die_if_kernel+0x50/0x80
                                spà0000070a91fb90 bspà0000070a911518
 [<a0000001008f8030>] ia64_bad_break+0x3d0/0x6e0
                                spà0000070a91fb90 bspà0000070a9114f0
 [<a00000010000c0c0>] ia64_native_leave_kernel+0x0/0x270
                                spà0000070a91fc20 bspà0000070a9114f0
 [<a0000001008c40f0>] offline_pages+0x210/0xee0
                                spà0000070a91fdf0 bspà0000070a9113c8
 [<a00000010022d580>] alloc_pages_current+0x180/0x2a0
                                spà0000070a91fe20 bspà0000070a9113a
Quoted 1 line

This patch is trying to fix the bug.

not just trying ;)

Quoted 2 lines
Quoted 17 lines
---
 include/linux/memory.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
include/linux/memory.h +1 -1
index 1ac7f6e..ff9a9f8 100644
@@ -19,7 +19,7 @@
 #include <linux/compiler.h>
 #include <linux/mutex.h>
 
-#define MIN_MEMORY_BLOCK_SIZE     (1 << SECTION_SIZE_BITS)
+#define MIN_MEMORY_BLOCK_SIZE     (1UL << SECTION_SIZE_BITS)
 
 struct memory_block {
 	unsigned long start_section_nr;