LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Fengguang Wu <wfg@mail.ustc.edu.cn>
To: Andrew Morton <akpm@osdl.org>
Cc: Martin Peschke <mp3@de.ibm.com>, linux-kernel@vger.kernel.org
Subject: [PATCH 2/8] readahead: state based method routines: explicitly embed class_new/class_old inside flags
Date: Sat, 27 Jan 2007 16:02:21 +0800	[thread overview]
Message-ID: <369886263.27547@ustc.edu.cn> (raw)
Message-ID: <20070127082529.253596257@mail.ustc.edu.cn> (raw)
In-Reply-To: <20070127080219.161473179@mail.ustc.edu.cn>

[-- Attachment #1: readahead-state-based-method-routines-explicitly-embed-class_new-class_old-inside-flags.patch --]
[-- Type: text/plain, Size: 2155 bytes --]

The new/old ra class were implicitly stored in low bits of file_ra_state.flags.
Now make the data structure obvious, and remove the coding tricks.

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

--- linux-2.6.20-rc4-mm1.orig/include/linux/fs.h
+++ linux-2.6.20-rc4-mm1/include/linux/fs.h
@@ -738,7 +738,14 @@ 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 */
+	union {
+		unsigned long	flags;	/* RA_FLAG_xxx | class_old | class_new */
+		struct {
+			u8	class_new;
+			u8	class_old;
+		};
+	};
+
 	unsigned long prev_page;	/* Cache last read() position */
 	unsigned long ra_pages;		/* Maximum readahead window */
 };
--- linux-2.6.20-rc4-mm1.orig/mm/readahead.c
+++ linux-2.6.20-rc4-mm1/mm/readahead.c
@@ -48,8 +48,6 @@ int readahead_hit_rate = 1;
 /*
  * 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,
@@ -795,12 +793,12 @@ out:
 
 static enum ra_class ra_class_new(struct file_ra_state *ra)
 {
-	return ra->flags & RA_CLASS_MASK;
+	return ra->class_new;
 }
 
 static inline enum ra_class ra_class_old(struct file_ra_state *ra)
 {
-	return (ra->flags >> RA_CLASS_SHIFT) & RA_CLASS_MASK;
+	return ra->class_old;
 }
 
 static unsigned long ra_readahead_size(struct file_ra_state *ra)
@@ -832,16 +830,8 @@ static int ra_has_index(struct file_ra_s
  */
 static void ra_set_class(struct file_ra_state *ra, enum ra_class ra_class)
 {
-	unsigned long flags_mask;
-	unsigned long flags;
-	unsigned long old_ra_class;
-
-	flags_mask = ~(RA_CLASS_MASK | (RA_CLASS_MASK << RA_CLASS_SHIFT));
-	flags = ra->flags & flags_mask;
-
-	old_ra_class = ra_class_new(ra) << RA_CLASS_SHIFT;
-
-	ra->flags = flags | old_ra_class | ra_class;
+	ra->class_old = ra->class_new;
+	ra->class_new = ra_class;
 }
 
 /*

--

      parent reply	other threads:[~2007-01-27  8:24 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <369886263.20106@ustc.edu.cn>
2007-01-27  8:02 ` [PATCH 0/8] readahead updates Fengguang Wu
     [not found]   ` <369886263.49250@ustc.edu.cn>
2007-01-27  8:02     ` [PATCH 1/8] readahead: min/max sizes: increase VM_MIN_READAHEAD to 32KB Fengguang Wu
     [not found]   ` <369886263.27547@ustc.edu.cn>
2007-01-27  8:02     ` [PATCH 2/8] readahead: state based method routines: explicitly embed class_new/class_old inside flags Fengguang Wu
     [not found]   ` <369886263.59195@ustc.edu.cn>
2007-01-27  8:02     ` [PATCH 3/8] readahead: state based method: prevent tiny size Fengguang Wu
     [not found]   ` <369886263.12429@ustc.edu.cn>
2007-01-27  8:02     ` [PATCH 4/8] readahead: state based method: move readahead_ratio out of compute_thrashing_threshold() Fengguang Wu
     [not found]   ` <369886264.20106@ustc.edu.cn>
2007-01-27  8:02     ` [PATCH 5/8] readahead: initial method: user recommended size: rename to read_ahead_initial_kb Fengguang Wu
     [not found]   ` <369886264.06097@ustc.edu.cn>
2007-01-27  8:02     ` [PATCH 6/8] readahead: thrashing recovery method fix Fengguang Wu
     [not found]   ` <369886264.76457@ustc.edu.cn>
2007-01-27  8:02     ` [PATCH 7/8] readahead: call scheme: fix thrashed unaligned read Fengguang Wu
     [not found]   ` <369886264.38864@ustc.edu.cn>
2007-01-27  8:02     ` [PATCH 8/8] readahead: laptop mode fix Fengguang Wu
2007-01-31 13:37   ` [PATCH 0/8] readahead updates martin
     [not found] <7HR6P-3Wm-3@gated-at.bofh.it>
     [not found] ` <7HR6S-3Wm-13@gated-at.bofh.it>
2007-01-27 12:01   ` [PATCH 2/8] readahead: state based method routines: explicitly embed class_new/class_old inside flags Bodo Eggert
2007-01-28 19:11     ` Randy Dunlap

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=369886263.27547@ustc.edu.cn \
    --to=wfg@mail.ustc.edu.cn \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mp3@de.ibm.com \
    --subject='Re: [PATCH 2/8] readahead: state based method routines: explicitly embed class_new/class_old inside flags' \
    /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

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).