From: Dave McCracken <dmccr@us.ibm.com>
To: Andrew Morton <akpm@digeo.com>
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org
Subject: [PATCH 2.5.63] Teach page_mapped about the anon flag
Date: Mon, 03 Mar 2003 15:06:21 -0600 [thread overview]
Message-ID: <103400000.1046725581@baldur.austin.ibm.com> (raw)
In-Reply-To: <20030227142450.1c6a6b72.akpm@digeo.com>
[-- Attachment #1: Type: text/plain, Size: 1177 bytes --]
--On Thursday, February 27, 2003 14:24:50 -0800 Andrew Morton
<akpm@digeo.com> wrote:
> I'm just looking at page_mapped(). It is now implicitly assuming that the
> architecture's representation of a zero-count atomic_t is all-bits-zero.
>
> This is not true on sparc32 if some other CPU is in the middle of an
> atomic_foo() against that counter. Maybe the assumption is false on other
> architectures too.
>
> So page_mapped() really should be performing an atomic_read() if that is
> appropriate to the particular page. I guess this involves testing
> page->mapping. Which is stable only when the page is locked or
> mapping->page_lock is held.
>
> It appears that all page_mapped() callers are inside lock_page() at
> present, so a quick audit and addition of a comment would be appropriate
> there please.
I'm not at all confident that page_mapped() is adequately protected.
Here's a patch that explicitly handles the atomic_t case.
Dave McCracken
======================================================================
Dave McCracken IBM Linux Base Kernel Team 1-512-838-3059
dmccr@us.ibm.com T/L 678-3059
[-- Attachment #2: objfix-2.5.63-1.diff --]
[-- Type: text/plain, Size: 738 bytes --]
--- 2.5.63-objrmap/include/linux/mm.h 2003-02-27 15:58:34.000000000 -0600
+++ 2.5.63-objfix/include/linux/mm.h 2003-02-28 14:21:56.000000000 -0600
@@ -363,10 +363,16 @@
* Return true if this page is mapped into pagetables. Subtle: test pte.direct
* rather than pte.chain. Because sometimes pte.direct is 64-bit, and .chain
* is only 32-bit.
+ *
+ * If the page is an object-mapped page, we need to do an atomic read of
+ * pte.mapcount instead, since atomic values may not be zero in the upper bits.
*/
static inline int page_mapped(struct page *page)
{
- return page->pte.direct != 0;
+ if (PageAnon(page))
+ return page->pte.direct != 0;
+ else
+ return atomic_read(&page->pte.mapcount) != 0;
}
/*
next prev parent reply other threads:[~2003-03-03 21:06 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-02-27 10:59 2.5.63-mm1 Andrew Morton
2003-02-27 21:22 ` Rising io_load results 2.5.63-mm1 Con Kolivas
2003-02-27 21:44 ` Andrew Morton
2003-02-27 22:01 ` Dave McCracken
2003-02-27 22:24 ` Andrew Morton
2003-03-03 21:06 ` Dave McCracken [this message]
2003-03-03 21:12 ` [PATCH 2.5.63] Teach page_mapped about the anon flag Andrew Morton
2003-03-03 21:24 ` Dave McCracken
2003-03-03 21:35 ` Andrew Morton
2003-03-03 21:52 ` Dave McCracken
2003-03-03 22:15 ` Andrew Morton
2003-03-04 18:32 ` [PATCH 2.5.63] Make objrmap mapcount non-atomic Dave McCracken
2003-02-27 23:56 ` Rising io_load results Re: 2.5.63-mm1 Con Kolivas
2003-02-28 0:06 ` Andrew Morton
2003-02-28 0:28 ` Con Kolivas
2003-02-28 7:46 ` Duncan Sands
2003-02-28 8:06 ` Andrew Morton
2003-02-28 12:48 ` Hugh Dickins
2003-02-28 15:56 ` Dave McCracken
2003-02-28 0:17 ` 2.5.63-mm1 Ed Tomlinson
2003-02-28 0:46 ` 2.5.63-mm1 Andrew Morton
2003-02-28 12:16 ` 2.5.63-mm1 steven roemen
2003-02-28 12:24 ` 2.5.63-mm1 Andrew Morton
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=103400000.1046725581@baldur.austin.ibm.com \
--to=dmccr@us.ibm.com \
--cc=akpm@digeo.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox