[patch] filemap_getpage can block when MAP_NONBLOCK specified

From: Jeff Moyer (jmoyer_at_redhat.com)
Date: 03/30/05

  • Next message: Indrek Kruusa: "Re: How's the nforce4 support in Linux?"
    Date:	Wed, 30 Mar 2005 15:15:46 -0500
    To: linux-kernel@vger.kernel.org
    
    

    Hello,

    We will return NULL from filemap_getpage when a page does not exist in the
    page cache and MAP_NONBLOCK is specified, here:

            page = find_get_page(mapping, pgoff);
            if (!page) {
                    if (nonblock)
                            return NULL;
                    goto no_cached_page;
            }

    But we forget to do so when the page in the cache is not uptodate. The
    following could result in a blocking call:

            /*
             * Ok, found a page in the page cache, now we need to check
             * that it's up-to-date.
             */
            if (!PageUptodate(page))
                    goto page_not_uptodate;

    Patch attached.

    Thanks,

    Jeff

    --- linux-2.6.11/mm/filemap.c.orig 2005-03-30 14:57:02.252975936 -0500
    +++ linux-2.6.11/mm/filemap.c 2005-03-30 15:02:51.808835368 -0500
    @@ -1379,8 +1379,13 @@ retry_find:
              * Ok, found a page in the page cache, now we need to check
              * that it's up-to-date.
              */
    - if (!PageUptodate(page))
    + if (!PageUptodate(page)) {
    + if (nonblock) {
    + page_cache_release(page);
    + return NULL;
    + }
                     goto page_not_uptodate;
    + }
     
     success:
             /*
    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/


  • Next message: Indrek Kruusa: "Re: How's the nforce4 support in Linux?"

    Relevant Pages

    • Re: amd64, 2.6.7: several problems
      ... KB of cache and is clocked at 2.0 GHz, and the second has 512 KB of cache and ... is clocked at 2.2 GHz. ... send the line "unsubscribe linux-kernel" in ... More majordomo info at http://vger.kernel.org/majordomo-info.html ...
      (Linux-Kernel)
    • Re: Bug: Pentium M not always detected by CPUFREQ
      ... cache size: 64 KB ... More majordomo info at http://vger.kernel.org/majordomo-info.html ... Please read the FAQ at http://www.tux.org/lkml/ ...
      (Linux-Kernel)
    • RE: why swap at all?
      ... But this doesn't help in this case as the image-file is up to 4,4GB in ... whole which means that it ALONE can fill up the whole cache. ... Real Programmers consider "what you see is what you get" to be just as ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • Re: irq load balancing
      ... performance reasons (cache issues etc). ... More majordomo info at http://vger.kernel.org/majordomo-info.html ... Please read the FAQ at http://www.tux.org/lkml/ ...
      (Linux-Kernel)
    • How to dump the page addresses of a kmem_cache object?
      ... this cache? ... Can someone give me a rough idea or direct me to somewhere ... More majordomo info at http://vger.kernel.org/majordomo-info.html ... Please read the FAQ at http://www.tux.org/lkml/ ...
      (Linux-Kernel)