The patch titled Subject: mm/damon/reclaim: schedule 'damon_reclaim_timer' only after 'system_wq' is initialized has been added to the -mm mm-hotfixes-unstable branch. Its filename is mm-damon-reclaim-schedule-damon_reclaim_timer-only-after-system_wq-is-initialized.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-damon-reclaim-schedule-damon_reclaim_timer-only-after-system_wq-is-initialized.patch This patch will later appear in the mm-hotfixes-unstable branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm 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 via the mm-everything branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there every 2-3 working days ------------------------------------------------------ From: SeongJae Park <sj@xxxxxxxxxx> Subject: mm/damon/reclaim: schedule 'damon_reclaim_timer' only after 'system_wq' is initialized Date: Sat, 4 Jun 2022 19:50:51 +0000 Commit 059342d1dd4e ("mm/damon/reclaim: fix the timer always stays active") made DAMON_RECLAIM's 'enabled' parameter store callback, 'enabled_store()', to schedule 'damon_reclaim_timer'. The scheduling uses 'system_wq', which is initialized in 'workqueue_init_early()'. As kernel parameters parsing function ('parse_args()') is called before 'workqueue_init_early()', 'enabled_store()' can be executed before 'workqueue_init_early()' and end up accessing the uninitialized 'system_wq'. As a result, the booting hang[1]. This commit fixes the issue by checking if the initialization is done before scheduling the timer. [1] https://lkml.kernel.org/20220604192222.1488-1-sj@xxxxxxxxxx/ Link: https://lkml.kernel.org/r/20220604195051.1589-1-sj@xxxxxxxxxx Fixes: 059342d1dd4e ("mm/damon/reclaim: fix the timer always stays active") Signed-off-by: SeongJae Park <sj@xxxxxxxxxx> Reported-by: Greg White <gwhite@xxxxxxxxxxx> Cc: Hailong Tu <tuhailong@xxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/damon/reclaim.c | 8 ++++++++ 1 file changed, 8 insertions(+) --- a/mm/damon/reclaim.c~mm-damon-reclaim-schedule-damon_reclaim_timer-only-after-system_wq-is-initialized +++ a/mm/damon/reclaim.c @@ -374,6 +374,8 @@ static void damon_reclaim_timer_fn(struc } static DECLARE_DELAYED_WORK(damon_reclaim_timer, damon_reclaim_timer_fn); +static bool damon_reclaim_initialized; + static int enabled_store(const char *val, const struct kernel_param *kp) { @@ -382,6 +384,10 @@ static int enabled_store(const char *val if (rc < 0) return rc; + /* system_wq might not initialized yet */ + if (!damon_reclaim_initialized) + return rc; + if (enabled) schedule_delayed_work(&damon_reclaim_timer, 0); @@ -449,6 +455,8 @@ static int __init damon_reclaim_init(voi damon_add_target(ctx, target); schedule_delayed_work(&damon_reclaim_timer, 0); + + damon_reclaim_initialized = true; return 0; } _ Patches currently in -mm which might be from sj@xxxxxxxxxx are mm-damon-reclaim-schedule-damon_reclaim_timer-only-after-system_wq-is-initialized.patch docs-admin-guide-damon-reclaim-remove-a-paragraph-that-been-obsolete-due-to-online-tuning-support.patch mm-damon-dbgfssysfs-move-target_has_pid-from-dbgfs-to-damonh.patch mm-damon-reclaim-deduplicate-commit_inputs-handling.patch mm-damon-sysfs-deduplicate-inputs-applying.patch mm-damon-reclaim-make-enabled-checking-timer-simpler.patch mm-damon-reclaim-add-damon_reclaim_-prefix-to-enabled_store.patch