public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Fengguang Wu <wfg@mail.ustc.edu.cn>
To: Andrew Morton <akpm@osdl.org>
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH 01/14] readahead: state based method: check node id
Date: Fri, 16 Mar 2007 16:48:57 +0800	[thread overview]
Message-ID: <374035058.94331@ustc.edu.cn> (raw)
Message-ID: <20070316085051.601015000@mail.ustc.edu.cn> (raw)
In-Reply-To: 20070316084856.687942000@mail.ustc.edu.cn

[-- Attachment #1: readahead-state-based-method-check-node-id.patch --]
[-- Type: text/plain, Size: 3060 bytes --]

The file_ra_state.age is node specific,
comparing ages between two nodes is a bug.

So add code to
- take down the node id in file_ra_state.flags;
- ensure that we are comparing the ages from the same node.

Signed-off-by: Fengguang Wu <wfg@mail.ustc.edu.cn>
---
 include/linux/fs.h |    2 +-
 mm/readahead.c     |   30 +++++++++++++++++++++++++-----
 2 files changed, 26 insertions(+), 6 deletions(-)

--- linux-2.6.21-rc3-mm2.orig/include/linux/fs.h
+++ linux-2.6.21-rc3-mm2/include/linux/fs.h
@@ -738,7 +738,7 @@ struct file_ra_state {
 	unsigned long mmap_hit;		/* Cache hit stat for mmap accesses */
 	unsigned long mmap_miss;	/* Cache miss stat for mmap accesses */
 
-	unsigned long flags;	/* RA_FLAG_xxx | ra_class_old | ra_class_new */
+	unsigned long flags;	/* RA_FLAG_xxx | node_id | class_old | class_new */
 	unsigned long prev_page;	/* Cache last read() position */
 	unsigned long ra_pages;		/* Maximum readahead window */
 };
--- linux-2.6.21-rc3-mm2.orig/mm/readahead.c
+++ linux-2.6.21-rc3-mm2/mm/readahead.c
@@ -52,11 +52,13 @@ EXPORT_SYMBOL_GPL(readahead_ratio);
 int readahead_hit_rate = 1;
 #endif /* CONFIG_ADAPTIVE_READAHEAD */
 
+#define RA_CLASS_SHIFT 4
+#define RA_CLASS_MASK  ((1 << RA_CLASS_SHIFT) - 1)
+#define RA_NODE_SHIFT  (2 * RA_CLASS_SHIFT)
+#define RA_NODE_MASK   ((MAX_NUMNODES-1) << RA_NODE_SHIFT)
 /*
  * Detailed classification of read-ahead behaviors.
  */
-#define RA_CLASS_SHIFT 4
-#define RA_CLASS_MASK  ((1 << RA_CLASS_SHIFT) - 1)
 enum ra_class {
 	RA_CLASS_ALL,
 	RA_CLASS_INITIAL,
@@ -802,6 +804,11 @@ static inline enum ra_class ra_class_old
 	return (ra->flags >> RA_CLASS_SHIFT) & RA_CLASS_MASK;
 }
 
+static inline int ra_node_id(struct file_ra_state *ra)
+{
+	return (ra->flags >> RA_NODE_SHIFT) & RA_NODE_MASK;
+}
+
 static unsigned long ra_readahead_size(struct file_ra_state *ra)
 {
 	return ra->readahead_index - ra->ra_index;
@@ -864,6 +871,18 @@ static void ra_set_size(struct file_ra_s
 }
 
 /*
+ * Save the current node id and age.
+ */
+static void ra_save_node_age(struct file_ra_state *ra)
+{
+	int nid = numa_node_id();
+
+	ra->flags &= ~RA_NODE_MASK;
+	ra->flags |= nid << RA_NODE_SHIFT;
+	ra->age = nr_scanned_pages_node(nid);
+}
+
+/*
  * Submit IO for the read-ahead request in file_ra_state.
  */
 static unsigned long ra_submit(struct file_ra_state *ra,
@@ -901,7 +920,7 @@ static unsigned long ra_submit(struct fi
 	}
 
 	/* Take down the current read-ahead aging value. */
-	ra->age = nr_scanned_pages_node(numa_node_id());
+	ra_save_node_age(ra);
 
 	ra_size = ra_readahead_size(ra);
 	la_size = ra_lookahead_size(ra);
@@ -1025,9 +1044,10 @@ static unsigned long compute_thrashing_t
 	unsigned long stream_shift;
 	unsigned long ra_size;
 	uint64_t ll;
+	int nid = ra_node_id(ra);
 
-	global_size = nr_free_inactive_pages_node(numa_node_id());
-	global_shift = nr_scanned_pages_node(numa_node_id()) - ra->age;
+	global_size = nr_free_inactive_pages_node(nid);
+	global_shift = nr_scanned_pages_node(nid) - ra->age;
 	global_shift |= 1UL;
 	stream_shift = ra_invoke_interval(ra);
 

--

  parent reply	other threads:[~2007-03-16  8:52 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20070316084856.687942000@mail.ustc.edu.cn>
2007-03-16  8:48 ` [PATCH 00/14] Adaptive readahead update Fengguang Wu
     [not found] ` <20070316085051.601015000@mail.ustc.edu.cn>
2007-03-16  8:48   ` Fengguang Wu [this message]
     [not found] ` <20070316085051.787637000@mail.ustc.edu.cn>
2007-03-16  8:48   ` [PATCH 02/14] readahead: state based method: decouple readahead_ratio from growth_limit Fengguang Wu
     [not found] ` <20070316085051.939153000@mail.ustc.edu.cn>
2007-03-16  8:48   ` [PATCH 03/14] readahead: state based method: cancel lookahead gracefully Fengguang Wu
     [not found] ` <20070316085052.111038000@mail.ustc.edu.cn>
2007-03-16  8:49   ` [PATCH 04/14] readahead: thrashing recovery method: check unbalanced aging Fengguang Wu
     [not found] ` <20070316085052.284256000@mail.ustc.edu.cn>
2007-03-16  8:49   ` [PATCH 05/14] readahead: thrashing recovery method: refill holes Fengguang Wu
     [not found] ` <20070316085052.388486000@mail.ustc.edu.cn>
2007-03-16  8:49   ` [PATCH 06/14] readahead: call scheme: cleanup Fengguang Wu
     [not found] ` <20070316085052.550263000@mail.ustc.edu.cn>
2007-03-16  8:49   ` [PATCH 07/14] readahead: call scheme: catch thrashing on lookahead time Fengguang Wu
     [not found] ` <20070316085052.688674000@mail.ustc.edu.cn>
2007-03-16  8:49   ` [PATCH 08/14] readahead: remove parameter ra_max from thrashing_recovery_readahead() Fengguang Wu
     [not found] ` <20070316085052.868849000@mail.ustc.edu.cn>
2007-03-16  8:49   ` [PATCH 09/14] readahead: remove parameter ra_max from adjust_rala*() Fengguang Wu
     [not found] ` <20070316085053.030235000@mail.ustc.edu.cn>
2007-03-16  8:49   ` [PATCH 10/14] readahead: state based method: protect against tiny size Fengguang Wu
     [not found] ` <20070316085053.155226000@mail.ustc.edu.cn>
2007-03-16  8:49   ` [PATCH 11/14] readahead: rename state_based_readahead() to clock_based_readahead() Fengguang Wu
     [not found] ` <20070316085053.339604000@mail.ustc.edu.cn>
2007-03-16  8:49   ` [PATCH 12/14] readahead: account I/O block times for stock readahead Fengguang Wu
     [not found] ` <20070316085053.463858000@mail.ustc.edu.cn>
2007-03-16  8:49   ` [PATCH 13/14] readahead: rescue_pages() updates Fengguang Wu
     [not found] ` <20070316085053.642868000@mail.ustc.edu.cn>
2007-03-16  8:49   ` [PATCH 14/14] readahead: remove noaction/shrink events Fengguang Wu

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=374035058.94331@ustc.edu.cn \
    --to=wfg@mail.ustc.edu.cn \
    --cc=akpm@osdl.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