On 05/25/2014 10:41 AM, DX Cui wrote: > On Fri, May 23, 2014 at 8:27 PM, DX Cui <rijcos@xxxxxxxxx> wrote: >> Hi all, >> I think I found out the root cause: when memory hotplug was introduced in 2005: >> https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=3947be1969a9ce455ec30f60ef51efb10e4323d1 >> there was a race condition in: >> >> + static int add_memory_block(unsigned long node_id, struct >> mem_section *section, >> + unsigned long state, int phys_device) >> +{ >> ... >> + ret = register_memory(mem, section, NULL); >> + if (!ret) >> + ret = mem_create_simple_file(mem, phys_index); >> + if (!ret) >> + ret = mem_create_simple_file(mem, state); >> >> Here, first, add_memory_block() invokes register_memory() -> >> sysdev_register() -> sysdev_add()-> >> kobject_uevent(&sysdev->kobj, KOBJ_ADD) to notify udev daemon, then >> invokes mem_create_simple_file(). If the current execution is preempted >> between the 2 steps, the issue I reported in the previous mail can happen. >> >> Luckily a commit in 2013 has fixed this issue undesignedly: >> https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=96b2c0fc8e74a615888e2bedfe55b439aa4695e1 >> >> It looks the new "register_memory() --> ... -> device_add()" path has the >> correct order for sysfs creation and notification udev. >> Correct. that patch does fix this issue, though that was not the primary reason for doing the patch. Always nice when a patch has unintended positive side affects. >> It would be great if you can confirm my analysis. :-) > > Any comments? > I think we need to backport the patch > 96b2c0fc8e74a615888e2bedfe55b439aa4695e1 to <=3.9 stable kernels. > Although I have seen any issues because of this issue I agree that the fix should be backported. Best to get rid of a known race condition before it jumps up and bites us. -Nathan -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@xxxxxxxxx. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"dont@xxxxxxxxx"> email@xxxxxxxxx </a>