mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Fengguang Wu <wfg@mail.ustc.edu.cn>
To: Rusty Russell <rusty@rustcorp.com.au>
Cc: Andrew Morton <akpm@osdl.org>,
	linux-kernel@vger.kernel.org, Andi Kleen <andi@firstfloor.org>,
	Jens Axboe <jens.axboe@oracle.com>,
	Oleg Nesterov <oleg@tv-sign.ru>,
	Steven Pratt <slpratt@austin.ibm.com>,
	Ram Pai <linuxram@us.ibm.com>
Subject: Re: [PATCH 4/9] readahead: data structure and routines
Date: Tue, 12 Jun 2007 20:07:06 +0800	[thread overview]
Message-ID: <381650021.10920@ustc.edu.cn> (raw)
Message-ID: <20070612120706.GB9624@mail.ustc.edu.cn> (raw)
In-Reply-To: <1181619050.6237.23.camel@localhost.localdomain>

Hi Rusty,

On Tue, Jun 12, 2007 at 01:30:50PM +1000, Rusty Russell wrote:
> On Thu, 2007-05-17 at 06:47 +0800, Fengguang Wu wrote: 
> > /*
> >   * Track a single file's readahead state
> > + *
> > + *  ================#============|==================#==================|
> > + *                  ^            ^                  ^                  ^
> > + *  file_ra_state.la_index    .ra_index   .lookahead_index   .readahead_index
> >   */
> >  struct file_ra_state {
> >  	unsigned long start;		/* Current window */
> > @@ -711,6 +715,12 @@ struct file_ra_state {
> >  	unsigned long prev_index;	/* Cache last read() position */
> >  	unsigned long ahead_start;	/* Ahead window */
> >  	unsigned long ahead_size;
> > +
> > +	pgoff_t la_index;               /* enqueue time */
> > +	pgoff_t ra_index;               /* begin offset */
> > +	pgoff_t lookahead_index;        /* time to do next readahead */
> > +	pgoff_t readahead_index;        /* end offset */
> > +
> 
> I found these variables a little confusing.  la_index is the last offset
> passed to ondemand_readahead, so perhaps "last_request_start" is a
> better name?  The comment "enqueue time" seems strange, too.

Yes, they are a bit confusing. Sorry for the bad naming and comments!

The precise meanings can be:
la_index - the time (where we are reading) when the readahead window is established
ra_index - where the readahead window starts
lookahead_index - the time (on reading of which) to push forward the readahead window
readahead_index - where the readahead window ends, or
                  where the next readahead should start with

In normal case, when the readahead window is pushed forward, the
following holds:
                la_index = lookahead_index; lookahead_index = new-value;
                ra_index = readahead_index; readahead_index = new-value;

> ra_index seems ok, although "readahead_start" might be better.  Perhaps
> readahead_index should be expressed as readahead_size, which is how it
> seems to be used.  Perhaps "lookahead_index" is best expressed as a
> buffer at the end of the readahead zone (readahead_min?).
> 
> ie:
> 	pgoff_t last_request_start;     /* start of req which triggered readahead */
> 	pgoff_t readahead_start;        /* Where readahead started */
> 	pgoff_t readahead_size;         /* PAGE_CACHE_SIZE units of readahead */
> 	pgoff_t readahead_min;          /* readahead_size left before we recalc */
> 
> This gets rid of many of the accessors, I think, and avoids introducing
> a new term to understand (lookahead).

Both indexes and sizes will be used in the code. So calculates may
always be necessary somewhere. If there's a good naming scheme, either
form(index/size based) is OK to me :)

In fact, there are two kind of windows and one buffer:

                    |---------- readahead window ----------->|                                                          
    ===#============|==================#=====================|                                                          
       |--- reader walking window ---->|--- async buffer --->|        

'lookahead' is not a standard term, while 'readahead_min' may be
confusing for some people?  Anyway, I'd like to propose two more
possible schemes:

	pgoff_t ahead_start;     /* readahead window */
        pgoff_t ahead_end;
	pgoff_t reader_start;    /* on read of which the ahead window was established */
	pgoff_t reader_end;      /* on read of which the ahead window will be pushed forward */

or preferably:

	pgoff_t start;                 /* where readahead started */
        unsigned long size;            /* # of readahead pages */
	unsigned long async_size;      /* do asynchronous readahead when there are only # of pages ahead */

	unsigned long async_size_old;  /* TODO: this one is not needed for now */

Any opinions? Thanks.

> > +/*
> > + * Where is the old read-ahead and look-ahead?
> > + */
> > +static inline void ra_set_index(struct file_ra_state *ra,
> > +				pgoff_t la_index, pgoff_t ra_index)
> > +{
> > +	ra->la_index = la_index;
> > +	ra->ra_index = ra_index;
> > +}
> > +
> > +/*
> > + * Where is the new read-ahead and look-ahead?
> > + */
> > +static inline void ra_set_size(struct file_ra_state *ra,
> > +				unsigned long ra_size, unsigned long la_size)
> > +{
> > +	ra->readahead_index = ra->ra_index + ra_size;
> > +	ra->lookahead_index = ra->ra_index + ra_size - la_size;
> > +}
> 
> These are only called in one place, so I think it's clearer to do this
> there directly.  But I see you exported ra_submit, too, even though it's
> only used in the same file.  Are there plans for other users?

Yes, if we are to re-introduce the adaptive readahead, the functions
will be reused.

Thank you,
Fengguang


  reply	other threads:[~2007-06-12 12:07 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20070516224752.500812933@mail.ustc.edu.cn>
2007-05-16 22:47 ` [PATCH 0/9] on-demand readahead Fengguang Wu
     [not found] ` <20070516224818.246719596@mail.ustc.edu.cn>
2007-05-16 22:47   ` [PATCH 1/9] readahead: introduce PG_readahead Fengguang Wu
2007-05-19  6:28     ` Andrew Morton
2007-05-19 11:35       ` Andi Kleen
2007-05-19 15:19         ` Andrew Morton
     [not found]       ` <20070519123031.GA6095@mail.ustc.edu.cn>
2007-05-19 12:30         ` Fengguang Wu
2007-05-19 15:25           ` Andrew Morton
     [not found]             ` <20070520030904.GA9176@mail.ustc.edu.cn>
2007-05-20  3:09               ` Fengguang Wu
2007-05-20  7:10                 ` Christoph Lameter
2007-06-12  1:04   ` Rusty Russell
     [not found]     ` <20070612025201.GA6447@mail.ustc.edu.cn>
2007-06-12  2:52       ` Fengguang Wu
     [not found] ` <20070516224818.384876951@mail.ustc.edu.cn>
2007-05-16 22:47   ` [PATCH 2/9] readahead: add look-ahead support to __do_page_cache_readahead() Fengguang Wu
     [not found] ` <20070516224818.544351896@mail.ustc.edu.cn>
2007-05-16 22:47   ` [PATCH 3/9] readahead: MIN_RA_PAGES/MAX_RA_PAGES macros Fengguang Wu
     [not found] ` <20070516224818.683288460@mail.ustc.edu.cn>
2007-05-16 22:47   ` [PATCH 4/9] readahead: data structure and routines Fengguang Wu
2007-06-12  3:30   ` Rusty Russell
     [not found]     ` <20070612120706.GB9624@mail.ustc.edu.cn>
2007-06-12 12:07       ` Fengguang Wu [this message]
2007-06-13  0:27       ` Rusty Russell
     [not found]         ` <20070613030701.GA6494@mail.ustc.edu.cn>
2007-06-13  3:07           ` Fengguang Wu
     [not found] ` <20070516224818.963553696@mail.ustc.edu.cn>
2007-05-16 22:47   ` [PATCH 6/9] readahead: convert filemap invocations Fengguang Wu
     [not found] ` <20070516224819.131727893@mail.ustc.edu.cn>
2007-05-16 22:47   ` [PATCH 7/9] readahead: convert splice invocations Fengguang Wu
     [not found] ` <20070516224819.420933490@mail.ustc.edu.cn>
2007-05-16 22:48   ` [PATCH 9/9] readahead: remove the old algorithm Fengguang Wu
2007-05-19 12:18   ` Andi Kleen
     [not found]     ` <20070519131713.GA6510@mail.ustc.edu.cn>
2007-05-19 13:17       ` Fengguang Wu
     [not found] ` <20070516224819.281192313@mail.ustc.edu.cn>
2007-05-16 22:48   ` [PATCH 8/9] readahead: convert ext3/ext4 invocations Fengguang Wu
2007-05-19 12:19   ` Andi Kleen
     [not found] ` <20070516224818.841068730@mail.ustc.edu.cn>
2007-05-16 22:47   ` [PATCH 5/9] readahead: on-demand readahead logic Fengguang Wu
2007-05-19  6:23     ` Andrew Morton
     [not found]       ` <20070519130202.GB6095@mail.ustc.edu.cn>
2007-05-19 13:02         ` Fengguang Wu
2007-06-12  4:36   ` Rusty Russell
     [not found]     ` <20070612103518.GA9624@mail.ustc.edu.cn>
2007-06-12 10:35       ` Fengguang Wu
2007-06-13  1:40       ` Rusty Russell
     [not found]         ` <20070613040044.GB6494@mail.ustc.edu.cn>
2007-06-13  4:00           ` Fengguang Wu
2007-06-13  5:51           ` Rusty Russell
     [not found]             ` <20070613070724.GA6146@mail.ustc.edu.cn>
2007-06-13  7:07               ` 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=381650021.10920@ustc.edu.cn \
    --to=wfg@mail.ustc.edu.cn \
    --cc=akpm@osdl.org \
    --cc=andi@firstfloor.org \
    --cc=jens.axboe@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxram@us.ibm.com \
    --cc=oleg@tv-sign.ru \
    --cc=rusty@rustcorp.com.au \
    --cc=slpratt@austin.ibm.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

Powered by JetHome