public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Con Kolivas <kernel@kolivas.org>
To: Andrew Morton <akpm@osdl.org>
Cc: linux-kernel@vger.kernel.org, ck@vds.kolivas.org
Subject: Re: [PATCH] mm - implement swap prefetching
Date: Wed, 12 Oct 2005 22:00:46 +1000	[thread overview]
Message-ID: <200510122200.47074.kernel@kolivas.org> (raw)
In-Reply-To: <20051011223419.4250ecf6.akpm@osdl.org>

On Wed, 12 Oct 2005 15:34, Andrew Morton wrote:
> Con Kolivas <kernel@kolivas.org> wrote:
> > +		/* Select the zone with the most free ram */
> > +		if (free > most_free) {
> > +			most_free = free;

> Why use the "zone with most free pages"?  Generally it would be better to
> use up ZONE_HIGHMEM first: ZONE_NORMAL is valuable.

Ok. Sounds fair.

> > +	/* We shouldn't prefetch when we are doing writeback */
> > +	if (ps.nr_writeback)
> > +		goto out;
>
> Yeah, this really needs to become per-disk-queue-aware.

I looked but it started looking like I was going to over-engineer.

> > +	/* Delay prefetching if we have significant amounts of dirty data */
> > +	pending_writes = ps.nr_dirty + ps.nr_unstable;
> > +	if (pending_writes > SWAP_CLUSTER_MAX)
> > +		goto out;
>
> Surely this is too aggressive.  There are almost always a few tens of dirty
> pages floating about, especially when atime updates are enabled.  I'd
> suggest that you stick a printk in here - I expect you'll find that this
> test triggers a lot - too much.

Actually I was quite aware of how frequently this hits. What I found in 
practice was that the amount of dirty ram was an extraordinarily good marker 
of whether the system was globally idle / low stressed or not. It did not 
seem to stop prefetching from occurring in the real world on the machines I 
tried it on.

> > +	if (unlikely(!read_trylock(&swapper_space.tree_lock)))
> > +		goto out;
> > +	limit += total_swapcache_pages;
> > +	read_unlock(&swapper_space.tree_lock);
>
> I'd just not bother with the locking at all here.

Ok.

> > +	daemonize("kprefetchd");
>
> kthread(), please.

Check.

> > +	init_timer(&prefetch_timer);
> > +	prefetch_timer.data = 0;
> > +	prefetch_timer.function = prefetch_wakeup;
> > +
> > +	kernel_thread(kprefetchd, NULL, CLONE_KERNEL);
> > +
> > +	return 0;
> > +}
>
> Might be able to use a boring old wake_up_process() here rather than a
> waitqueue.
>
> Is the timer actually needed?  Could just do schedule_timeout() in
> kprefetchd()?

I guess. The timer just made it easy to start and stop it completely before I 
turned prefetch into a daemon and it kinda stayed that way. It's not run that 
frequently and only does miniscule things in that context; is it of a 
significant advantage?

Thanks very much!

Cheers,
Con

  reply	other threads:[~2005-10-12 12:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-10-10 14:23 [PATCH] mm - implement swap prefetching Con Kolivas
2005-10-10 14:35 ` Jesper Juhl
2005-10-10 14:39   ` Con Kolivas
2005-10-11  6:48 ` Con Kolivas
2005-10-12  5:34   ` Andrew Morton
2005-10-12 12:00     ` Con Kolivas [this message]
2005-10-15  8:10     ` Con Kolivas

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=200510122200.47074.kernel@kolivas.org \
    --to=kernel@kolivas.org \
    --cc=akpm@osdl.org \
    --cc=ck@vds.kolivas.org \
    --cc=linux-kernel@vger.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