lkml.org 
[lkml]   [2020]   [Nov]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Subject[RFC PATCH 20/76] mm: Stop generic_file_buffered_read() from grabbing a superfluous page
    From
    Date
    Under some circumstances, generic_file_buffered_read() will allocate
    sufficient pages to read to the end of the file, call readahead/readpages
    on them and copy the data over - and then it will allocate another page at
    the EOF and call readpage on that and then ignore it. This is unnecessary
    and a waste of time and resources.

    Catch the overallocation in the "no_cached_page:" part and prevent it from
    happening.

    Signed-off-by: David Howells <dhowells@redhat.com>
    ---

    mm/filemap.c | 2 ++
    1 file changed, 2 insertions(+)

    diff --git a/mm/filemap.c b/mm/filemap.c
    index cfb753955e36..5a63aa1dd71e 100644
    --- a/mm/filemap.c
    +++ b/mm/filemap.c
    @@ -2447,6 +2447,8 @@ ssize_t generic_file_buffered_read(struct kiocb *iocb,
    * Ok, it wasn't cached, so we need to create a new
    * page..
    */
    + if ((index << PAGE_SHIFT) >= i_size_read(inode))
    + goto out;
    page = page_cache_alloc(mapping);
    if (!page) {
    error = -ENOMEM;

    \
     
     \ /
      Last update: 2020-11-20 16:09    [W:4.515 / U:0.632 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site