diff options
author | Wang Sheng-Hui <shhuiw@foxmail.com> | 2016-06-08 18:33:56 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-06-09 17:23:11 -0400 |
commit | f3a932baa7f65072434f1c04c02c8a4d2746fcfc (patch) | |
tree | 82a75a1d6fc3b7113b7530646918d64b4e18da88 /mm | |
parent | ba62bafe942b159a6109cbec780d36496e06b6c5 (diff) |
mm: introduce dedicated WQ_MEM_RECLAIM workqueue to do lru_add_drain_all
This patch is based on https://patchwork.ozlabs.org/patch/574623/.
Tejun submitted commit 23d11a58a9a6 ("workqueue: skip flush dependency
checks for legacy workqueues") for the legacy create*_workqueue()
interface.
But some workq created by alloc_workqueue still reports warning on
memory reclaim, e.g nvme_workq with flag WQ_MEM_RECLAIM set:
workqueue: WQ_MEM_RECLAIM nvme:nvme_reset_work is flushing !WQ_MEM_RECLAIM events:lru_add_drain_per_cpu
------------[ cut here ]------------
WARNING: CPU: 0 PID: 6 at SoC/linux/kernel/workqueue.c:2448 check_flush_dependency+0xb4/0x10c
...
check_flush_dependency+0xb4/0x10c
flush_work+0x54/0x140
lru_add_drain_all+0x138/0x188
migrate_prep+0xc/0x18
alloc_contig_range+0xf4/0x350
cma_alloc+0xec/0x1e4
dma_alloc_from_contiguous+0x38/0x40
__dma_alloc+0x74/0x25c
nvme_alloc_queue+0xcc/0x36c
nvme_reset_work+0x5c4/0xda8
process_one_work+0x128/0x2ec
worker_thread+0x58/0x434
kthread+0xd4/0xe8
ret_from_fork+0x10/0x50
That's because lru_add_drain_all() will schedule the drain work on
system_wq, whose flag is set to 0, !WQ_MEM_RECLAIM.
Introduce a dedicated WQ_MEM_RECLAIM workqueue to do
lru_add_drain_all(), aiding in getting memory freed.
Link: http://lkml.kernel.org/r/1464917521-9775-1-git-send-email-shhuiw@foxmail.com
Signed-off-by: Wang Sheng-Hui <shhuiw@foxmail.com>
Acked-by: Tejun Heo <tj@kernel.org>
Cc: Keith Busch <keith.busch@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thierry Reding <treding@nvidia.com>
Cc: Ingo Molnar <mingo@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm')
-rw-r--r-- | mm/swap.c | 20 |
1 files changed, 19 insertions, 1 deletions
@@ -667,6 +667,24 @@ static void lru_add_drain_per_cpu(struct work_struct *dummy) | |||
667 | 667 | ||
668 | static DEFINE_PER_CPU(struct work_struct, lru_add_drain_work); | 668 | static DEFINE_PER_CPU(struct work_struct, lru_add_drain_work); |
669 | 669 | ||
670 | /* | ||
671 | * lru_add_drain_wq is used to do lru_add_drain_all() from a WQ_MEM_RECLAIM | ||
672 | * workqueue, aiding in getting memory freed. | ||
673 | */ | ||
674 | static struct workqueue_struct *lru_add_drain_wq; | ||
675 | |||
676 | static int __init lru_init(void) | ||
677 | { | ||
678 | lru_add_drain_wq = alloc_workqueue("lru-add-drain", WQ_MEM_RECLAIM, 0); | ||
679 | |||
680 | if (WARN(!lru_add_drain_wq, | ||
681 | "Failed to create workqueue lru_add_drain_wq")) | ||
682 | return -ENOMEM; | ||
683 | |||
684 | return 0; | ||
685 | } | ||
686 | early_initcall(lru_init); | ||
687 | |||
670 | void lru_add_drain_all(void) | 688 | void lru_add_drain_all(void) |
671 | { | 689 | { |
672 | static DEFINE_MUTEX(lock); | 690 | static DEFINE_MUTEX(lock); |
@@ -686,7 +704,7 @@ void lru_add_drain_all(void) | |||
686 | pagevec_count(&per_cpu(lru_deactivate_pvecs, cpu)) || | 704 | pagevec_count(&per_cpu(lru_deactivate_pvecs, cpu)) || |
687 | need_activate_page_drain(cpu)) { | 705 | need_activate_page_drain(cpu)) { |
688 | INIT_WORK(work, lru_add_drain_per_cpu); | 706 | INIT_WORK(work, lru_add_drain_per_cpu); |
689 | schedule_work_on(cpu, work); | 707 | queue_work_on(cpu, lru_add_drain_wq, work); |
690 | cpumask_set_cpu(cpu, &has_work); | 708 | cpumask_set_cpu(cpu, &has_work); |
691 | } | 709 | } |
692 | } | 710 | } |