The patch titled readahead: kconfig option READAHEAD_HIT_FEEDBACK has been added to the -mm tree. Its filename is readahead-call-scheme-no-fastcall-for-readahead_cache_hit-kconfig-option-readahead_hit_feedback.patch See http://www.zip.com.au/~akpm/linux/patches/stuff/added-to-mm.txt to find out what to do about this ------------------------------------------------------ Subject: readahead: kconfig option READAHEAD_HIT_FEEDBACK From: Wu Fengguang <wfg@xxxxxxxxxxxxxxxx> Introduce a kconfig option READAHEAD_HIT_FEEDBACK to enable users to disable the readahead hit feedback feature. The readahead hit accounting brings per-page overheads. However it is necessary for the onseek method, and possible strides method in future. Signed-off-by: Wu Fengguang <wfg@xxxxxxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxx> --- include/linux/fs.h | 14 ++++++++------ include/linux/mm.h | 9 +++++++++ mm/Kconfig | 10 ++++++++++ mm/readahead.c | 27 ++++++++++++++++++++++----- 4 files changed, 49 insertions(+), 11 deletions(-) diff -puN include/linux/fs.h~readahead-call-scheme-no-fastcall-for-readahead_cache_hit-kconfig-option-readahead_hit_feedback include/linux/fs.h --- a/include/linux/fs.h~readahead-call-scheme-no-fastcall-for-readahead_cache_hit-kconfig-option-readahead_hit_feedback +++ a/include/linux/fs.h @@ -647,6 +647,13 @@ struct file_ra_state { pgoff_t readahead_index; /* + * Snapshot of the (node's) read-ahead aging value + * on time of I/O submission. + */ + unsigned long age; + +#ifdef CONFIG_READAHEAD_HIT_FEEDBACK + /* * Read-ahead hits. * i.e. # of distinct read-ahead pages accessed. * @@ -659,12 +666,7 @@ struct file_ra_state { u16 hit1; /* for the current sequence */ u16 hit2; /* for the previous sequence */ u16 hit3; /* for the prev-prev sequence */ - - /* - * Snapshot of the (node's) read-ahead aging value - * on time of I/O submission. - */ - unsigned long age; +#endif }; #endif }; diff -puN include/linux/mm.h~readahead-call-scheme-no-fastcall-for-readahead_cache_hit-kconfig-option-readahead_hit_feedback include/linux/mm.h --- a/include/linux/mm.h~readahead-call-scheme-no-fastcall-for-readahead_cache_hit-kconfig-option-readahead_hit_feedback +++ a/include/linux/mm.h @@ -997,7 +997,16 @@ page_cache_readahead_adaptive(struct add struct file_ra_state *ra, struct file *filp, struct page *prev_page, struct page *page, pgoff_t first_index, pgoff_t index, pgoff_t last_index); + +#if defined(CONFIG_READAHEAD_HIT_FEEDBACK) || defined(CONFIG_DEBUG_READAHEAD) void readahead_cache_hit(struct file_ra_state *ra, struct page *page); +#else +static inline void readahead_cache_hit(struct file_ra_state *ra, + struct page *page) +{ +} +#endif + #ifdef CONFIG_ADAPTIVE_READAHEAD extern int readahead_ratio; diff -puN mm/Kconfig~readahead-call-scheme-no-fastcall-for-readahead_cache_hit-kconfig-option-readahead_hit_feedback mm/Kconfig --- a/mm/Kconfig~readahead-call-scheme-no-fastcall-for-readahead_cache_hit-kconfig-option-readahead_hit_feedback +++ a/mm/Kconfig @@ -215,6 +215,16 @@ config DEBUG_READAHEAD Say N for production servers. +config READAHEAD_HIT_FEEDBACK + bool "Readahead hit feedback" + default y + depends on READAHEAD_ALLOW_OVERHEADS + help + Enable readahead hit feedback. + + It is not needed in normal cases, except for detecting the + seek-and-read pattern. + config READAHEAD_SMOOTH_AGING bool "Fine grained readahead aging" default n diff -puN mm/readahead.c~readahead-call-scheme-no-fastcall-for-readahead_cache_hit-kconfig-option-readahead_hit_feedback mm/readahead.c --- a/mm/readahead.c~readahead-call-scheme-no-fastcall-for-readahead_cache_hit-kconfig-option-readahead_hit_feedback +++ a/mm/readahead.c @@ -881,8 +881,12 @@ static unsigned long ra_invoke_interval( */ static int ra_cache_hit_ok(struct file_ra_state *ra) { +#ifdef CONFIG_READAHEAD_HIT_FEEDBACK return ra->hit0 * readahead_hit_rate >= (ra->lookahead_index - ra->la_index); +#else + return 1; +#endif } /* @@ -916,6 +920,7 @@ static void ra_set_class(struct file_ra_ ra->flags = flags | old_ra_class | ra_class; +#ifdef CONFIG_READAHEAD_HIT_FEEDBACK /* * Add request-hit up to sequence-hit and reset the former. */ @@ -932,6 +937,7 @@ static void ra_set_class(struct file_ra_ ra->hit2 = ra->hit1; ra->hit1 = 0; } +#endif } /* @@ -1600,6 +1606,7 @@ static int try_readahead_on_seek(struct file_ra_state *ra, pgoff_t index, unsigned long ra_size, unsigned long ra_max) { +#ifdef CONFIG_READAHEAD_HIT_FEEDBACK unsigned long hit0 = ra->hit0; unsigned long hit1 = ra->hit1 + hit0; unsigned long hit2 = ra->hit2; @@ -1628,6 +1635,9 @@ try_readahead_on_seek(struct file_ra_sta ra_set_size(ra, ra_size, 0); return 1; +#else + return 0; +#endif } /* @@ -1655,7 +1665,7 @@ thrashing_recovery_readahead(struct addr ra_size = ra->ra_index - index; else { /* After thrashing, we know the exact thrashing-threshold. */ - ra_size = ra->hit0; + ra_size = index - ra->ra_index; update_ra_thrash_bytes(mapping->backing_dev_info, ra_size); /* And we'd better be a bit conservative. */ @@ -1819,6 +1829,7 @@ readit: return size; } +#if defined(CONFIG_READAHEAD_HIT_FEEDBACK) || defined(CONFIG_DEBUG_READAHEAD) /** * readahead_cache_hit - adaptive read-ahead feedback function * @ra: file_ra_state which holds the readahead state @@ -1838,13 +1849,16 @@ void readahead_cache_hit(struct file_ra_ if (!ra_has_index(ra, page->index)) return; +#ifdef CONFIG_READAHEAD_HIT_FEEDBACK ra->hit0++; +#endif if (page->index >= ra->ra_index) ra_account(ra, RA_EVENT_READAHEAD_HIT, 1); else ra_account(ra, RA_EVENT_READAHEAD_HIT, -1); } +#endif /* * When closing a normal readonly file, @@ -1860,7 +1874,6 @@ void readahead_close(struct file *file) struct address_space *mapping = inode->i_mapping; struct backing_dev_info *bdi = mapping->backing_dev_info; unsigned long pos = file->f_pos; /* supposed to be small */ - unsigned long pgrahit = file->f_ra.hit0; unsigned long pgcached = mapping->nrpages; unsigned long pgaccess; @@ -1870,7 +1883,12 @@ void readahead_close(struct file *file) if (pgcached > bdi->ra_pages0) /* excessive reads */ return; - pgaccess = max(pgrahit, 1 + pos / PAGE_CACHE_SIZE); + pgaccess = 1 + pos / PAGE_CACHE_SIZE; +#ifdef CONFIG_READAHEAD_HIT_FEEDBACK + if (pgaccess < file->f_ra.hit0) + pgaccess = file->f_ra.hit0; +#endif + if (pgaccess >= pgcached) { if (bdi->ra_expect_bytes < bdi->ra_pages0 * PAGE_CACHE_SIZE) bdi->ra_expect_bytes += pgcached * PAGE_CACHE_SIZE / 8; @@ -1891,12 +1909,11 @@ void readahead_close(struct file *file) debug_inc(initial_ra_miss); dprintk("initial_ra_miss on file %s " - "size %lluK cached %luK hit %luK " + "size %lluK cached %luK " "pos %lu by %s(%d)\n", file->f_dentry->d_name.name, i_size_read(inode) / 1024, pgcached << (PAGE_CACHE_SHIFT - 10), - pgrahit << (PAGE_CACHE_SHIFT - 10), pos, current->comm, current->pid); } _ Patches currently in -mm which might be from wfg@xxxxxxxxxxxxxxxx are origin.patch readahead-kconfig-options.patch readahead-kconfig-option-readahead_allow_overheads.patch radixtree-introduce-radix_tree_scan_hole.patch mm-introduce-probe_page.patch mm-introduce-pg_readahead.patch readahead-add-look-ahead-support-to-__do_page_cache_readahead.patch readahead-delay-page-release-in-do_generic_mapping_read.patch readahead-insert-cond_resched-calls.patch readahead-minmax_ra_pages.patch readahead-events-accounting.patch readahead-rescue_pages.patch readahead-sysctl-parameters.patch readahead-sysctl-parameters-fix.patch readahead-min-max-sizes.patch readahead-state-based-method-aging-accounting.patch readahead-state-based-method-routines.patch readahead-state-based-method-routines-no-ra_flag_eof-on-single-page-file.patch readahead-state-based-method.patch readahead-state-based-method-readahead-state-based-method-stand-alone-size-limit-code.patch readahead-state-based-method-aging-accounting-readahead-kconfig-option-readahead_smooth_aging.patch readahead-context-based-method.patch readahead-context-based-method-apply-stream_shift-size-limits-to-contexta-method.patch readahead-context-based-method-fix-remain-counting.patch readahead-context-based-method-slow-start.patch readahead-initial-method-guiding-sizes.patch readahead-initial-method-guiding-sizes-aggressive-initial-sizes.patch readahead-initial-method-thrashing-guard-size.patch readahead-initial-method-expected-read-size.patch readahead-initial-method-user-recommended-size.patch readahead-initial-method.patch readahead-backward-prefetching-method.patch readahead-backward-prefetching-method-add-use-case-comment.patch readahead-seeking-reads-method.patch readahead-thrashing-recovery-method.patch readahead-call-scheme.patch readahead-call-scheme-fix-fastcall.patch readahead-call-scheme-no-fastcall-for-readahead_cache_hit.patch readahead-call-scheme-no-fastcall-for-readahead_cache_hit-kconfig-option-readahead_hit_feedback.patch readahead-laptop-mode.patch readahead-loop-case.patch readahead-nfsd-case.patch readahead-turn-on-by-default.patch readahead-debug-radix-tree-new-functions.patch readahead-debug-traces-showing-accessed-file-names.patch readahead-debug-traces-showing-read-patterns.patch readahead-remove-size-limit-on-read_ahead_kb.patch readahead-backward-prefetching-method-fix.patch readahead-remove-the-size-limit-of-max_sectors_kb-on-read_ahead_kb.patch - To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html