UBUNTU: SAUCE: add tracing for user initiated readahead requests
authorAndy Whitcroft <apw@canonical.com>
Thu, 29 Jul 2010 08:46:41 +0000 (09:46 +0100)
committerLeann Ogasawara <leann.ogasawara@canonical.com>
Mon, 28 Mar 2011 13:49:04 +0000 (06:49 -0700)
Track pages which undergo readahead and for each record which were
actually consumed, via either read or faulted into a map.  This allows
userspace readahead applications (such as ureadahead) to track which
pages in core at the end of a boot are actually required and generate an
optimal readahead pack.  It also allows pack adjustment and optimisation
in parallel with readahead, allowing the pack to evolve to be accurate
as userspace paths change.  The status of the pages are reported back via
the mincore() call using a newly allocated bit.

Signed-off-by: Andy Whitcroft <apw@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Signed-off-by: Leann Ogasawara <leann.ogasawara@canonical.com>

include/linux/page-flags.h
mm/filemap.c
mm/memory.c
mm/mincore.c
mm/readahead.c

index 0db8037..94b3f07 100644 (file)
@@ -107,6 +107,7 @@ enum pageflags {
 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
        PG_compound_lock,
 #endif
+       PG_readaheadunused,     /* user oriented readahead as yet unused*/
        __NR_PAGEFLAGS,
 
        /* Filesystems */
@@ -235,6 +236,8 @@ PAGEFLAG(MappedToDisk, mappedtodisk)
 PAGEFLAG(Reclaim, reclaim) TESTCLEARFLAG(Reclaim, reclaim)
 PAGEFLAG(Readahead, reclaim)           /* Reminder to do async read-ahead */
 
+PAGEFLAG(ReadaheadUnused, readaheadunused)
+
 #ifdef CONFIG_HIGHMEM
 /*
  * Must use a macro here due to header dependency issues. page_zone() is not
index 83a45d3..4fdc966 100644 (file)
@@ -1211,6 +1211,9 @@ int file_read_actor(read_descriptor_t *desc, struct page *page,
        if (size > count)
                size = count;
 
+       if (PageReadaheadUnused(page))
+               ClearPageReadaheadUnused(page);
+
        /*
         * Faults on the destination of a read are common, so do it before
         * taking the kmap.
index 5823698..42ed735 100644 (file)
@@ -3030,10 +3030,15 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
        else
                VM_BUG_ON(!PageLocked(vmf.page));
 
+       page = vmf.page;
+
+       /* Mark the page as used on fault. */
+       if (PageReadaheadUnused(page))
+               ClearPageReadaheadUnused(page);
+
        /*
         * Should we do an early C-O-W break?
         */
-       page = vmf.page;
        if (flags & FAULT_FLAG_WRITE) {
                if (!(vma->vm_flags & VM_SHARED)) {
                        anon = 1;
index a4e6b9d..e7b61de 100644 (file)
@@ -77,6 +77,8 @@ static unsigned char mincore_page(struct address_space *mapping, pgoff_t pgoff)
        page = find_get_page(mapping, pgoff);
        if (page) {
                present = PageUptodate(page);
+               if (present)
+                       present |= (PageReadaheadUnused(page) << 7);
                page_cache_release(page);
        }
 
index 77506a2..6948b92 100644 (file)
@@ -181,6 +181,7 @@ __do_page_cache_readahead(struct address_space *mapping, struct file *filp,
                list_add(&page->lru, &page_pool);
                if (page_idx == nr_to_read - lookahead_size)
                        SetPageReadahead(page);
+               SetPageReadaheadUnused(page);
                ret++;
        }