linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: Kevin Hao <haokexin@gmail.com>, linux-mm@kvack.org
Cc: Andrea Arcangeli <aarcange@redhat.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	Pavel Machek <pavel@ucw.cz>
Subject: Re: [PATCH] mm: ksm: Remove unnecessary try_to_freeze()
Date: Wed, 13 Dec 2023 12:37:46 +0100	[thread overview]
Message-ID: <0a573adb-b0d3-4108-ba17-6498bb3ee274@redhat.com> (raw)
In-Reply-To: <20231213090906.1070985-1-haokexin@gmail.com>

On 13.12.23 10:09, Kevin Hao wrote:
> 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.
> 
> Signed-off-by: Kevin Hao <haokexin@gmail.com>
> Cc: Andrea Arcangeli <aarcange@redhat.com>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: "Rafael J. Wysocki" <rafael@kernel.org>
> Cc: Pavel Machek <pavel@ucw.cz>
> ---
>   mm/ksm.c | 4 +---
>   1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/mm/ksm.c b/mm/ksm.c
> index 16532fa85a46..e2ce850c2739 100644
> --- 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 {

I'm not an expert on task freezing, but staring at 
Documentation/power/freezing-of-tasks.txt

"freezable kernel threads need to call it
explicitly in suitable places or use the wait_event_freezable() or
wait_event_freezable_timeout() macros (defined in 
include/linux/freezer.h) that combine interruptible sleep with checking 
if the task is to be frozen and calling try_to_freeze()."

So this cleanup makes sense to me.

Acked-by: David Hildenbrand <david@redhat.com>

-- 
Cheers,

David / dhildenb



      parent reply	other threads:[~2023-12-13 11:37 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-13  9:09 Kevin Hao
2023-12-13 11:17 ` Rafael J. Wysocki
2023-12-13 11:28   ` David Hildenbrand
2023-12-13 11:35     ` Kevin Hao
2023-12-13 11:37 ` David Hildenbrand [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0a573adb-b0d3-4108-ba17-6498bb3ee274@redhat.com \
    --to=david@redhat.com \
    --cc=aarcange@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=haokexin@gmail.com \
    --cc=linux-mm@kvack.org \
    --cc=pavel@ucw.cz \
    --cc=rafael@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox