2005-04-16 16:20:36 -06:00
|
|
|
/*
|
|
|
|
* Macros for manipulating and testing page->flags
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef PAGE_FLAGS_H
|
|
|
|
#define PAGE_FLAGS_H
|
|
|
|
|
2006-06-23 03:03:06 -06:00
|
|
|
#include <linux/types.h>
|
2008-04-28 03:12:48 -06:00
|
|
|
#ifndef __GENERATING_BOUNDS_H
|
2007-05-06 15:49:40 -06:00
|
|
|
#include <linux/mm_types.h>
|
2008-04-28 03:12:48 -06:00
|
|
|
#include <linux/bounds.h>
|
|
|
|
#endif /* !__GENERATING_BOUNDS_H */
|
2006-06-23 03:03:06 -06:00
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
/*
|
|
|
|
* Various page->flags bits:
|
|
|
|
*
|
|
|
|
* PG_reserved is set for special pages, which can never be swapped out. Some
|
|
|
|
* of them might not even exist (eg empty_bad_page)...
|
|
|
|
*
|
2006-09-26 00:31:35 -06:00
|
|
|
* The PG_private bitflag is set on pagecache pages if they contain filesystem
|
|
|
|
* specific data (which is normally at page->private). It can be used by
|
|
|
|
* private allocations for its own usage.
|
2005-04-16 16:20:36 -06:00
|
|
|
*
|
2006-09-26 00:31:35 -06:00
|
|
|
* During initiation of disk I/O, PG_locked is set. This bit is set before I/O
|
|
|
|
* and cleared when writeback _starts_ or when read _completes_. PG_writeback
|
|
|
|
* is set before writeback starts and cleared when it finishes.
|
|
|
|
*
|
|
|
|
* PG_locked also pins a page in pagecache, and blocks truncation of the file
|
|
|
|
* while it is held.
|
|
|
|
*
|
|
|
|
* page_waitqueue(page) is a wait queue of all tasks waiting for the page
|
|
|
|
* to become unlocked.
|
2005-04-16 16:20:36 -06:00
|
|
|
*
|
|
|
|
* PG_uptodate tells whether the page's contents is valid. When a read
|
|
|
|
* completes, the page becomes uptodate, unless a disk I/O error happened.
|
|
|
|
*
|
2006-09-26 00:31:35 -06:00
|
|
|
* PG_referenced, PG_reclaim are used for page reclaim for anonymous and
|
|
|
|
* file-backed pagecache (see mm/vmscan.c).
|
2005-04-16 16:20:36 -06:00
|
|
|
*
|
|
|
|
* PG_error is set to indicate that an I/O error occurred on this page.
|
|
|
|
*
|
|
|
|
* PG_arch_1 is an architecture specific page state bit. The generic code
|
|
|
|
* guarantees that this bit is cleared for a page when it first is entered into
|
|
|
|
* the page cache.
|
|
|
|
*
|
|
|
|
* PG_highmem pages are not permanently mapped into the kernel virtual address
|
|
|
|
* space, they need to be kmapped separately for doing IO on the pages. The
|
|
|
|
* struct page (these bits with information) are always mapped into kernel
|
|
|
|
* address space...
|
2006-09-26 00:31:35 -06:00
|
|
|
*
|
|
|
|
* PG_buddy is set to indicate that the page is free and in the buddy system
|
|
|
|
* (see mm/page_alloc.c).
|
|
|
|
*
|
2005-04-16 16:20:36 -06:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Don't use the *_dontuse flags. Use the macros. Otherwise you'll break
|
2006-04-10 23:53:01 -06:00
|
|
|
* locked- and dirty-page accounting.
|
|
|
|
*
|
|
|
|
* The page flags field is split into two parts, the main flags area
|
|
|
|
* which extends from the low bits upwards, and the fields area which
|
|
|
|
* extends from the high bits downwards.
|
|
|
|
*
|
|
|
|
* | FIELD | ... | FLAGS |
|
2008-04-28 03:12:48 -06:00
|
|
|
* N-1 ^ 0
|
|
|
|
* (NR_PAGEFLAGS)
|
2006-04-10 23:53:01 -06:00
|
|
|
*
|
2008-04-28 03:12:48 -06:00
|
|
|
* The fields area is reserved for fields mapping zone, node (for NUMA) and
|
|
|
|
* SPARSEMEM section (for variants of SPARSEMEM that require section ids like
|
|
|
|
* SPARSEMEM_EXTREME with !SPARSEMEM_VMEMMAP).
|
2005-04-16 16:20:36 -06:00
|
|
|
*/
|
2008-04-28 03:12:47 -06:00
|
|
|
enum pageflags {
|
|
|
|
PG_locked, /* Page is locked. Don't touch. */
|
|
|
|
PG_error,
|
|
|
|
PG_referenced,
|
|
|
|
PG_uptodate,
|
|
|
|
PG_dirty,
|
|
|
|
PG_lru,
|
|
|
|
PG_active,
|
|
|
|
PG_slab,
|
|
|
|
PG_owner_priv_1, /* Owner use. If pagecache, fs may use*/
|
|
|
|
PG_arch_1,
|
|
|
|
PG_reserved,
|
|
|
|
PG_private, /* If pagecache, has fs-private data */
|
|
|
|
PG_writeback, /* Page is under writeback */
|
|
|
|
PG_compound, /* A compound page */
|
|
|
|
PG_swapcache, /* Swap page: swp_entry_t in private */
|
|
|
|
PG_mappedtodisk, /* Has blocks allocated on-disk */
|
|
|
|
PG_reclaim, /* To be reclaimed asap */
|
|
|
|
PG_buddy, /* Page is free, on buddy lists */
|
2006-06-23 03:03:06 -06:00
|
|
|
|
|
|
|
#if (BITS_PER_LONG > 32)
|
|
|
|
/*
|
|
|
|
* 64-bit-only flags build down from bit 31
|
|
|
|
*
|
|
|
|
* 32 bit -------------------------------| FIELDS | FLAGS |
|
|
|
|
* 64 bit | FIELDS | ?????? FLAGS |
|
|
|
|
* 63 32 0
|
|
|
|
*/
|
2008-04-28 03:12:47 -06:00
|
|
|
PG_uncached = 31, /* Page has been mapped as uncached */
|
2006-06-23 03:03:06 -06:00
|
|
|
#endif
|
2008-04-28 03:12:48 -06:00
|
|
|
__NR_PAGEFLAGS
|
2008-04-28 03:12:47 -06:00
|
|
|
};
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2008-04-28 03:12:48 -06:00
|
|
|
#ifndef __GENERATING_BOUNDS_H
|
|
|
|
|
2008-04-28 03:12:49 -06:00
|
|
|
/*
|
|
|
|
* Macros to create function definitions for page flags
|
|
|
|
*/
|
|
|
|
#define TESTPAGEFLAG(uname, lname) \
|
|
|
|
static inline int Page##uname(struct page *page) \
|
|
|
|
{ return test_bit(PG_##lname, &page->flags); }
|
|
|
|
|
|
|
|
#define SETPAGEFLAG(uname, lname) \
|
|
|
|
static inline void SetPage##uname(struct page *page) \
|
|
|
|
{ set_bit(PG_##lname, &page->flags); }
|
|
|
|
|
|
|
|
#define CLEARPAGEFLAG(uname, lname) \
|
|
|
|
static inline void ClearPage##uname(struct page *page) \
|
|
|
|
{ clear_bit(PG_##lname, &page->flags); }
|
|
|
|
|
|
|
|
#define __SETPAGEFLAG(uname, lname) \
|
|
|
|
static inline void __SetPage##uname(struct page *page) \
|
|
|
|
{ __set_bit(PG_##lname, &page->flags); }
|
|
|
|
|
|
|
|
#define __CLEARPAGEFLAG(uname, lname) \
|
|
|
|
static inline void __ClearPage##uname(struct page *page) \
|
|
|
|
{ __clear_bit(PG_##lname, &page->flags); }
|
|
|
|
|
|
|
|
#define TESTSETFLAG(uname, lname) \
|
|
|
|
static inline int TestSetPage##uname(struct page *page) \
|
|
|
|
{ return test_and_set_bit(PG_##lname, &page->flags); }
|
|
|
|
|
|
|
|
#define TESTCLEARFLAG(uname, lname) \
|
|
|
|
static inline int TestClearPage##uname(struct page *page) \
|
|
|
|
{ return test_and_clear_bit(PG_##lname, &page->flags); }
|
|
|
|
|
|
|
|
|
|
|
|
#define PAGEFLAG(uname, lname) TESTPAGEFLAG(uname, lname) \
|
|
|
|
SETPAGEFLAG(uname, lname) CLEARPAGEFLAG(uname, lname)
|
|
|
|
|
|
|
|
#define __PAGEFLAG(uname, lname) TESTPAGEFLAG(uname, lname) \
|
|
|
|
__SETPAGEFLAG(uname, lname) __CLEARPAGEFLAG(uname, lname)
|
|
|
|
|
|
|
|
#define TESTSCFLAG(uname, lname) \
|
|
|
|
TESTSETFLAG(uname, lname) TESTCLEARFLAG(uname, lname)
|
|
|
|
|
2008-04-28 03:12:50 -06:00
|
|
|
struct page; /* forward declaration */
|
|
|
|
|
|
|
|
PAGEFLAG(Locked, locked) TESTSCFLAG(Locked, locked)
|
|
|
|
PAGEFLAG(Error, error)
|
|
|
|
PAGEFLAG(Referenced, referenced) TESTCLEARFLAG(Referenced, referenced)
|
|
|
|
PAGEFLAG(Dirty, dirty) TESTSCFLAG(Dirty, dirty) __CLEARPAGEFLAG(Dirty, dirty)
|
|
|
|
PAGEFLAG(LRU, lru) __CLEARPAGEFLAG(LRU, lru)
|
|
|
|
PAGEFLAG(Active, active) __CLEARPAGEFLAG(Active, active)
|
|
|
|
__PAGEFLAG(Slab, slab)
|
2008-04-28 03:12:52 -06:00
|
|
|
PAGEFLAG(Checked, owner_priv_1) /* Used by some filesystems */
|
|
|
|
PAGEFLAG(Pinned, owner_priv_1) TESTSCFLAG(Pinned, owner_priv_1) /* Xen */
|
2008-04-28 03:12:50 -06:00
|
|
|
PAGEFLAG(Reserved, reserved) __CLEARPAGEFLAG(Reserved, reserved)
|
|
|
|
PAGEFLAG(Private, private) __CLEARPAGEFLAG(Private, private)
|
|
|
|
__SETPAGEFLAG(Private, private)
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Only test-and-set exist for PG_writeback. The unconditional operators are
|
|
|
|
* risky: they bypass page accounting.
|
|
|
|
*/
|
|
|
|
TESTPAGEFLAG(Writeback, writeback) TESTSCFLAG(Writeback, writeback)
|
|
|
|
__PAGEFLAG(Buddy, buddy)
|
|
|
|
PAGEFLAG(MappedToDisk, mappedtodisk)
|
|
|
|
|
|
|
|
/* PG_readahead is only used for file reads; PG_reclaim is only for writes */
|
|
|
|
PAGEFLAG(Reclaim, reclaim) TESTCLEARFLAG(Reclaim, reclaim)
|
2008-04-28 03:12:52 -06:00
|
|
|
PAGEFLAG(Readahead, reclaim) /* Reminder to do async read-ahead */
|
2008-04-28 03:12:50 -06:00
|
|
|
|
|
|
|
#ifdef CONFIG_HIGHMEM
|
2005-04-16 16:20:36 -06:00
|
|
|
/*
|
2008-04-28 03:12:50 -06:00
|
|
|
* Must use a macro here due to header dependency issues. page_zone() is not
|
|
|
|
* available at this point.
|
2005-04-16 16:20:36 -06:00
|
|
|
*/
|
2008-04-28 03:12:52 -06:00
|
|
|
#define PageHighMem(__p) is_highmem(page_zone(__p))
|
2008-04-28 03:12:50 -06:00
|
|
|
#else
|
|
|
|
static inline int PageHighMem(struct page *page)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_SWAP
|
|
|
|
PAGEFLAG(SwapCache, swapcache)
|
|
|
|
#else
|
|
|
|
static inline int PageSwapCache(struct page *page)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if (BITS_PER_LONG > 32)
|
|
|
|
PAGEFLAG(Uncached, uncached)
|
|
|
|
#endif
|
2005-04-16 16:20:36 -06:00
|
|
|
|
mm: fix PageUptodate data race
After running SetPageUptodate, preceeding stores to the page contents to
actually bring it uptodate may not be ordered with the store to set the
page uptodate.
Therefore, another CPU which checks PageUptodate is true, then reads the
page contents can get stale data.
Fix this by having an smp_wmb before SetPageUptodate, and smp_rmb after
PageUptodate.
Many places that test PageUptodate, do so with the page locked, and this
would be enough to ensure memory ordering in those places if
SetPageUptodate were only called while the page is locked. Unfortunately
that is not always the case for some filesystems, but it could be an idea
for the future.
Also bring the handling of anonymous page uptodateness in line with that of
file backed page management, by marking anon pages as uptodate when they
_are_ uptodate, rather than when our implementation requires that they be
marked as such. Doing allows us to get rid of the smp_wmb's in the page
copying functions, which were especially added for anonymous pages for an
analogous memory ordering problem. Both file and anonymous pages are
handled with the same barriers.
FAQ:
Q. Why not do this in flush_dcache_page?
A. Firstly, flush_dcache_page handles only one side (the smb side) of the
ordering protocol; we'd still need smp_rmb somewhere. Secondly, hiding away
memory barriers in a completely unrelated function is nasty; at least in the
PageUptodate macros, they are located together with (half) the operations
involved in the ordering. Thirdly, the smp_wmb is only required when first
bringing the page uptodate, wheras flush_dcache_page should be called each time
it is written to through the kernel mapping. It is logically the wrong place to
put it.
Q. Why does this increase my text size / reduce my performance / etc.
A. Because it is adding the necessary instructions to eliminate the data-race.
Q. Can it be improved?
A. Yes, eg. if you were to create a rule that all SetPageUptodate operations
run under the page lock, we could avoid the smp_rmb places where PageUptodate
is queried under the page lock. Requires audit of all filesystems and at least
some would need reworking. That's great you're interested, I'm eagerly awaiting
your patches.
Signed-off-by: Nick Piggin <npiggin@suse.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2008-02-04 23:29:34 -07:00
|
|
|
static inline int PageUptodate(struct page *page)
|
|
|
|
{
|
|
|
|
int ret = test_bit(PG_uptodate, &(page)->flags);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Must ensure that the data we read out of the page is loaded
|
|
|
|
* _after_ we've loaded page->flags to check for PageUptodate.
|
|
|
|
* We can skip the barrier if the page is not uptodate, because
|
|
|
|
* we wouldn't be reading anything from it.
|
|
|
|
*
|
|
|
|
* See SetPageUptodate() for the other side of the story.
|
|
|
|
*/
|
|
|
|
if (ret)
|
|
|
|
smp_rmb();
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void __SetPageUptodate(struct page *page)
|
|
|
|
{
|
|
|
|
smp_wmb();
|
|
|
|
__set_bit(PG_uptodate, &(page)->flags);
|
2006-06-30 02:55:32 -06:00
|
|
|
#ifdef CONFIG_S390
|
mm: fix PageUptodate data race
After running SetPageUptodate, preceeding stores to the page contents to
actually bring it uptodate may not be ordered with the store to set the
page uptodate.
Therefore, another CPU which checks PageUptodate is true, then reads the
page contents can get stale data.
Fix this by having an smp_wmb before SetPageUptodate, and smp_rmb after
PageUptodate.
Many places that test PageUptodate, do so with the page locked, and this
would be enough to ensure memory ordering in those places if
SetPageUptodate were only called while the page is locked. Unfortunately
that is not always the case for some filesystems, but it could be an idea
for the future.
Also bring the handling of anonymous page uptodateness in line with that of
file backed page management, by marking anon pages as uptodate when they
_are_ uptodate, rather than when our implementation requires that they be
marked as such. Doing allows us to get rid of the smp_wmb's in the page
copying functions, which were especially added for anonymous pages for an
analogous memory ordering problem. Both file and anonymous pages are
handled with the same barriers.
FAQ:
Q. Why not do this in flush_dcache_page?
A. Firstly, flush_dcache_page handles only one side (the smb side) of the
ordering protocol; we'd still need smp_rmb somewhere. Secondly, hiding away
memory barriers in a completely unrelated function is nasty; at least in the
PageUptodate macros, they are located together with (half) the operations
involved in the ordering. Thirdly, the smp_wmb is only required when first
bringing the page uptodate, wheras flush_dcache_page should be called each time
it is written to through the kernel mapping. It is logically the wrong place to
put it.
Q. Why does this increase my text size / reduce my performance / etc.
A. Because it is adding the necessary instructions to eliminate the data-race.
Q. Can it be improved?
A. Yes, eg. if you were to create a rule that all SetPageUptodate operations
run under the page lock, we could avoid the smp_rmb places where PageUptodate
is queried under the page lock. Requires audit of all filesystems and at least
some would need reworking. That's great you're interested, I'm eagerly awaiting
your patches.
Signed-off-by: Nick Piggin <npiggin@suse.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2008-02-04 23:29:34 -07:00
|
|
|
page_clear_dirty(page);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2006-09-29 02:58:41 -06:00
|
|
|
static inline void SetPageUptodate(struct page *page)
|
|
|
|
{
|
mm: fix PageUptodate data race
After running SetPageUptodate, preceeding stores to the page contents to
actually bring it uptodate may not be ordered with the store to set the
page uptodate.
Therefore, another CPU which checks PageUptodate is true, then reads the
page contents can get stale data.
Fix this by having an smp_wmb before SetPageUptodate, and smp_rmb after
PageUptodate.
Many places that test PageUptodate, do so with the page locked, and this
would be enough to ensure memory ordering in those places if
SetPageUptodate were only called while the page is locked. Unfortunately
that is not always the case for some filesystems, but it could be an idea
for the future.
Also bring the handling of anonymous page uptodateness in line with that of
file backed page management, by marking anon pages as uptodate when they
_are_ uptodate, rather than when our implementation requires that they be
marked as such. Doing allows us to get rid of the smp_wmb's in the page
copying functions, which were especially added for anonymous pages for an
analogous memory ordering problem. Both file and anonymous pages are
handled with the same barriers.
FAQ:
Q. Why not do this in flush_dcache_page?
A. Firstly, flush_dcache_page handles only one side (the smb side) of the
ordering protocol; we'd still need smp_rmb somewhere. Secondly, hiding away
memory barriers in a completely unrelated function is nasty; at least in the
PageUptodate macros, they are located together with (half) the operations
involved in the ordering. Thirdly, the smp_wmb is only required when first
bringing the page uptodate, wheras flush_dcache_page should be called each time
it is written to through the kernel mapping. It is logically the wrong place to
put it.
Q. Why does this increase my text size / reduce my performance / etc.
A. Because it is adding the necessary instructions to eliminate the data-race.
Q. Can it be improved?
A. Yes, eg. if you were to create a rule that all SetPageUptodate operations
run under the page lock, we could avoid the smp_rmb places where PageUptodate
is queried under the page lock. Requires audit of all filesystems and at least
some would need reworking. That's great you're interested, I'm eagerly awaiting
your patches.
Signed-off-by: Nick Piggin <npiggin@suse.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2008-02-04 23:29:34 -07:00
|
|
|
#ifdef CONFIG_S390
|
2006-09-29 02:58:41 -06:00
|
|
|
if (!test_and_set_bit(PG_uptodate, &page->flags))
|
2007-04-27 08:01:57 -06:00
|
|
|
page_clear_dirty(page);
|
2006-06-30 02:55:32 -06:00
|
|
|
#else
|
mm: fix PageUptodate data race
After running SetPageUptodate, preceeding stores to the page contents to
actually bring it uptodate may not be ordered with the store to set the
page uptodate.
Therefore, another CPU which checks PageUptodate is true, then reads the
page contents can get stale data.
Fix this by having an smp_wmb before SetPageUptodate, and smp_rmb after
PageUptodate.
Many places that test PageUptodate, do so with the page locked, and this
would be enough to ensure memory ordering in those places if
SetPageUptodate were only called while the page is locked. Unfortunately
that is not always the case for some filesystems, but it could be an idea
for the future.
Also bring the handling of anonymous page uptodateness in line with that of
file backed page management, by marking anon pages as uptodate when they
_are_ uptodate, rather than when our implementation requires that they be
marked as such. Doing allows us to get rid of the smp_wmb's in the page
copying functions, which were especially added for anonymous pages for an
analogous memory ordering problem. Both file and anonymous pages are
handled with the same barriers.
FAQ:
Q. Why not do this in flush_dcache_page?
A. Firstly, flush_dcache_page handles only one side (the smb side) of the
ordering protocol; we'd still need smp_rmb somewhere. Secondly, hiding away
memory barriers in a completely unrelated function is nasty; at least in the
PageUptodate macros, they are located together with (half) the operations
involved in the ordering. Thirdly, the smp_wmb is only required when first
bringing the page uptodate, wheras flush_dcache_page should be called each time
it is written to through the kernel mapping. It is logically the wrong place to
put it.
Q. Why does this increase my text size / reduce my performance / etc.
A. Because it is adding the necessary instructions to eliminate the data-race.
Q. Can it be improved?
A. Yes, eg. if you were to create a rule that all SetPageUptodate operations
run under the page lock, we could avoid the smp_rmb places where PageUptodate
is queried under the page lock. Requires audit of all filesystems and at least
some would need reworking. That's great you're interested, I'm eagerly awaiting
your patches.
Signed-off-by: Nick Piggin <npiggin@suse.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2008-02-04 23:29:34 -07:00
|
|
|
/*
|
|
|
|
* Memory barrier must be issued before setting the PG_uptodate bit,
|
|
|
|
* so that all previous stores issued in order to bring the page
|
|
|
|
* uptodate are actually visible before PageUptodate becomes true.
|
|
|
|
*
|
|
|
|
* s390 doesn't need an explicit smp_wmb here because the test and
|
|
|
|
* set bit already provides full barriers.
|
|
|
|
*/
|
|
|
|
smp_wmb();
|
|
|
|
set_bit(PG_uptodate, &(page)->flags);
|
2005-04-16 16:20:36 -06:00
|
|
|
#endif
|
mm: fix PageUptodate data race
After running SetPageUptodate, preceeding stores to the page contents to
actually bring it uptodate may not be ordered with the store to set the
page uptodate.
Therefore, another CPU which checks PageUptodate is true, then reads the
page contents can get stale data.
Fix this by having an smp_wmb before SetPageUptodate, and smp_rmb after
PageUptodate.
Many places that test PageUptodate, do so with the page locked, and this
would be enough to ensure memory ordering in those places if
SetPageUptodate were only called while the page is locked. Unfortunately
that is not always the case for some filesystems, but it could be an idea
for the future.
Also bring the handling of anonymous page uptodateness in line with that of
file backed page management, by marking anon pages as uptodate when they
_are_ uptodate, rather than when our implementation requires that they be
marked as such. Doing allows us to get rid of the smp_wmb's in the page
copying functions, which were especially added for anonymous pages for an
analogous memory ordering problem. Both file and anonymous pages are
handled with the same barriers.
FAQ:
Q. Why not do this in flush_dcache_page?
A. Firstly, flush_dcache_page handles only one side (the smb side) of the
ordering protocol; we'd still need smp_rmb somewhere. Secondly, hiding away
memory barriers in a completely unrelated function is nasty; at least in the
PageUptodate macros, they are located together with (half) the operations
involved in the ordering. Thirdly, the smp_wmb is only required when first
bringing the page uptodate, wheras flush_dcache_page should be called each time
it is written to through the kernel mapping. It is logically the wrong place to
put it.
Q. Why does this increase my text size / reduce my performance / etc.
A. Because it is adding the necessary instructions to eliminate the data-race.
Q. Can it be improved?
A. Yes, eg. if you were to create a rule that all SetPageUptodate operations
run under the page lock, we could avoid the smp_rmb places where PageUptodate
is queried under the page lock. Requires audit of all filesystems and at least
some would need reworking. That's great you're interested, I'm eagerly awaiting
your patches.
Signed-off-by: Nick Piggin <npiggin@suse.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2008-02-04 23:29:34 -07:00
|
|
|
}
|
|
|
|
|
2008-04-28 03:12:50 -06:00
|
|
|
CLEARPAGEFLAG(Uptodate, uptodate)
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2008-04-28 03:12:50 -06:00
|
|
|
extern void cancel_dirty_page(struct page *page, unsigned int account_size);
|
2007-07-19 02:47:55 -06:00
|
|
|
|
2008-04-28 03:12:50 -06:00
|
|
|
int test_clear_page_writeback(struct page *page);
|
|
|
|
int test_set_page_writeback(struct page *page);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2008-04-28 03:12:50 -06:00
|
|
|
static inline void set_page_writeback(struct page *page)
|
|
|
|
{
|
|
|
|
test_set_page_writeback(page);
|
|
|
|
}
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2008-04-28 03:12:50 -06:00
|
|
|
TESTPAGEFLAG(Compound, compound)
|
|
|
|
__PAGEFLAG(Head, compound)
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2007-05-06 15:49:39 -06:00
|
|
|
/*
|
2007-05-06 15:49:40 -06:00
|
|
|
* PG_reclaim is used in combination with PG_compound to mark the
|
2008-04-28 03:12:50 -06:00
|
|
|
* head and tail of a compound page. This saves one page flag
|
|
|
|
* but makes it impossible to use compound pages for the page cache.
|
|
|
|
* The PG_reclaim bit would have to be used for reclaim or readahead
|
|
|
|
* if compound pages enter the page cache.
|
2007-05-06 15:49:40 -06:00
|
|
|
*
|
|
|
|
* PG_compound & PG_reclaim => Tail page
|
|
|
|
* PG_compound & ~PG_reclaim => Head page
|
2007-05-06 15:49:39 -06:00
|
|
|
*/
|
2007-05-06 15:49:40 -06:00
|
|
|
#define PG_head_tail_mask ((1L << PG_compound) | (1L << PG_reclaim))
|
|
|
|
|
2008-04-28 03:12:50 -06:00
|
|
|
static inline int PageTail(struct page *page)
|
|
|
|
{
|
|
|
|
return ((page->flags & PG_head_tail_mask) == PG_head_tail_mask);
|
|
|
|
}
|
2007-05-06 15:49:40 -06:00
|
|
|
|
|
|
|
static inline void __SetPageTail(struct page *page)
|
|
|
|
{
|
|
|
|
page->flags |= PG_head_tail_mask;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void __ClearPageTail(struct page *page)
|
|
|
|
{
|
|
|
|
page->flags &= ~PG_head_tail_mask;
|
|
|
|
}
|
|
|
|
|
2008-04-28 03:12:48 -06:00
|
|
|
#endif /* !__GENERATING_BOUNDS_H */
|
2005-04-16 16:20:36 -06:00
|
|
|
#endif /* PAGE_FLAGS_H */
|