The patch titled Subject: proc/kcore: don't grab lock for memory hotplug notifier has been added to the -mm tree. Its filename is proc-kcore-dont-grab-lock-for-memory-hotplug-notifier.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/proc-kcore-dont-grab-lock-for-memory-hotplug-notifier.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/proc-kcore-dont-grab-lock-for-memory-hotplug-notifier.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Omar Sandoval <osandov@xxxxxx> Subject: proc/kcore: don't grab lock for memory hotplug notifier The memory hotplug notifier kcore_callback() only needs kclist_lock to prevent races with __kcore_update_ram(), but we can easily eliminate that race by using an atomic xchg() in __kcore_update_ram(). This is preparation for converting kclist_lock to an rwsem. Link: http://lkml.kernel.org/r/0a4bc89f4dbde8b5b2ea309f7b4fb6a85fe29df2.1531953780.git.osandov@xxxxxx Signed-off-by: Omar Sandoval <osandov@xxxxxx> Reviewed-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> Cc: Alexey Dobriyan <adobriyan@xxxxxxxxx> Cc: Bhupesh Sharma <bhsharma@xxxxxxxxxx> Cc: Eric Biederman <ebiederm@xxxxxxxxxxxx> Cc: James Morse <james.morse@xxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- fs/proc/kcore.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff -puN fs/proc/kcore.c~proc-kcore-dont-grab-lock-for-memory-hotplug-notifier fs/proc/kcore.c --- a/fs/proc/kcore.c~proc-kcore-dont-grab-lock-for-memory-hotplug-notifier +++ a/fs/proc/kcore.c @@ -118,7 +118,7 @@ static void __kcore_update_ram(struct li LIST_HEAD(garbage); write_lock(&kclist_lock); - if (kcore_need_update) { + if (xchg(&kcore_need_update, 0)) { list_for_each_entry_safe(pos, tmp, &kclist_head, list) { if (pos->type == KCORE_RAM || pos->type == KCORE_VMEMMAP) @@ -127,7 +127,6 @@ static void __kcore_update_ram(struct li list_splice_tail(list, &kclist_head); } else list_splice(list, &garbage); - kcore_need_update = 0; proc_root_kcore->size = get_kcore_size(&nphdr, &size); write_unlock(&kclist_lock); @@ -593,9 +592,8 @@ static int __meminit kcore_callback(stru switch (action) { case MEM_ONLINE: case MEM_OFFLINE: - write_lock(&kclist_lock); kcore_need_update = 1; - write_unlock(&kclist_lock); + break; } return NOTIFY_OK; } _ Patches currently in -mm which might be from osandov@xxxxxx are proc-kcore-dont-grab-lock-for-kclist_add.patch proc-kcore-dont-grab-lock-for-memory-hotplug-notifier.patch proc-kcore-replace-kclist_lock-rwlock-with-rwsem.patch proc-kcore-fix-memory-hotplug-vs-multiple-opens-race.patch proc-kcore-hold-lock-during-read.patch proc-kcore-clean-up-elf-header-generation.patch proc-kcore-optimize-multiple-page-reads.patch proc-kcore-add-vmcoreinfo-note-to-proc-kcore.patch -- To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html