Re: memory hot-add: the kernel can notify udev daemon before creating the sys file state?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.
>
> 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.

-- DX

--
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>




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]