linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Zlatko Calusic <Zlatko.Calusic@CARNet.hr>
To: Rik van Riel <H.H.vanRiel@phys.uu.nl>
Cc: "Stephen C. Tweedie" <sct@redhat.com>, Linux MM <linux-mm@kvack.org>
Subject: Re: [PATCH] swapin readahead
Date: 01 Dec 1998 18:20:49 +0100	[thread overview]
Message-ID: <87vhjvkccu.fsf@atlas.CARNet.hr> (raw)
In-Reply-To: Rik van Riel's message of "Tue, 1 Dec 1998 17:42:08 +0100 (CET)"

Rik van Riel <H.H.vanRiel@phys.uu.nl> writes:

> In my experience allocations aren't the big problem but
> deallocations. I guess we lose some memory there :(

Yes. something like that. Since nobody asked pages to swap in (we
decided to swap them in) it looks like nobody frees them. :)
So we should free them somewhere, probably.

> > Also, looking at the patch source, it looks like the comment there is
> > completely misleading, as the for() loop is not doing anything, at
> > all. The patch can be shortened to do offset++, if() and only ONE
> > read_swap_cache_async, if I'm understanding it correctly. Sorry, I'm
> > not including it here, have some other things to do fast.
> 
> You have to read each entry separately; you want all of
> them to have an entry in the swap cache...

+
+	/*
+	 * Primitive swap readahead code. We simply read the
+	 * next 16 entries in the swap area. The break below
+	 * is needed or else the request queue will explode :)
+	 */
+	for (i = 1; i++ < 16;) {
+		offset++;
+		if (!swapdev->swap_map[offset] || offset >= swapdev->max
+				|| atomic_read(&nr_async_pages) >
+				pager_daemon.swap_cluster / 2)
+			break;
+		read_swap_cache_async(SWP_ENTRY(SWP_TYPE(entry), offset),
+0);
+			break;
+	}               ^^^^^^

Last break in the for() loop, exits the loop after the very first
pass. Why don't you get get rid of the loop, then:

	offset++;
	if (swapdev->swap_map[offset] && offset < swapdev->max
			&& atomic_read(&nr_async_pages) <=
			pager_daemon.swap_cluster / 2)
		read_swap_cache_async(SWP_ENTRY(SWP_TYPE(entry), offset), 0);

Functionality is exactly the same, and code is much more readable.
Do you see my point now?

I wish you luck with the swapin readahed. I'm also very interested in
the impact it could made, since my tests revealed that swapping in
adjacent pages from swap is quite common operation, so in some
workloads it could be a big win (hogmem, for instance, would probably
be much faster :)).

Good luck!
-- 
Posted by Zlatko Calusic           E-mail: <Zlatko.Calusic@CARNet.hr>
---------------------------------------------------------------------
	      Black holes are where God divided by zero.
--
This is a majordomo managed list.  To unsubscribe, send a message with
the body 'unsubscribe linux-mm me@address' to: majordomo@kvack.org

  reply	other threads:[~1998-12-01 17:24 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-11-26 23:23 Rik van Riel
1998-12-01 15:13 ` Stephen C. Tweedie
1998-12-01 15:41   ` Rik van Riel
1998-12-01 15:51   ` Zlatko Calusic
1998-12-01 16:42     ` Rik van Riel
1998-12-01 17:20       ` Zlatko Calusic [this message]
1998-12-01 18:32         ` Rik van Riel
1998-12-02 17:35           ` Stephen C. Tweedie
1998-12-02 21:18             ` Zlatko Calusic
1998-12-03  5:25               ` Eric W. Biederman
1998-12-03  8:55                 ` Zlatko Calusic
1998-12-03 15:39                   ` Eric W. Biederman
1998-12-03 10:07                 ` Rik van Riel
1998-12-02 17:33         ` Stephen C. Tweedie
1998-12-03 14:44           ` Rik van Riel

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=87vhjvkccu.fsf@atlas.CARNet.hr \
    --to=zlatko.calusic@carnet.hr \
    --cc=H.H.vanRiel@phys.uu.nl \
    --cc=linux-mm@kvack.org \
    --cc=sct@redhat.com \
    /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