From: Andrew Morton <akpm@linux-foundation.org>
To: Nick Piggin <npiggin@kernel.dk>
Cc: linux-mm@kvack.org
Subject: Re: [patch] mm: find_get_pages_contig fixlet
Date: Thu, 11 Nov 2010 22:05:53 -0800 [thread overview]
Message-ID: <20101111220553.64911bfd.akpm@linux-foundation.org> (raw)
In-Reply-To: <20101111075455.GA10210@amd>
On Thu, 11 Nov 2010 18:54:55 +1100 Nick Piggin <npiggin@kernel.dk> wrote:
> Testing ->mapping and ->index without a ref is not stable as the page
> may have been reused at this point.
>
> Signed-off-by: Nick Piggin <npiggin@kernel.dk>
> ---
> mm/filemap.c | 13 ++++++++++---
> 1 file changed, 10 insertions(+), 3 deletions(-)
>
> Index: linux-2.6/mm/filemap.c
> ===================================================================
> --- linux-2.6.orig/mm/filemap.c 2010-11-11 18:51:51.000000000 +1100
> +++ linux-2.6/mm/filemap.c 2010-11-11 18:51:52.000000000 +1100
> @@ -835,9 +835,6 @@ unsigned find_get_pages_contig(struct ad
> if (radix_tree_deref_retry(page))
> goto restart;
>
> - if (page->mapping == NULL || page->index != index)
> - break;
> -
> if (!page_cache_get_speculative(page))
> goto repeat;
>
> @@ -847,6 +844,16 @@ unsigned find_get_pages_contig(struct ad
> goto repeat;
> }
>
> + /*
> + * must check mapping and index after taking the ref.
> + * otherwise we can get both false positives and false
> + * negatives, which is just confusing to the caller.
> + */
> + if (page->mapping == NULL || page->index != index) {
> + page_cache_release(page);
> + break;
> + }
> +
Dumb question: if it's been "reused" then what prevents the page from
having a non-NULL ->mapping and a matching index?
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom policy in Canada: sign http://dissolvethecrtc.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2010-11-12 6:14 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-11 7:54 [patch] mm: find_get_pages_contig fixlet Nick Piggin
2010-11-11 12:02 ` Wu Fengguang
2010-11-12 5:48 ` Nick Piggin
2010-11-12 5:58 ` Minchan Kim
2010-11-12 6:05 ` Andrew Morton [this message]
2010-11-12 7:25 ` Minchan Kim
2010-11-15 4:36 ` Nick Piggin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20101111220553.64911bfd.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=linux-mm@kvack.org \
--cc=npiggin@kernel.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.