readahead: cleanup blockable_page_cache_readahead()
Subsystems (2)
PATCH RESEND 4/4 readahead: cleanup blockable_page_cache_readahead()
I think that do_page_cache_readahead() can be inlined in blockable_page_cache_readahead(), this makes the code a bit more readable in my opinion.
Also makes check_ra_success() static inline.
mm/readahead.c renamed from mm/readahead.c~ +7 -11
@@ -348,8 +348,8 @@ int force_page_cache_readahead(struct ad* readahead isn't helping. * */ -int check_ra_success (struct file_ra_state *ra,unsigned long nr_to_read, -unsigned long actual) +static inline int check_ra_success (struct file_ra_state *ra, +unsigned long nr_to_read,unsigned long actual) {if (actual ==0 ) { ra->cache_hit += nr_to_read;
@@ -394,15 +394,11 @@ blockable_page_cache_readahead(struct ad {int actual; -if (block) { - actual =__do_page_cache_readahead (mapping, filp, - offset, nr_to_read); - }else { - actual =do_page_cache_readahead (mapping, filp, - offset, nr_to_read); -if (actual ==-1 ) -return 0 ; - } +if (!block &&bdi_read_congested (mapping->backing_dev_info)) +return 0 ; + + actual =__do_page_cache_readahead (mapping, filp, offset, nr_to_read); +return check_ra_success (ra, nr_to_read, actual); }
Andrew,
I have verified the patches against my standard benchmarks and did not see any bad effects.
Also I have reviewd the patch and it looked clean and correct.
RP
Quoted 41 lines · Oleg Nesterov
I think that
do_page_cache_readahead()can be inlined inblockable_page_cache_readahead(), this makes the code a bit more readable in my opinion.Also makes
check_ra_success()static inline.Signed-off-by Oleg Nesterov <[email protected]>mm/readahead.c renamed from mm/readahead.c~ +7
-11@@ -348,8 +348,8 @@ int force_page_cache_readahead(struct ad* readahead isn't helping. * */ -int check_ra_success (struct file_ra_state *ra,unsigned long nr_to_read, -unsigned long actual) +static inline int check_ra_success (struct file_ra_state *ra, +unsigned long nr_to_read,unsigned long actual) {if (actual ==0 ) { ra->cache_hit += nr_to_read;@@ -394,15 +394,11 @@ blockable_page_cache_readahead(struct ad {int actual; -if (block) { - actual =__do_page_cache_readahead (mapping, filp, - offset, nr_to_read); - }else { - actual =do_page_cache_readahead (mapping, filp, - offset, nr_to_read); -if (actual ==-1 ) -return 0 ; - } +if (!block &&bdi_read_congested (mapping->backing_dev_info)) +return 0 ; + + actual =__do_page_cache_readahead (mapping, filp, offset, nr_to_read); +return check_ra_success (ra, nr_to_read, actual); }
Quoted 9 lines · Ram
Andrew,
I have verified the patches against my standard benchmarks and did not see any bad effects.Also I have reviewd the patch and it looked clean and correct.
RP
I have not had a chance to benchmark, but visual inspection looks good.
Steve
Quoted 46 lines · Oleg Nesterov
Quoted 45 lines
I think that
do_page_cache_readahead()can be inlined inblockable_page_cache_readahead(), this makes the code a bit more readable in my opinion.Also makes
check_ra_success()static inline.Signed-off-by Oleg Nesterov <[email protected]>mm/readahead.c renamed from mm/readahead.c~ +7
-11@@ -348,8 +348,8 @@ int force_page_cache_readahead(struct ad* readahead isn't helping. * */ -int check_ra_success (struct file_ra_state *ra,unsigned long nr_to_read, -unsigned long actual) +static inline int check_ra_success (struct file_ra_state *ra, +unsigned long nr_to_read,unsigned long actual) {if (actual ==0 ) { ra->cache_hit += nr_to_read;@@ -394,15 +394,11 @@ blockable_page_cache_readahead(struct ad {int actual; -if (block) { - actual =__do_page_cache_readahead (mapping, filp, - offset, nr_to_read); - }else { - actual =do_page_cache_readahead (mapping, filp, - offset, nr_to_read); -if (actual ==-1 ) -return 0 ; - } +if (!block &&bdi_read_congested (mapping->backing_dev_info)) +return 0 ; + + actual =__do_page_cache_readahead (mapping, filp, offset, nr_to_read); +return check_ra_success (ra, nr_to_read, actual); }