own header file for struct page.
Subsystems (3)
PATCH 1/2 own header file for struct page.
From: Heiko Carstens <[email protected]>
This moves the definition of struct page from mm.h to its own header file page.h.
This is a prereq to fix SetPageUptodate which is broken on s390:
#define SetPageUptodate(_page)
do {
struct page *__page = (_page);
if (!test_and_set_bit(PG_uptodate, &__page->flags))
page_test_and_clear_dirty(_page);
} while (0)_page gets used twice in this macro which can cause subtle bugs. Using __page for the page_test_and_clear_dirty call doesn't work since it causes yet another problem with the page_test_and_clear_dirty macro as well.
In order to get of all these problems caused by macros it seems to be a good idea to get rid of them and convert them to static inline functions. Because of header file include order it's necessary to have a seperate header file for the struct page definition.
---
Patches are against git tree as of today. Better ideas welcome of course.
include/linux/mm.h | 64 -------------------------------------------- include/linux/page.h | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+), 63 deletions(-)
include/linux/mm.h +1 -63
@@ -15,6 +15,7 @@#include <linux/fs.h> #include <linux/mutex.h> #include <linux/debug_locks.h> +#include <linux/page.h> struct mempolicy ;struct anon_vma ;
@@ -215,64 +216,6 @@struct inode ;/* -* Each physical page in the system has a struct page associated with -* it to keep track of whatever it is we are using the page for at the -* moment. Note that we have no way to track which tasks are using -* a page. -*/ -struct page { -unsigned long flags;/* Atomic flags, some possibly -* updated asynchronously */ -atomic_t _count;/* Usage count, see below. */ -atomic_t _mapcount;/* Count of ptes mapped in mms, -* to show when page is mapped -* & limit reverse map searches. -*/ -union { -struct { -unsigned long private;/* Mapping-private opaque data: -* usually used for buffer_heads -* if PagePrivate set; used for -* swp_entry_t if PageSwapCache; -* indicates order in the buddy -* system if PG_buddy is set. -*/ -struct address_space *mapping;/* If low bit clear, points to -* inode address_space, or NULL. -* If page mapped as anonymous -* memory, low bit is set, and -* it points to anon_vma object: -* see PAGE_MAPPING_ANON below. -*/ - }; -#if NR_CPUS >=CONFIG_SPLIT_PTLOCK_CPUS -spinlock_t ptl; -#endif - }; -pgoff_t index;/* Our offset within mapping. */ -struct list_head lru;/* Pageout list, eg. active_list -* protected by zone->lru_lock ! -*/ -/* -* On machines where all RAM is mapped into kernel address space, -* we can simply calculate the virtual address. On machines with -* highmem some memory is mapped into kernel virtual memory -* dynamically, so we need a place to store that address. -* Note that this field could be 16 bits on x86 ... ;) -* -* Architectures with slow multiplication can define -* WANT_PAGE_VIRTUAL in asm/page.h -*/ -#if defined(WANT_PAGE_VIRTUAL ) -void *virtual;/* Kernel virtual address (NULL if -not kmapped, ie. highmem) */ -#endif /* WANT_PAGE_VIRTUAL */ -}; - -#define page_private (page) ((page)->private) -#define set_page_private (page, v) ((page)->private = (v)) - -/* * FIXME: take this include out, include page-flags.h in * files which need it (119 of them) */
@@ -521,11 +464,6 @@*/ #include <linux/vmstat.h> -#ifndef CONFIG_DISCONTIGMEM -/* The array of struct pages - for discontigmem use pgdat->lmem_map */ -extern struct page *mem_map; -#endif - static __always_inline void *lowmem_page_address(struct page *page) {return __va (page_to_pfn (page) <<PAGE_SHIFT );
include/linux/page.h new file +74 -0
74 lines not on this page · raw message
Quoted 13 lines · On Fri, 8 Sep 2006 13:17:16 +0200 Heiko Carstens <[email protected]>…
From: Heiko Carstens <[email protected]>
This moves the definition of struct page from
mm.hto its own header filepage.h.
This is a prereq to fix SetPageUptodate which is broken on s390:#define SetPageUptodate(_page) do { struct page *__page = (_page); if (!test_and_set_bit(PG_uptodate, &__page->flags)) page_test_and_clear_dirty(_page); } while (0)
Quoted 9 lines
_pagegets used twice in this macro which can cause subtle bugs. Using__pagefor thepage_test_and_clear_dirtycall doesn't work since it causes yet another problem with thepage_test_and_clear_dirtymacro as well.
In order to get of all these problems caused by macros it seems to be a good idea to get rid of them and convert them to static inline functions. Because of header file include order it's necessary to have a seperate header file for the struct page definition.
hmm.
include/linux/page.h
Quoted 2 lines
include/linux/page.h new file +0
-0
We have asm/page.h, and one would expect that a <linux/page.h> would be related to <asm/page.h> in the usual fashion. But it isn't.
Can we think of a different filename? page-struct.h, maybe? pageframe.h?
include/linux/page.h line 72
Quoted 4 lines
include/linux/page.h new file +4
-0+#ifndef CONFIG_DISCONTIGMEM +/* The array of struct pages - for discontigmem use pgdat->lmem_map */ +extern struct page *mem_map; +#endif
Am surprised to see this declaration in this file.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 23 lines
Quoted 11 lines
This moves the definition of struct page from
mm.hto its own header filepage.h.
This is a prereq to fix SetPageUptodate which is broken on s390:#define SetPageUptodate(_page) do { struct page *__page = (_page); if (!test_and_set_bit(PG_uptodate, &__page->flags)) page_test_and_clear_dirty(_page); } while (0)Quoted 9 lines
_pagegets used twice in this macro which can cause subtle bugs. Using__pagefor thepage_test_and_clear_dirtycall doesn't work since it causes yet another problem with thepage_test_and_clear_dirtymacro as well.
In order to get of all these problems caused by macros it seems to be a good idea to get rid of them and convert them to static inline functions. Because of header file include order it's necessary to have a seperate header file for the struct page definition.hmm.
Quoted 7 lines
include/linux/page.h
Quoted 2 lines
include/linux/page.h new file +0
-0We have
asm/page.h, and one would expect that a <linux/page.h> would be related to <asm/page.h> in the usual fashion. But it isn't.Can we think of a different filename?
page-struct.h, maybe?pageframe.h?
Yes, of course.
Quoted 6 lines
include/linux/page.h line 72
Quoted 4 lines
include/linux/page.h new file +4
-0+#ifndef CONFIG_DISCONTIGMEM +/* The array of struct pages - for discontigmem use pgdat->lmem_map */ +extern struct page *mem_map; +#endif Am surprised to see this declaration in this file.
Hmm... first I thought I could add the same declaration to asm-s390/pgtable.h. But then deciced against it, since I would just duplicate code. Any better idea where to put it?
Quoted 10 lines · On Fri, 8 Sep 2006 20:33:40 +0200 Heiko Carstens <[email protected]>…
Quoted 6 lines
include/linux/page.h line 72
Quoted 4 lines
include/linux/page.h new file +4
-0+#ifndef CONFIG_DISCONTIGMEM +/* The array of struct pages - for discontigmem use pgdat->lmem_map */ +extern struct page *mem_map; +#endif Am surprised to see this declaration in this file.
Hmm... first I thought I could add the same declaration to
asm-s390/pgtable.h. But then deciced against it, since I would just duplicate code. Any better idea where to put it?
dunno. mmzone.h?
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 1/2 own header file for struct page v2.
From: Heiko Carstens <[email protected]>
This moves the definition of struct page from mm.h to its own header file page-struct.h.
This is a prereq to fix SetPageUptodate which is broken on s390:
#define SetPageUptodate(_page)
do {
struct page *__page = (_page);
if (!test_and_set_bit(PG_uptodate, &__page->flags))
page_test_and_clear_dirty(_page);
} while (0)_page gets used twice in this macro which can cause subtle bugs. Using __page for the page_test_and_clear_dirty call doesn't work since it causes yet another problem with the page_test_and_clear_dirty macro as well.
In order to avoid all these problems caused by macros it seems to be a good idea to get rid of them and convert them to static inline functions. Because of header file include order it's necessary to have a seperate header file for the struct page definition.
---
Updated patch: - against -mm
- changed name to page-struct.h instead of page.h
- moved mem_map declaration to mmzone.h
include/linux/mm.h | 70 ----------------------------------------- include/linux/mmzone.h | 5 ++ include/linux/page-struct.h | 75 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 81 insertions(+), 69 deletions(-)
include/linux/mm.h +1 -69
@@ -16,6 +16,7 @@#include <linux/mutex.h> #include <linux/debug_locks.h> #include <linux/backing-dev.h> +#include <linux/page-struct.h> struct mempolicy ;struct anon_vma ;
@@ -216,70 +217,6 @@struct inode ;/* -* Each physical page in the system has a struct page associated with -* it to keep track of whatever it is we are using the page for at the -* moment. Note that we have no way to track which tasks are using -* a page, though if it is a pagecache page, rmap structures can tell us -* who is mapping it. -*/ -struct page { -unsigned long flags;/* Atomic flags, some possibly -* updated asynchronously */ -atomic_t _count;/* Usage count, see below. */ -atomic_t _mapcount;/* Count of ptes mapped in mms, -* to show when page is mapped -* & limit reverse map searches. -*/ -union { -struct { -unsigned long private;/* Mapping-private opaque data: -* usually used for buffer_heads -* if PagePrivate set; used for -* swp_entry_t if PageSwapCache; -* indicates order in the buddy -* system if PG_buddy is set. -*/ -struct address_space *mapping;/* If low bit clear, points to -* inode address_space, or NULL. -* If page mapped as anonymous -* memory, low bit is set, and -* it points to anon_vma object: -* see PAGE_MAPPING_ANON below. -*/ - }; -#if NR_CPUS >=CONFIG_SPLIT_PTLOCK_CPUS -spinlock_t ptl; -#endif - }; -pgoff_t index;/* Our offset within mapping. */ -struct list_head lru;/* Pageout list, eg. active_list -* protected by zone->lru_lock ! -*/ -/* -* On machines where all RAM is mapped into kernel address space, -* we can simply calculate the virtual address. On machines with -* highmem some memory is mapped into kernel virtual memory -* dynamically, so we need a place to store that address. -* Note that this field could be 16 bits on x86 ... ;) -* -* Architectures with slow multiplication can define -* WANT_PAGE_VIRTUAL in asm/page.h -*/ -#if defined(WANT_PAGE_VIRTUAL ) -void *virtual;/* Kernel virtual address (NULL if -not kmapped, ie. highmem) */ -#endif /* WANT_PAGE_VIRTUAL */ -#ifdef CONFIG_PAGE_OWNER -int order; -unsigned int gfp_mask; -unsigned long trace[8 ]; -#endif -}; - -#define page_private (page) ((page)->private) -#define set_page_private (page, v) ((page)->private = (v)) - -/* * FIXME: take this include out, include page-flags.h in * files which need it (119 of them) */
@@ -551,11 +488,6 @@*/ #include <linux/vmstat.h> -#ifndef CONFIG_DISCONTIGMEM -/* The array of struct pages - for discontigmem use pgdat->lmem_map */ -extern struct page *mem_map; -#endif - static __always_inline void *lowmem_page_address(struct page *page) {return __va (page_to_pfn (page) <<PAGE_SHIFT );
include/linux/page-struct.h new file +75 -0
75 lines not on this page · raw message
include/linux/mmzone.h +5 -0
@@ -318,6 +318,11 @@ };#endif /* CONFIG_ARCH_POPULATES_NODE_MAP */ +#ifndef CONFIG_DISCONTIGMEM +/* The array of struct pages - for discontigmem use pgdat->lmem_map */ +extern struct page *mem_map; +#endif +/* * The pg_data_t structure is used in machines with CONFIG_DISCONTIGMEM * (mostly NUMA machines?) to denote a higher-level memory zone than the
PATCH 2/2 convert s390 page handling macros to functions v2
In reply to Andrew MortonFrom: Heiko Carstens <[email protected]>
Convert s390 page handling macros to functions. In particular this fixes a problem with s390's SetPageUptodate macro which uses its input parameter twice which again can cause subtle bugs.
---
include/asm-s390/pgtable.h | 85 +++++++++++++++++++++------------------------ include/linux/page-flags.h | 11 ++--- 2 files changed, 46 insertions(+), 50 deletions(-)
include/linux/page-flags.h +5 -6
@@ -130,12 +130,11 @@#define PageUptodate (page) test_bit(PG_uptodate, &(page)->flags)#ifdef CONFIG_S390 -#define SetPageUptodate (_page) \ - do { \ - struct page *__page = (_page); \ - if (!test_and_set_bit(PG_uptodate, &__page->flags)) \ - page_test_and_clear_dirty(_page); \ - } while (0) +static inline void SetPageUptodate (struct page *page) +{ +if (!test_and_set_bit (PG_uptodate, &page->flags)) +page_test_and_clear_dirty (page); +}#else #define SetPageUptodate (page) set_bit(PG_uptodate, &(page)->flags)#endif
include/asm-s390/pgtable.h +41 -44
110 lines not on this page · raw message
Hi,
Quoted 7 lines · Heiko Carstens
In order to get of all these problems caused by macros it seems to be a good idea to get rid of them and convert them to static inline functions. Because of header file include order it's necessary to have a seperate header file for the struct page definition.
Cc Martin Schwidefsky <[email protected]>Signed-off-by Heiko Carstens <[email protected]>
Quoted 7 lines
---
Patches are against git tree as of today. Better ideas welcome of course.
include/linux/mm.h | 64 -------------------------------------------- include/linux/page.h | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+), 63 deletions(-)
To avoid the explosion in number of small header files each containing a single definition, it would be better to generally split between the definitions and implementations, so IMO mm_types.h with all the structures and defines from mm.h would be better.
bye, Roman
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 11 lines
Quoted 11 lines
In order to get of all these problems caused by macros it seems to be a good idea to get rid of them and convert them to static inline functions. Because of header file include order it's necessary to have a seperate header file for the struct page definition.
Cc Martin Schwidefsky <[email protected]>Signed-off-by Heiko Carstens <[email protected]>---
Patches are against git tree as of today. Better ideas welcome of course.
Quoted 8 lines
Quoted 3 lines
include/linux/mm.h | 64 -------------------------------------------- include/linux/page.h | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+), 63 deletions(-)To avoid the explosion in number of small header files each containing a single definition, it would be better to generally split between the definitions and implementations, so IMO
mm_types.hwith all the structures and defines frommm.hwould be better.
That could be done, but I wouldn't know where to start and where to end. Moving simply all definitions to mm_types.h doesn't seem to be a good solution. E.g. having something like "struct shrinker" in mm_types.h seems to be rather pointless IMHO.
Maybe we can simply leave it by just taking the struct page definition out for now?
PATCH 1/2 own header file for struct page v3
In reply to Roman ZippelFrom: Heiko Carstens <[email protected]>
This moves the definition of struct page from mm.h into a new header file mm_types.h.
This is a prereq to fix SetPageUptodate which is broken on s390:
#define SetPageUptodate(_page)
do {
struct page *__page = (_page);
if (!test_and_set_bit(PG_uptodate, &__page->flags))
page_test_and_clear_dirty(_page);
} while (0)_page gets used twice in this macro which can cause subtle bugs. Using __page for the page_test_and_clear_dirty call doesn't work since it causes yet another problem with the page_test_and_clear_dirty macro as well.
In order to avoid all these problems caused by macros it seems to be a good idea to get rid of them and convert them to static inline functions. Because of header file include order it's necessary to have a seperate header file for the struct page definition.
---
Updated patch: v2:
- against -mm
- changed name to page-struct.h instead of page.h
- moved mem_map declaration to mmzone.h
v3:
- mm_types.h instead of page-struct.h. To be used if someone wants to move more definitions from mm.h to a seperate header file.
include/linux/mm.h | 67 ------------------------------------------- include/linux/mm_types.h | 72 +++++++++++++++++++++++++++++++++++++++++++++++ include/linux/mmzone.h | 5 +++ 3 files changed, 78 insertions(+), 66 deletions(-)
include/linux/mm.h +1 -66
@@ -16,6 +16,7 @@#include <linux/mutex.h> #include <linux/debug_locks.h> #include <linux/backing-dev.h> +#include <linux/mm_types.h> struct mempolicy ;struct anon_vma ;
@@ -215,67 +216,6 @@struct mmu_gather ;struct inode ; -/* -* Each physical page in the system has a struct page associated with -* it to keep track of whatever it is we are using the page for at the -* moment. Note that we have no way to track which tasks are using -* a page, though if it is a pagecache page, rmap structures can tell us -* who is mapping it. -*/ -struct page { -unsigned long flags;/* Atomic flags, some possibly -* updated asynchronously */ -atomic_t _count;/* Usage count, see below. */ -atomic_t _mapcount;/* Count of ptes mapped in mms, -* to show when page is mapped -* & limit reverse map searches. -*/ -union { -struct { -unsigned long private;/* Mapping-private opaque data: -* usually used for buffer_heads -* if PagePrivate set; used for -* swp_entry_t if PageSwapCache; -* indicates order in the buddy -* system if PG_buddy is set. -*/ -struct address_space *mapping;/* If low bit clear, points to -* inode address_space, or NULL. -* If page mapped as anonymous -* memory, low bit is set, and -* it points to anon_vma object: -* see PAGE_MAPPING_ANON below. -*/ - }; -#if NR_CPUS >=CONFIG_SPLIT_PTLOCK_CPUS -spinlock_t ptl; -#endif - }; -pgoff_t index;/* Our offset within mapping. */ -struct list_head lru;/* Pageout list, eg. active_list -* protected by zone->lru_lock ! -*/ -/* -* On machines where all RAM is mapped into kernel address space, -* we can simply calculate the virtual address. On machines with -* highmem some memory is mapped into kernel virtual memory -* dynamically, so we need a place to store that address. -* Note that this field could be 16 bits on x86 ... ;) -* -* Architectures with slow multiplication can define -* WANT_PAGE_VIRTUAL in asm/page.h -*/ -#if defined(WANT_PAGE_VIRTUAL ) -void *virtual;/* Kernel virtual address (NULL if -not kmapped, ie. highmem) */ -#endif /* WANT_PAGE_VIRTUAL */ -#ifdef CONFIG_PAGE_OWNER -int order; -unsigned int gfp_mask; -unsigned long trace[8 ]; -#endif -}; -#define page_private (page) ((page)->private)#define set_page_private (page, v) ((page)->private = (v))
@@ -551,11 +491,6 @@*/ #include <linux/vmstat.h> -#ifndef CONFIG_DISCONTIGMEM -/* The array of struct pages - for discontigmem use pgdat->lmem_map */ -extern struct page *mem_map; -#endif - static __always_inline void *lowmem_page_address(struct page *page) {return __va (page_to_pfn (page) <<PAGE_SHIFT );
include/linux/mmzone.h +5 -0
@@ -318,6 +318,11 @@ };#endif /* CONFIG_ARCH_POPULATES_NODE_MAP */ +#ifndef CONFIG_DISCONTIGMEM +/* The array of struct pages - for discontigmem use pgdat->lmem_map */ +extern struct page *mem_map; +#endif +/* * The pg_data_t structure is used in machines with CONFIG_DISCONTIGMEM * (mostly NUMA machines?) to denote a higher-level memory zone than the
include/linux/mm_types.h new file +72 -0
72 lines not on this page · raw message
PATCH 2/2 convert s390 page handling macros to functions v3
In reply to Roman ZippelFrom: Heiko Carstens <[email protected]>
Convert s390 page handling macros to functions. In particular this fixes a problem with s390's SetPageUptodate macro which uses its input parameter twice which again can cause subtle bugs.
---
include/asm-s390/pgtable.h | 85 +++++++++++++++++++++------------------------ include/linux/page-flags.h | 11 ++--- 2 files changed, 46 insertions(+), 50 deletions(-)
include/linux/page-flags.h +5 -6
@@ -130,12 +130,11 @@#define PageUptodate (page) test_bit(PG_uptodate, &(page)->flags)#ifdef CONFIG_S390 -#define SetPageUptodate (_page) \ - do { \ - struct page *__page = (_page); \ - if (!test_and_set_bit(PG_uptodate, &__page->flags)) \ - page_test_and_clear_dirty(_page); \ - } while (0) +static inline void SetPageUptodate (struct page *page) +{ +if (!test_and_set_bit (PG_uptodate, &page->flags)) +page_test_and_clear_dirty (page); +}#else #define SetPageUptodate (page) set_bit(PG_uptodate, &(page)->flags)#endif
include/asm-s390/pgtable.h +41 -44
112 lines not on this page · raw message
Re: [patch 2/2] convert s390 page handling macros to functions v3
include/asm-s390/pgtable.h line 610
Quoted 5 lines · Heiko Carstens
include/asm-s390/pgtable.h +4
-0+static inline int page_test_and_clear_dirty (struct page *page) +{ +unsigned long physpage =__pa ((page - mem_map) <<PAGE_SHIFT ); +int skey =page_get_storage_key (physpage);
This has nothing to do with your patch at all, but why is 'page - mem_map' being open-coded here?
I see at least a couple of page_to_phys() definitions on some architectures. This operation is done enough times that s390 could probably use the same treatment.
It could at least use a page_to_pfn() instead of the 'page - mem_map' operation, right?
-- Dave
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [patch 2/2] convert s390 page handling macros to functions v3
Quoted 9 lines · Dave Hansen
include/asm-s390/pgtable.h line 610
Quoted 5 lines · Heiko Carstens
include/asm-s390/pgtable.h +4
-0+static inline int page_test_and_clear_dirty (struct page *page) +{ +unsigned long physpage =__pa ((page - mem_map) <<PAGE_SHIFT ); +int skey =page_get_storage_key (physpage);This has nothing to do with your patch at all, but why is 'page -
mem_map' being open-coded here?
I just changed the defines to functions without thinking about this.. :)
Quoted 3 lines
I see at least a couple of
page_to_phys()definitions on some architectures. This operation is done enough times that s390 could probably use the same treatment.
Yes, even s390 has page_to_phys() as well. But why is it in io.h? Seems like this is inconsistent across architectures. Also in quite a few architectures the define looks like this:
#define page_to_phys(page) ((page - mem_map) << PAGE_SHIFT)
A pair of braces is missing around page. Yet another possible subtle bug...
Quoted 2 lines
It could at least use a
page_to_pfn()instead of the 'page -mem_map' operation, right?
Yes, I will address that in a later patch. Shouldn't stop this one from being merged, if there aren't any other objections.
Thanks for pointing this out!