Skip to content

Commit

Permalink
mm/readahead.c: inline ra_submit
Browse files Browse the repository at this point in the history
Commit f9acc8c ("readahead: sanify file_ra_state names") left
ra_submit with a single function call.

Move ra_submit to internal.h and inline it to save some stack.  Thanks
to Andrew Morton for commenting different versions.

Signed-off-by: Fabian Frederick <[email protected]>
Suggested-by: Andrew Morton <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Fabian Frederick authored and torvalds committed Apr 7, 2014
1 parent 55f6714 commit 29f175d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 21 deletions.
3 changes: 0 additions & 3 deletions include/linux/mm.h
Original file line number Diff line number Diff line change
Expand Up @@ -1875,9 +1875,6 @@ void page_cache_async_readahead(struct address_space *mapping,
unsigned long size);

unsigned long max_sane_readahead(unsigned long nr);
unsigned long ra_submit(struct file_ra_state *ra,
struct address_space *mapping,
struct file *filp);

/* Generic expand stack which grows the stack according to GROWS{UP,DOWN} */
extern int expand_stack(struct vm_area_struct *vma, unsigned long address);
Expand Down
15 changes: 15 additions & 0 deletions mm/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#ifndef __MM_INTERNAL_H
#define __MM_INTERNAL_H

#include <linux/fs.h>
#include <linux/mm.h>

void free_pgtables(struct mmu_gather *tlb, struct vm_area_struct *start_vma,
Expand All @@ -21,6 +22,20 @@ static inline void set_page_count(struct page *page, int v)
atomic_set(&page->_count, v);
}

extern int __do_page_cache_readahead(struct address_space *mapping,
struct file *filp, pgoff_t offset, unsigned long nr_to_read,
unsigned long lookahead_size);

/*
* Submit IO for the read-ahead request in file_ra_state.
*/
static inline unsigned long ra_submit(struct file_ra_state *ra,
struct address_space *mapping, struct file *filp)
{
return __do_page_cache_readahead(mapping, filp,
ra->start, ra->size, ra->async_size);
}

/*
* Turn a non-refcounted page (->_count == 0) into refcounted with
* a count of one.
Expand Down
21 changes: 3 additions & 18 deletions mm/readahead.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
*/

#include <linux/kernel.h>
#include <linux/fs.h>
#include <linux/gfp.h>
#include <linux/mm.h>
#include <linux/export.h>
#include <linux/blkdev.h>
#include <linux/backing-dev.h>
Expand All @@ -20,6 +18,8 @@
#include <linux/syscalls.h>
#include <linux/file.h>

#include "internal.h"

/*
* Initialise a struct file's readahead state. Assumes that the caller has
* memset *ra to zero.
Expand Down Expand Up @@ -149,8 +149,7 @@ static int read_pages(struct address_space *mapping, struct file *filp,
*
* Returns the number of pages requested, or the maximum amount of I/O allowed.
*/
static int
__do_page_cache_readahead(struct address_space *mapping, struct file *filp,
int __do_page_cache_readahead(struct address_space *mapping, struct file *filp,
pgoff_t offset, unsigned long nr_to_read,
unsigned long lookahead_size)
{
Expand Down Expand Up @@ -243,20 +242,6 @@ unsigned long max_sane_readahead(unsigned long nr)
return min(nr, MAX_READAHEAD);
}

/*
* Submit IO for the read-ahead request in file_ra_state.
*/
unsigned long ra_submit(struct file_ra_state *ra,
struct address_space *mapping, struct file *filp)
{
int actual;

actual = __do_page_cache_readahead(mapping, filp,
ra->start, ra->size, ra->async_size);

return actual;
}

/*
* Set the initial window size, round to next power of 2 and square
* for small size, x 4 for medium, and x 2 for large
Expand Down

0 comments on commit 29f175d

Please sign in to comment.