Skip to content

Commit 6ea183d

Browse files
Michal Hockotorvalds
authored andcommitted
mm: handle lru_add_drain_all for UP properly
Since for_each_cpu(cpu, mask) added by commit 2d3854a ("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 4d43d39 ("workqueue: Try to catch flush_work() without INIT_WORK().") by unconditionally calling flush_work() [1]. Workaround this issue by using CONFIG_SMP=n specific lru_add_drain_all implementation. There is no real need to defer the implementation to the workqueue as the draining is going to happen on the local cpu. So alias lru_add_drain_all to lru_add_drain which does all the necessary work. [akpm@linux-foundation.org: fix various build warnings] [1] https://lkml.kernel.org/r/18a30387-6aa5-6123-e67c-57579ecc3f38@roeck-us.net Link: http://lkml.kernel.org/r/20190213124334.GH4525@dhcp22.suse.cz Signed-off-by: Michal Hocko <mhocko@suse.com> Reported-by: Guenter Roeck <linux@roeck-us.net> Debugged-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> Cc: Tejun Heo <tj@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 94b3334 commit 6ea183d

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

mm/swap.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -320,11 +320,6 @@ static inline void activate_page_drain(int cpu)
320320
{
321321
}
322322

323-
static bool need_activate_page_drain(int cpu)
324-
{
325-
return false;
326-
}
327-
328323
void activate_page(struct page *page)
329324
{
330325
struct zone *zone = page_zone(page);
@@ -653,13 +648,15 @@ void lru_add_drain(void)
653648
put_cpu();
654649
}
655650

651+
#ifdef CONFIG_SMP
652+
653+
static DEFINE_PER_CPU(struct work_struct, lru_add_drain_work);
654+
656655
static void lru_add_drain_per_cpu(struct work_struct *dummy)
657656
{
658657
lru_add_drain();
659658
}
660659

661-
static DEFINE_PER_CPU(struct work_struct, lru_add_drain_work);
662-
663660
/*
664661
* Doesn't need any cpu hotplug locking because we do rely on per-cpu
665662
* kworkers being shut down before our page_alloc_cpu_dead callback is
@@ -702,6 +699,12 @@ void lru_add_drain_all(void)
702699

703700
mutex_unlock(&lock);
704701
}
702+
#else
703+
void lru_add_drain_all(void)
704+
{
705+
lru_add_drain();
706+
}
707+
#endif
705708

706709
/**
707710
* release_pages - batched put_page()

0 commit comments

Comments
 (0)