The patch titled Subject: proc/kcore: don't grab lock for kclist_add() has been added to the -mm tree. Its filename is proc-kcore-dont-grab-lock-for-kclist_add.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/proc-kcore-dont-grab-lock-for-kclist_add.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/proc-kcore-dont-grab-lock-for-kclist_add.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 kclist_add() Patch series "/proc/kcore improvements", v3. This series makes a few improvements to /proc/kcore. Patches 1, 2, and 3 are prep patches. Patch 4 is a fix/cleanup. Patch 5 is another prep patch. Patches 6 and 7 are optimizations to ->read(). Patch 8 adds vmcoreinfo to /proc/kcore. This patch (of 8): kclist_add() is only called at init time, so there's no point in grabbing any locks. We're also going to replace the rwlock with a rwsem, which we don't want to try grabbing during early boot. While we're here, mark kclist_add() with __init so that we'll get a warning if it's called from non-init code. Link: http://lkml.kernel.org/r/98208db1faf167aa8b08eebfa968d95c70527739.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 | 7 +++---- include/linux/kcore.h | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff -puN fs/proc/kcore.c~proc-kcore-dont-grab-lock-for-kclist_add fs/proc/kcore.c --- a/fs/proc/kcore.c~proc-kcore-dont-grab-lock-for-kclist_add +++ a/fs/proc/kcore.c @@ -62,16 +62,15 @@ static LIST_HEAD(kclist_head); static DEFINE_RWLOCK(kclist_lock); static int kcore_need_update = 1; -void -kclist_add(struct kcore_list *new, void *addr, size_t size, int type) +/* This doesn't grab kclist_lock, so it should only be used at init time. */ +void __init kclist_add(struct kcore_list *new, void *addr, size_t size, + int type) { new->addr = (unsigned long)addr; new->size = size; new->type = type; - write_lock(&kclist_lock); list_add_tail(&new->list, &kclist_head); - write_unlock(&kclist_lock); } static size_t get_kcore_size(int *nphdr, size_t *elf_buflen) diff -puN include/linux/kcore.h~proc-kcore-dont-grab-lock-for-kclist_add include/linux/kcore.h --- a/include/linux/kcore.h~proc-kcore-dont-grab-lock-for-kclist_add +++ a/include/linux/kcore.h @@ -35,7 +35,7 @@ struct vmcoredd_node { }; #ifdef CONFIG_PROC_KCORE -extern void kclist_add(struct kcore_list *, void *, size_t, int type); +void __init kclist_add(struct kcore_list *, void *, size_t, int type); #else static inline void kclist_add(struct kcore_list *new, void *addr, size_t size, int type) _ 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