Re: [PATCH -mm 05/25] define page_file_cache() function

Previous thread: [PATCH -mm 08/25] add some sanity checks to get_scan_ratio by Rik van Riel on Friday, June 6, 2008 - 1:28 pm. (3 messages)

Next thread: [PATCH -mm 00/25] VM pageout scalability improvements (V10) by Rik van Riel on Friday, June 6, 2008 - 1:28 pm. (9 messages)
From: Rik van Riel
Date: Friday, June 6, 2008 - 1:28 pm

From: Rik van Riel <riel@redhat.com>

Define page_file_cache() function to answer the question:
	is page backed by a file?

Originally part of Rik van Riel's split-lru patch.  Extracted
to make available for other, independent reclaim patches.

Moved inline function to linux/mm_inline.h where it will
be needed by subsequent "split LRU" and "noreclaim" patches.  

Unfortunately this needs to use a page flag, since the
PG_swapbacked state needs to be preserved all the way
to the point where the page is last removed from the
LRU.  Trying to derive the status from other info in
the page resulted in wrong VM statistics in earlier
split VM patchsets.

Signed-off-by: Rik van Riel <riel@redhat.com>
Signed-off-by: Lee Schermerhorn <lee.schermerhorn@hp.com>
Signed-off-by: MinChan Kim <minchan.kim@gmail.com>

---
 include/linux/mm_inline.h  |   24 ++++++++++++++++++++++++
 include/linux/page-flags.h |    2 ++
 mm/memory.c                |    3 +++
 mm/migrate.c               |    2 ++
 mm/page_alloc.c            |    4 ++++
 mm/shmem.c                 |    1 +
 mm/swap_state.c            |    3 +++
 7 files changed, 39 insertions(+)

Index: linux-2.6.26-rc2-mm1/include/linux/mm_inline.h
===================================================================
--- linux-2.6.26-rc2-mm1.orig/include/linux/mm_inline.h	2008-05-23 14:21:33.000000000 -0400
+++ linux-2.6.26-rc2-mm1/include/linux/mm_inline.h	2008-05-23 14:21:34.000000000 -0400
@@ -1,3 +1,26 @@
+#ifndef LINUX_MM_INLINE_H
+#define LINUX_MM_INLINE_H
+
+/**
+ * page_file_cache - should the page be on a file LRU or anon LRU?
+ * @page: the page to test
+ *
+ * Returns !0 if @page is page cache page backed by a regular filesystem,
+ * or 0 if @page is anonymous, tmpfs or otherwise ram or swap backed.
+ *
+ * We would like to get this info without a page flag, but the state
+ * needs to survive until the page is last deleted from the LRU, which
+ * could be as far down as __page_cache_release.
+ */
+static inline int ...
From: Andrew Morton
Date: Friday, June 6, 2008 - 6:04 pm

On Fri, 06 Jun 2008 16:28:43 -0400


2?

Maybe bool would suit here.

Maybe a better name would be page_is_file_cache().  The gnu (gcc?)
convention of putting _p at the end of predicate functions' names makes
heaps of sense.


This function doesn't do enough stuff to do that which it says it does.
There must be a whole pile of preconditions which the caller must
evaluate before this function can be usefully used.  I mean, it would
be a bug to pass an anonymous page or a slab page or whatever into

Those __ClearPageFoo() functions scare my pants into the next suburb. 
They can cause such horridly subtle bugs if misused.  Every single
callsite should have special attention and careful justification in

OK, someone lost their tab key and it wasn't you.

<does git-blame>



--

From: Rik van Riel
Date: Saturday, June 7, 2008 - 4:38 pm

On Fri, 6 Jun 2008 18:04:34 -0700

After this patch, 19 are in use.  I believe the way we
keep track of zones means we have 24 total on i386, but
the exact value depends on CONFIG_NODES_SHIFT, which
determines the maximum number of NUMA nodes supported.

The code in include/linux/mm.h makes sure the user
cannot compile the kernel with too high a NODES_SHIFT
value.


It will be replaced with LRU_FILE in a later patch.  I'll change it


Passing in a slab page would indeed not give a useful result.  This
function is meant to help functions that manipulate the LRU lists
(which already know the page is or should be an LRU page) sort the
page onto the right list.

I have amended the comment to reflect this.

-- 
All rights reversed.
--

Previous thread: [PATCH -mm 08/25] add some sanity checks to get_scan_ratio by Rik van Riel on Friday, June 6, 2008 - 1:28 pm. (3 messages)

Next thread: [PATCH -mm 00/25] VM pageout scalability improvements (V10) by Rik van Riel on Friday, June 6, 2008 - 1:28 pm. (9 messages)