mm: ksm: remove unnecessary try_to_freeze()
authorKevin Hao <haokexin@gmail.com>
Wed, 13 Dec 2023 09:09:06 +0000 (17:09 +0800)
committerAndrew Morton <akpm@linux-foundation.org>
Wed, 20 Dec 2023 22:48:13 +0000 (14:48 -0800)
A freezable kernel thread can enter frozen state during freezing by
either calling try_to_freeze() or using wait_event_freezable() and its
variants. However, there is no need to use both methods simultaneously.

Link: https://lkml.kernel.org/r/20231213090906.1070985-1-haokexin@gmail.com
Signed-off-by: Kevin Hao <haokexin@gmail.com>
Acked-by: David Hildenbrand <david@redhat.com>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/ksm.c

index b93389a3780e04bb59e58da985984b1052cc9d54..c0e1995fb4449a1803eb5228fbbf9a310497326b 100644 (file)
--- a/mm/ksm.c
+++ b/mm/ksm.c
@@ -2604,11 +2604,9 @@ static int ksm_scan_thread(void *nothing)
                        ksm_do_scan(ksm_thread_pages_to_scan);
                mutex_unlock(&ksm_thread_mutex);
 
-               try_to_freeze();
-
                if (ksmd_should_run()) {
                        sleep_ms = READ_ONCE(ksm_thread_sleep_millisecs);
-                       wait_event_interruptible_timeout(ksm_iter_wait,
+                       wait_event_freezable_timeout(ksm_iter_wait,
                                sleep_ms != READ_ONCE(ksm_thread_sleep_millisecs),
                                msecs_to_jiffies(sleep_ms));
                } else {