summaryrefslogtreecommitdiff
path: root/include/linux
diff options
context:
space:
mode:
authorAndrew Morton <akpm@zip.com.au>2002-04-29 23:52:37 -0700
committerLinus Torvalds <torvalds@home.transmeta.com>2002-04-29 23:52:37 -0700
commitaa78091f0f2860df00a4ccc5d4609afd9d831dd0 (patch)
treefe91202ae1fed74c403bf6f7cc9caf5a3f2ca5da /include/linux
parent68872e78c90ddfe683bf1c10ee93323f6d640251 (diff)
[PATCH] cleanup page flags
page->flags cleanup. Moves the definitions of the page->flags bits and all the PageFoo macros into linux/page-flags.h. That file is currently included from mm.h, but the stage is set to remove that and include page-flags.h direct in all .c files which require that. (120 of them). The patch also makes all the page flag macros and functions consistent: For PG_foo, the following functions are defined: SetPageFoo ClearPageFoo TestSetPageFoo TestClearPageFoo PageFoo and that's it. - Page_Uptodate is renamed to PageUptodate - LockPage is removed. All users updated to use SetPageLocked - UnlockPage is removed. All callers updated to use unlock_page(). it's a real function - there's no need to hide that fact. - PageTestandClearReferenced renamed to TestClearPageReferenced - PageSetSlab renamed to SetPageSlab - __SetPageReserved is removed. It's an infinitesimally small microoptimisation, and is inconsistent. - TryLockPage is renamed to TestSetPageLocked - PageSwapCache() is renamed to page_swap_cache(), so it doesn't pretend to be a page->flags bit test.
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/mm.h70
-rw-r--r--include/linux/page-flags.h84
2 files changed, 76 insertions, 78 deletions
diff --git a/include/linux/mm.h b/include/linux/mm.h
index b548d2cd8504..e8451aeaa93a 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -191,11 +191,6 @@ typedef struct page {
#define set_page_count(p,v) atomic_set(&(p)->count, v)
/*
- * 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)...
- *
* Multiple processes may "see" the same page. E.g. for untouched
* mappings of /dev/null, all processes see the same page full of
* zeroes, and text pages of executables and shared libraries have
@@ -224,8 +219,6 @@ typedef struct page {
* page's address_space. Usually, this is the address of a circular
* list of the page's disk buffers.
*
- * The PG_private bitflag is set if page->private contains a valid
- * value.
* For pages belonging to inodes, the page->count is the number of
* attaches, plus 1 if `private' contains something, plus one for
* the page cache itself.
@@ -244,64 +237,9 @@ typedef struct page {
* to be written to disk,
* - private pages which have been modified may need to be swapped out
* to swap space and (later) to be read back into memory.
- * During disk I/O, PG_locked_dontuse is used. This bit is set before I/O
- * and reset when I/O completes. page_waitqueue(page) is a wait queue of all
- * tasks waiting for the I/O on this page to complete.
- * 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.
- *
- * For choosing which pages to swap out, inode pages carry a
- * PG_referenced bit, which is set any time the system accesses
- * that page through the (mapping,index) hash table. This referenced
- * bit, together with the referenced bit in the page tables, is used
- * to manipulate page->age and move the page across the active,
- * inactive_dirty and inactive_clean lists.
- *
- * Note that the referenced bit, the page->lru list_head and the
- * active, inactive_dirty and inactive_clean lists are protected by
- * the pagemap_lru_lock, and *NOT* by the usual PG_locked_dontuse bit!
- *
- * PG_skip is used on sparc/sparc64 architectures to "skip" certain
- * parts of the address space.
- *
- * 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...
*/
/*
- * Don't use the *_dontuse flags. Use the macros. Otherwise
- * you'll break locked- and dirty-page accounting.
- */
-#define PG_locked_dontuse 0 /* Page is locked. Don't touch. */
-#define PG_error 1
-#define PG_referenced 2
-#define PG_uptodate 3
-
-#define PG_dirty_dontuse 4
-#define PG_unused 5 /* err. This is unused. */
-#define PG_lru 6
-#define PG_active 7
-
-#define PG_slab 8 /* slab debug (Suparna wants this) */
-#define PG_skip 10 /* kill me now: obsolete */
-#define PG_highmem 11
-#define PG_checked 12 /* kill me in 2.5.<early>. */
-
-#define PG_arch_1 13
-#define PG_reserved 14
-#define PG_launder 15 /* written out by VM pressure.. */
-#define PG_private 16 /* Has something at ->private */
-
-/*
* FIXME: take this include out, include page-flags.h in
* files which need it (119 of them)
*/
@@ -444,14 +382,6 @@ extern void show_mem(void);
extern void si_meminfo(struct sysinfo * val);
extern void swapin_readahead(swp_entry_t);
-extern struct address_space swapper_space;
-#define PageSwapCache(page) ((page)->mapping == &swapper_space)
-
-static inline int is_page_cache_freeable(struct page * page)
-{
- return page_count(page) - !!PagePrivate(page) == 1;
-}
-
extern int can_share_swap_page(struct page *);
extern int remove_exclusive_swap_page(struct page *);
diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
index 9ae7a8009ead..aeba6b4f74ac 100644
--- a/include/linux/page-flags.h
+++ b/include/linux/page-flags.h
@@ -6,6 +6,70 @@
#define PAGE_FLAGS_H
/*
+ * 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)...
+ *
+ * The PG_private bitflag is set if page->private contains a valid value.
+ *
+ * During disk I/O, PG_locked_dontuse is used. This bit is set before I/O and
+ * reset when I/O completes. page_waitqueue(page) is a wait queue of all tasks
+ * waiting for the I/O on this page to complete.
+ *
+ * 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.
+ *
+ * For choosing which pages to swap out, inode pages carry a PG_referenced bit,
+ * which is set any time the system accesses that page through the (mapping,
+ * index) hash table. This referenced bit, together with the referenced bit
+ * in the page tables, is used to manipulate page->age and move the page across
+ * the active, inactive_dirty and inactive_clean lists.
+ *
+ * Note that the referenced bit, the page->lru list_head and the active,
+ * inactive_dirty and inactive_clean lists are protected by the
+ * pagemap_lru_lock, and *NOT* by the usual PG_locked_dontuse bit!
+ *
+ * PG_skip is used on sparc/sparc64 architectures to "skip" certain parts of
+ * the address space.
+ *
+ * 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...
+ */
+
+/*
+ * Don't use the *_dontuse flags. Use the macros. Otherwise you'll break
+ * locked- and dirty-page accounting. The top eight bits of page->flags are
+ * used for page->zone, so putting flag bits there doesn't work.
+ */
+#define PG_locked_dontuse 0 /* Page is locked. Don't touch. */
+#define PG_error 1
+#define PG_referenced 2
+#define PG_uptodate 3
+
+#define PG_dirty_dontuse 4
+#define PG_lru 5
+#define PG_active 6
+#define PG_slab 7 /* slab debug (Suparna wants this) */
+
+#define PG_skip 8 /* kill me now: obsolete */
+#define PG_highmem 9
+#define PG_checked 10 /* kill me in 2.5.<early>. */
+#define PG_arch_1 11
+
+#define PG_reserved 12
+#define PG_launder 13 /* written out by VM pressure.. */
+#define PG_private 14 /* Has something at ->private */
+
+/*
* Global page accounting. One instance per CPU.
*/
extern struct page_state {
@@ -30,7 +94,6 @@ extern void get_page_state(struct page_state *ret);
/*
* Manipulation of page state flags
*/
-#define UnlockPage(page) unlock_page(page)
#define PageLocked(page) test_bit(PG_locked_dontuse, &(page)->flags)
#define SetPageLocked(page) \
do { \
@@ -38,8 +101,7 @@ extern void get_page_state(struct page_state *ret);
&(page)->flags)) \
inc_page_state(nr_locked); \
} while (0)
-#define LockPage(page) SetPageLocked(page) /* grr. kill me */
-#define TryLockPage(page) \
+#define TestSetPageLocked(page) \
({ \
int ret; \
ret = test_and_set_bit(PG_locked_dontuse, \
@@ -71,9 +133,9 @@ extern void get_page_state(struct page_state *ret);
#define PageReferenced(page) test_bit(PG_referenced, &(page)->flags)
#define SetPageReferenced(page) set_bit(PG_referenced, &(page)->flags)
#define ClearPageReferenced(page) clear_bit(PG_referenced, &(page)->flags)
-#define PageTestandClearReferenced(page) test_and_clear_bit(PG_referenced, &(page)->flags)
+#define TestClearPageReferenced(page) test_and_clear_bit(PG_referenced, &(page)->flags)
-#define Page_Uptodate(page) test_bit(PG_uptodate, &(page)->flags)
+#define PageUptodate(page) test_bit(PG_uptodate, &(page)->flags)
#define SetPageUptodate(page) set_bit(PG_uptodate, &(page)->flags)
#define ClearPageUptodate(page) clear_bit(PG_uptodate, &(page)->flags)
@@ -118,8 +180,8 @@ extern void get_page_state(struct page_state *ret);
#define ClearPageActive(page) clear_bit(PG_active, &(page)->flags)
#define PageSlab(page) test_bit(PG_slab, &(page)->flags)
-#define PageSetSlab(page) set_bit(PG_slab, &(page)->flags)
-#define PageClearSlab(page) clear_bit(PG_slab, &(page)->flags)
+#define SetPageSlab(page) set_bit(PG_slab, &(page)->flags)
+#define ClearPageSlab(page) clear_bit(PG_slab, &(page)->flags)
#ifdef CONFIG_HIGHMEM
#define PageHighMem(page) test_bit(PG_highmem, &(page)->flags)
@@ -133,7 +195,6 @@ extern void get_page_state(struct page_state *ret);
#define PageReserved(page) test_bit(PG_reserved, &(page)->flags)
#define SetPageReserved(page) set_bit(PG_reserved, &(page)->flags)
#define ClearPageReserved(page) clear_bit(PG_reserved, &(page)->flags)
-#define __SetPageReserved(page) __set_bit(PG_reserved, &(page)->flags)
#define PageLaunder(page) test_bit(PG_launder, &(page)->flags)
#define SetPageLaunder(page) set_bit(PG_launder, &(page)->flags)
@@ -142,4 +203,11 @@ extern void get_page_state(struct page_state *ret);
#define ClearPagePrivate(page) clear_bit(PG_private, &(page)->flags)
#define PagePrivate(page) test_bit(PG_private, &(page)->flags)
+/*
+ * The PageSwapCache predicate doesn't use a PG_flag at this time,
+ * but it may again do so one day.
+ */
+extern struct address_space swapper_space;
+#define PageSwapCache(page) ((page)->mapping == &swapper_space)
+
#endif /* PAGE_FLAGS_H */