linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Chen Yucong <slaoub@gmail.com>
To: akpm@linux-foundation.org
Cc: ddstreet@ieee.org, mgorman@suse.de, hughd@google.com,
	shli@kernel.org, k.kozlowski@samsung.com, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org, Chen Yucong <slaoub@gmail.com>
Subject: [PATCH] swap: Avoid scanning invalidated region for cheap seek
Date: Mon, 26 May 2014 10:00:59 +0800	[thread overview]
Message-ID: <1401069659-29589-1-git-send-email-slaoub@gmail.com> (raw)

For cheap seek, when we scan the region between si->lowset_bit
and scan_base, if san_base is greater than si->highest_bit, the
scan operation between si->highest_bit and scan_base is not
unnecessary.

This patch can be used to avoid scanning invalidated region for
cheap seek.

Signed-off-by: Chen Yucong <slaoub@gmail.com>
---
 mm/swapfile.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/mm/swapfile.c b/mm/swapfile.c
index beeeef8..7f0f27e 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -489,6 +489,7 @@ static unsigned long scan_swap_map(struct swap_info_struct *si,
 {
 	unsigned long offset;
 	unsigned long scan_base;
+	unsigned long upper_bound;
 	unsigned long last_in_cluster = 0;
 	int latency_ration = LATENCY_LIMIT;
 
@@ -551,9 +552,11 @@ static unsigned long scan_swap_map(struct swap_info_struct *si,
 
 		offset = si->lowest_bit;
 		last_in_cluster = offset + SWAPFILE_CLUSTER - 1;
+		upper_bound = (scan_base <= si->highest_bit) ?
+				scan_base : (si->highest_bit + 1);
 
 		/* Locate the first empty (unaligned) cluster */
-		for (; last_in_cluster < scan_base; offset++) {
+		for (; last_in_cluster < upper_bound; offset++) {
 			if (si->swap_map[offset])
 				last_in_cluster = offset + SWAPFILE_CLUSTER;
 			else if (offset == last_in_cluster) {
-- 
1.7.10.4

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

             reply	other threads:[~2014-05-26  2:02 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-26  2:00 Chen Yucong [this message]
2014-05-28  3:53 ` [PATCH] swap: Avoid scanning invalidated region for cheap seek Hugh Dickins
2014-05-30  7:41   ` Shaohua Li

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=1401069659-29589-1-git-send-email-slaoub@gmail.com \
    --to=slaoub@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=ddstreet@ieee.org \
    --cc=hughd@google.com \
    --cc=k.kozlowski@samsung.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mgorman@suse.de \
    --cc=shli@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;
as well as URLs for NNTP newsgroup(s).