Re: [PATCH] mm: ksm: Remove unnecessary try_to_freeze()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx> 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: signature.asc
Description: PGP signature


[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux