Re: [PATCH 2/9] readahead: clean up and simplify the code forfilemap page fault readahead

From: Fengguang Wu
Date: Wed Dec 19 2007 - 01:55:35 EST


On Wed, Dec 19, 2007 at 12:54:23AM +0100, Nick Piggin wrote:
> On Tue, Dec 18, 2007 at 07:50:33PM +0800, Fengguang Wu wrote:
> > On Tue, Dec 18, 2007 at 09:19:07AM +0100, Nick Piggin wrote:
> > > On Sun, Dec 16, 2007 at 07:59:30PM +0800, Fengguang Wu wrote:
> >
> > > > + read_lock_irq(&mapping->tree_lock);
> > > > + page = radix_tree_lookup(&mapping->page_tree, offset);
> > > > + if (likely(page)) {
> > > > + int got_lock, uptodate;
> > > > + page_cache_get(page);
> > > > +
> > > > + got_lock = !TestSetPageLocked(page);
> > > > + uptodate = PageUptodate(page);
> > > > + read_unlock_irq(&mapping->tree_lock);
> > >
> > > If we could avoid open coding tree_lock here (and expanding its coverage
> > > to PageUptodate), that would be nice. I don't think it gains us too much.
> >
> > To use find_get_page()? That would be nice to me, too.
>
> Exactly.

Done. Also I think it's better not to split the `found' case into
the two cases of 'found & lock-ok' and 'found & wait-lock' for now.
That would reduce some more code:

-/*
- * A successful mmap hit is when we didn't need any IO at all,
- * and got an immediate lock on an up-to-date page. There's not
- * much to do, except decide on whether we want to trigger read-
- * ahead.
- *
- * We currently do the same thing as we did for a locked page
- * that we're waiting for.
- */
-static void do_mmap_hit(struct vm_area_struct *vma,
- struct file_ra_state *ra,
- struct file *file,
- struct page *page,
- pgoff_t offset)
-{
- do_async_mmap_readahead(vma, ra, file, page, offset);
-}
-
/**
* filemap_fault - read in file data for page fault handling
* @vma: vma in which the fault was taken
@@ -1411,28 +1396,13 @@
return VM_FAULT_SIGBUS;

/*
- * Do we have something in the page cache already that
- * is unlocked and already up-to-date?
+ * Do we have something in the page cache already?
*/
page = find_get_page(mapping, offset);
if (likely(page)) {
- if (likely(!TestSetPageLocked(page))) {
- /*
- * Previous IO error? No read-ahead, but try to
- * re-do a single read.
- */
- if (unlikely(!PageUptodate(page)))
- goto page_not_uptodate;
-
- do_mmap_hit(vma, ra, file, page, offset);
- goto found_it;
- }
-
/*
- * We found the page, but it was locked..
- *
- * So do async readahead and wait for it to
- * unlock.
+ * We found the page, so try async readahead before
+ * waiting for the lock.
*/
do_async_mmap_readahead(vma, ra, file, page, offset);
lock_page(page);

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/