The patch titled Subject: mm/swap.c: workaround for_each_cpu() bug on UP kernel has been added to the -mm tree. Its filename is mm-swapc-workaround-for_each_cpu-bug-on-up-kernel.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/mm-swapc-workaround-for_each_cpu-bug-on-up-kernel.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/mm-swapc-workaround-for_each_cpu-bug-on-up-kernel.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: Tetsuo Handa <penguin-kernel@xxxxxxxxxxxxxxxxxxx> Subject: mm/swap.c: workaround for_each_cpu() bug on UP kernel Since for_each_cpu(cpu, mask) added by commit 2d3854a37e8b767a ("cpumask: introduce new API, without changing anything") did not evaluate the mask argument if NR_CPUS == 1 due to CONFIG_SMP=n, lru_add_drain_all() is hitting WARN_ON() at __flush_work() added by commit 4d43d395fed12463 ("workqueue: Try to catch flush_work() without INIT_WORK().") by unconditionally calling flush_work() [1]. We should fix for_each_cpu() etc. but we need enough grace period for allowing people to test and fix unexpected behaviors including build failures. Therefore, this patch temporarily duplicates flush_work() for NR_CPUS == 1 case. This patch will be reverted after for_each_cpu() etc. are fixed. [1] https://lkml.kernel.org/r/18a30387-6aa5-6123-e67c-57579ecc3f38@xxxxxxxxxxxx Link: http://lkml.kernel.org/r/1549533189-9177-1-git-send-email-penguin-kernel@xxxxxxxxxxxxxxxxxxx Signed-off-by: Tetsuo Handa <penguin-kernel@xxxxxxxxxxxxxxxxxxx> Reported-by: Guenter Roeck <linux@xxxxxxxxxxxx> Acked-by: Guenter Roeck <linux@xxxxxxxxxxxx> Reviewed by: William Kucharski <william.kucharski@xxxxxxxxxx> Cc: Chris Metcalf <chris.d.metcalf@xxxxxxxxx> Cc: Rusty Russell <rusty@xxxxxxxxxxxxxxx> Cc: Tejun Heo <tj@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- --- a/mm/swap.c~mm-swapc-workaround-for_each_cpu-bug-on-up-kernel +++ a/mm/swap.c @@ -694,11 +694,16 @@ void lru_add_drain_all(void) INIT_WORK(work, lru_add_drain_per_cpu); queue_work_on(cpu, mm_percpu_wq, work); cpumask_set_cpu(cpu, &has_work); +#if NR_CPUS == 1 + flush_work(work); +#endif } } +#if NR_CPUS != 1 for_each_cpu(cpu, &has_work) flush_work(&per_cpu(lru_add_drain_work, cpu)); +#endif mutex_unlock(&lock); } _ Patches currently in -mm which might be from penguin-kernel@xxxxxxxxxxxxxxxxxxx are mm-swapc-workaround-for_each_cpu-bug-on-up-kernel.patch memcg-killed-threads-should-not-invoke-memcg-oom-killer.patch mmoom-dont-kill-global-init-via-memoryoomgroup.patch info-task-hung-in-generic_file_write_iter.patch info-task-hung-in-generic_file_write-fix.patch