[PATCH v3] factor out kswapd sleeping logic from kswapd()

From: KOSAKI Motohiro
Date: Tue Nov 16 2010 - 01:07:30 EST


> > +void kswapd_try_to_sleep(pg_data_t *pgdat, int order)
> > +{
>
> As pointed out elsewhere, this should be static.

Fixed.


> > + long remaining = 0;
> > + DEFINE_WAIT(wait);
> > +
> > + if (freezing(current) || kthread_should_stop())
> > + return;
> > +
> > + prepare_to_wait(&pgdat->kswapd_wait, &wait, TASK_INTERRUPTIBLE);
> > +
> > + /* Try to sleep for a short interval */
> > + if (!sleeping_prematurely(pgdat, order, remaining)) {
> > + remaining = schedule_timeout(HZ/10);
> > + finish_wait(&pgdat->kswapd_wait, &wait);
> > + prepare_to_wait(&pgdat->kswapd_wait, &wait, TASK_INTERRUPTIBLE);
> > + }
> > +
> > + /*
> > + * After a short sleep, check if it was a
> > + * premature sleep. If not, then go fully
> > + * to sleep until explicitly woken up
> > + */
>
> Very minor but that comment should now fit on fewer lines.

Thanks, fixed.


> > + if (!sleeping_prematurely(pgdat, order, remaining)) {
> > + trace_mm_vmscan_kswapd_sleep(pgdat->node_id);
> > + set_pgdat_percpu_threshold(pgdat, calculate_normal_threshold);
> > + schedule();
> > + set_pgdat_percpu_threshold(pgdat, calculate_pressure_threshold);
>
> I posted a patch adding a comment on why set_pgdat_percpu_threshold() is
> called. I do not believe it has been picked up by Andrew but it if is,
> the patches will conflict. The resolution will be obvious but you may
> need to respin this patch if the comment patch gets picked up in mmotm.
>
> Otherwise, I see no problems.

OK, I've rebased the patch on top your comment patch.