linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Hao <haokexin@gmail.com>
To: David Hildenbrand <david@redhat.com>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>,
	linux-mm@kvack.org, Andrea Arcangeli <aarcange@redhat.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Pavel Machek <pavel@ucw.cz>
Subject: Re: [PATCH] mm: ksm: Remove unnecessary try_to_freeze()
Date: Wed, 13 Dec 2023 19:35:28 +0800	[thread overview]
Message-ID: <ZXmXAFi7zIIfquAo@pek-khao-d3> (raw)
In-Reply-To: <92046e20-b05e-4710-93f5-4b64d41b86b6@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 1549 bytes --]

On Wed, Dec 13, 2023 at 12:28:21PM +0100, David Hildenbrand wrote:
> On 13.12.23 12:17, Rafael J. Wysocki wrote:
> > On Wed, Dec 13, 2023 at 10:09 AM Kevin Hao <haokexin@gmail.com> 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.
> > 
> > The changelog doesn't match the patch IMV.
> > 
> 
> Staring at the code, I think it makes sense once one spots the existing
> "wait_event_freezable()" on the else path.

Yes. The change from wait_event_interruptible_timeout() to
wait_event_freezable_timeout() led to some confusion. In the else path, there
is indeed a wait_event_freezable(). The complete code is as follows:

static int ksm_scan_thread(void *nothing)
{
	unsigned int sleep_ms;

	set_freezable();
	set_user_nice(current, 5);

	while (!kthread_should_stop()) {
		mutex_lock(&ksm_thread_mutex);
		wait_while_offlining();
		if (ksmd_should_run())
			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,
				sleep_ms != READ_ONCE(ksm_thread_sleep_millisecs),
				msecs_to_jiffies(sleep_ms));
		} else {
			wait_event_freezable(ksm_thread_wait,
				ksmd_should_run() || kthread_should_stop());
		}
	}
	return 0;
}

Thanks,
Kevin

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply	other threads:[~2023-12-13 11:35 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 [this message]
2023-12-13 11:37 ` David Hildenbrand

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=ZXmXAFi7zIIfquAo@pek-khao-d3 \
    --to=haokexin@gmail.com \
    --cc=aarcange@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=david@redhat.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