Re: [PATCH 5/12] ksm: keep quiet while list empty

From: Hugh Dickins
Date: Wed Aug 05 2009 - 07:55:14 EST


On Tue, 4 Aug 2009, Andrew Morton wrote:
> On Mon, 3 Aug 2009 13:14:03 +0100 (BST)
> Hugh Dickins <hugh.dickins@xxxxxxxxxxxxx> wrote:
>
> > + if (ksmd_should_run()) {
> > schedule_timeout_interruptible(
> > msecs_to_jiffies(ksm_thread_sleep_millisecs));
> > } else {
> > wait_event_interruptible(ksm_thread_wait,
> > - (ksm_run & KSM_RUN_MERGE) ||
> > - kthread_should_stop());
> > + ksmd_should_run() || kthread_should_stop());
> > }
>
> Yields

(Phew, for a moment I thought you were asking us to use yield() here.)

>
>
> if (ksmd_should_run()) {
> schedule_timeout_interruptible(
> msecs_to_jiffies(ksm_thread_sleep_millisecs));
> } else {
> wait_event_interruptible(ksm_thread_wait,
> ksmd_should_run() || kthread_should_stop());
> }
>
> can it be something like
>
> wait_event_interruptible_timeout(ksm_thread_wait,
> ksmd_should_run() || kthread_should_stop(),
> msecs_to_jiffies(ksm_thread_sleep_millisecs));
>
> ?

I'd be glad to simplify what we have there, but I think your proposal
ends up doing exactly what we're trying to avoid, doesn't it? Won't
it briefly wake up ksmd every ksm_thread_sleep_millisecs, even when
there's nothing for it to do?

>
> That would also reduce the latency in responding to kthread_should_stop().

That's not a high priority consideration. So far as I can tell, the only
use for that test is at startup, if the sysfs_create_group mysteriously
fails. It's mostly a leftover from when you could have CONFIG_KSM=m:

I did wonder whether to go back and add some SLAB_PANICs etc now,
but in the end I was either too lazy or too deferential to Izik's
fine error handling (you choose which to believe: both, actually).

Hugh
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/