* [PATCH v3] memory-hotplug: Fix kernel warning during memory hotplug on ppc64
@ 2016-01-06 21:35 John Allen
2016-01-06 21:49 ` kbuild test robot
0 siblings, 1 reply; 2+ messages in thread
From: John Allen @ 2016-01-06 21:35 UTC (permalink / raw)
To: gregkh
Cc: Nathan Fontenot, akpm, linux-kernel, linuxppc-dev, Michael Ellerman
This patch fixes a bug where a kernel warning is triggered when performing
a memory hotplug on ppc64. This warning may also occur on any architecture
that uses the memory_probe_store interface.
WARNING: at drivers/base/memory.c:200
CPU: 9 PID: 13042 Comm: systemd-udevd Not tainted 4.4.0-rc4-00113-g0bd0f1e-dirty #7
NIP [c00000000055e034] pages_correctly_reserved+0x134/0x1b0
LR [c00000000055e7f8] memory_subsys_online+0x68/0x140
Call Trace:
[c0000000fa9e7b50] [c0000000fa9e7b90] 0xc0000000fa9e7b90 (unreliable)
[c0000000fa9e7bb0] [c00000000055e7f8] memory_subsys_online+0x68/0x140
[c0000000fa9e7bf0] [c000000000540064] device_online+0xb4/0x120
[c0000000fa9e7c30] [c00000000055e6c0] store_mem_state+0xb0/0x180
[c0000000fa9e7c70] [c00000000053c5e4] dev_attr_store+0x34/0x60
[c0000000fa9e7c90] [c0000000002db0a4] sysfs_kf_write+0x64/0xa0
[c0000000fa9e7cb0] [c0000000002da0cc] kernfs_fop_write+0x17c/0x1e0
[c0000000fa9e7d00] [c0000000002481b0] __vfs_write+0x40/0x160
[c0000000fa9e7d90] [c000000000248ce8] vfs_write+0xb8/0x200
[c0000000fa9e7de0] [c000000000249b40] SyS_write+0x60/0x110
[c0000000fa9e7e30] [c000000000009260] system_call+0x38/0xd0
The warning is triggered because there is a udev rule that automatically
tries to online memory after it has been added. The udev rule varies from
distro to distro, but will generally look something like:
SUBSYSTEM=="memory", ACTION=="add", ATTR{state}=="offline", ATTR{state}="online"
On any architecture that uses memory_probe_store to reserve memory, the
udev rule will be triggered after the first section of the block is
reserved and will subsequently attempt to online the entire block,
interrupting the memory reservation process and causing the warning.
This patch modifies memory_probe_store to add a block of memory with
a single call to add_memory as opposed to looping through and adding
each section individually. A single call to add_memory is protected by
the mem_hotplug mutex which will prevent the udev rule from onlining
memory until the reservation of the entire block is complete.
Signed-off-by: John Allen <jallen@linux.vnet.ibm.com>
---
v2: -Move call to unlock_device_hotplug under "out" label
v3: -Update changelog with trimmed traces from newer kernel
-After further testing and reviewing the original purpose of
the lock_device_hotplug_sysfs mutex, modified solution to
fix the issue by replacing loop that adds memory section
by section with a single call to add_memory.
diff --git a/drivers/base/memory.c b/drivers/base/memory.c
index 25425d3..e15ddb65 100644
--- a/drivers/base/memory.c
+++ b/drivers/base/memory.c
@@ -461,15 +461,12 @@ memory_probe_store(struct device *dev, struct device_attribute *attr,
if (phys_addr & ((pages_per_block << PAGE_SHIFT) - 1))
return -EINVAL;
- for (i = 0; i < sections_per_block; i++) {
- nid = memory_add_physaddr_to_nid(phys_addr);
- ret = add_memory(nid, phys_addr,
- PAGES_PER_SECTION << PAGE_SHIFT);
- if (ret)
- goto out;
+ nid = memory_add_physaddr_to_nid(phys_addr);
+ ret = add_memory(nid, phys_addr,
+ MIN_MEMORY_BLOCK_SIZE * sections_per_block);
- phys_addr += MIN_MEMORY_BLOCK_SIZE;
- }
+ if (ret)
+ goto out;
ret = count;
out:
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v3] memory-hotplug: Fix kernel warning during memory hotplug on ppc64
2016-01-06 21:35 [PATCH v3] memory-hotplug: Fix kernel warning during memory hotplug on ppc64 John Allen
@ 2016-01-06 21:49 ` kbuild test robot
0 siblings, 0 replies; 2+ messages in thread
From: kbuild test robot @ 2016-01-06 21:49 UTC (permalink / raw)
To: John Allen
Cc: kbuild-all, gregkh, Nathan Fontenot, akpm, linux-kernel,
linuxppc-dev, Michael Ellerman
[-- Attachment #1: Type: text/plain, Size: 2931 bytes --]
Hi John,
[auto build test WARNING on v4.4-rc8]
[also build test WARNING on next-20160106]
[if your patch is applied to the wrong git tree, please drop us a note to help improving the system]
url: https://github.com/0day-ci/linux/commits/John-Allen/memory-hotplug-Fix-kernel-warning-during-memory-hotplug-on-ppc64/20160107-053749
config: x86_64-randconfig-x017-01041832 (attached as .config)
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64
All warnings (new ones prefixed by >>):
drivers/base/memory.c: In function 'memory_probe_store':
>> drivers/base/memory.c:454:6: warning: unused variable 'i' [-Wunused-variable]
int i, ret;
^
vim +/i +454 drivers/base/memory.c
3947be19 Dave Hansen 2005-10-29 438
10fbcf4c Kay Sievers 2011-12-21 439 static DEVICE_ATTR(block_size_bytes, 0444, print_block_size, NULL);
3947be19 Dave Hansen 2005-10-29 440
3947be19 Dave Hansen 2005-10-29 441 /*
3947be19 Dave Hansen 2005-10-29 442 * Some architectures will have custom drivers to do this, and
3947be19 Dave Hansen 2005-10-29 443 * will not need to do it from userspace. The fake hot-add code
3947be19 Dave Hansen 2005-10-29 444 * as well as ppc64 will do all of their discovery in userspace
3947be19 Dave Hansen 2005-10-29 445 * and will require this interface.
3947be19 Dave Hansen 2005-10-29 446 */
3947be19 Dave Hansen 2005-10-29 447 #ifdef CONFIG_ARCH_MEMORY_PROBE
3947be19 Dave Hansen 2005-10-29 448 static ssize_t
10fbcf4c Kay Sievers 2011-12-21 449 memory_probe_store(struct device *dev, struct device_attribute *attr,
28812fe1 Andi Kleen 2010-01-05 450 const char *buf, size_t count)
3947be19 Dave Hansen 2005-10-29 451 {
3947be19 Dave Hansen 2005-10-29 452 u64 phys_addr;
bc02af93 Yasunori Goto 2006-06-27 453 int nid;
6add7cd6 Nathan Fontenot 2011-01-31 @454 int i, ret;
61b94fea Anton Blanchard 2011-09-15 455 unsigned long pages_per_block = PAGES_PER_SECTION * sections_per_block;
3947be19 Dave Hansen 2005-10-29 456
b69deb2b Zhang Zhen 2014-08-06 457 ret = kstrtoull(buf, 0, &phys_addr);
b69deb2b Zhang Zhen 2014-08-06 458 if (ret)
b69deb2b Zhang Zhen 2014-08-06 459 return ret;
3947be19 Dave Hansen 2005-10-29 460
61b94fea Anton Blanchard 2011-09-15 461 if (phys_addr & ((pages_per_block << PAGE_SHIFT) - 1))
61b94fea Anton Blanchard 2011-09-15 462 return -EINVAL;
:::::: The code at line 454 was first introduced by commit
:::::: 6add7cd618b4d4dc525731beb539c5e06e891855 memory hotplug: sysfs probe routine should add all memory sections
:::::: TO: Nathan Fontenot <nfont@austin.ibm.com>
:::::: CC: Greg Kroah-Hartman <gregkh@suse.de>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[-- Attachment #2: .config.gz --]
[-- Type: application/octet-stream, Size: 22761 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-01-06 21:50 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-06 21:35 [PATCH v3] memory-hotplug: Fix kernel warning during memory hotplug on ppc64 John Allen
2016-01-06 21:49 ` kbuild test robot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).