From: Heiko Carstens <heiko.carstens@de.ibm.com>
From: Heiko Carstens <heiko.carstens@de.ibm.com>
To: Andrew Morton <akpm@osdl.org>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Martin Schwidefsky <schwidefsky@de.ibm.com>
Subject: [patch 2/2] convert s390 page handling macros to functions v2
Date: Fri, 8 Sep 2006 21:48:07 +0200 [thread overview]
Message-ID: <20060908194807.GB10139@osiris.ibm.com> (raw)
In-Reply-To: <20060908120616.db18c4a0.akpm@osdl.org>
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.
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
---
include/asm-s390/pgtable.h | 85 +++++++++++++++++++++------------------------
include/linux/page-flags.h | 11 ++---
2 files changed, 46 insertions(+), 50 deletions(-)
Index: linux-2.6.17/include/linux/page-flags.h
===================================================================
--- linux-2.6.17.orig/include/linux/page-flags.h 2006-09-08 21:36:56.000000000 +0200
+++ linux-2.6.17/include/linux/page-flags.h 2006-09-08 21:39:50.000000000 +0200
@@ -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
Index: linux-2.6.17/include/asm-s390/pgtable.h
===================================================================
--- linux-2.6.17.orig/include/asm-s390/pgtable.h 2006-09-08 21:36:56.000000000 +0200
+++ linux-2.6.17/include/asm-s390/pgtable.h 2006-09-08 21:39:50.000000000 +0200
@@ -33,7 +33,7 @@
#ifndef __ASSEMBLY__
#include <asm/bug.h>
#include <asm/processor.h>
-#include <linux/threads.h>
+#include <linux/page-struct.h>
struct vm_area_struct; /* forward declaration (include/linux/mm.h) */
struct mm_struct;
@@ -604,30 +604,31 @@
* should therefore only be called if it is not mapped in any
* address space.
*/
-#define page_test_and_clear_dirty(_page) \
-({ \
- struct page *__page = (_page); \
- unsigned long __physpage = __pa((__page-mem_map) << PAGE_SHIFT); \
- int __skey = page_get_storage_key(__physpage); \
- if (__skey & _PAGE_CHANGED) \
- page_set_storage_key(__physpage, __skey & ~_PAGE_CHANGED);\
- (__skey & _PAGE_CHANGED); \
-})
+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);
+
+ if (skey & _PAGE_CHANGED)
+ page_set_storage_key(physpage, skey & ~_PAGE_CHANGED);
+ return skey & _PAGE_CHANGED;
+}
/*
* Test and clear referenced bit in storage key.
*/
-#define page_test_and_clear_young(page) \
-({ \
- struct page *__page = (page); \
- unsigned long __physpage = __pa((__page-mem_map) << PAGE_SHIFT); \
- int __ccode; \
- asm volatile ("rrbe 0,%1\n\t" \
- "ipm %0\n\t" \
- "srl %0,28\n\t" \
- : "=d" (__ccode) : "a" (__physpage) : "cc" ); \
- (__ccode & 2); \
-})
+static inline int page_test_and_clear_young(struct page *page)
+{
+ unsigned long physpage = __pa((page - mem_map) << PAGE_SHIFT);
+ int ccode;
+
+ asm volatile (
+ "rrbe 0,%1\n"
+ "ipm %0\n"
+ "srl %0,28\n"
+ : "=d" (ccode) : "a" (physpage) : "cc" );
+ return ccode & 2;
+}
/*
* Conversion functions: convert a page and protection to a page entry,
@@ -640,32 +641,28 @@
return __pte;
}
-#define mk_pte(pg, pgprot) \
-({ \
- struct page *__page = (pg); \
- pgprot_t __pgprot = (pgprot); \
- unsigned long __physpage = __pa((__page-mem_map) << PAGE_SHIFT); \
- pte_t __pte = mk_pte_phys(__physpage, __pgprot); \
- __pte; \
-})
-
-#define pfn_pte(pfn, pgprot) \
-({ \
- pgprot_t __pgprot = (pgprot); \
- unsigned long __physpage = __pa((pfn) << PAGE_SHIFT); \
- pte_t __pte = mk_pte_phys(__physpage, __pgprot); \
- __pte; \
-})
+static inline pte_t mk_pte(struct page *page, pgprot_t pgprot)
+{
+ unsigned long physpage = __pa((page - mem_map) << PAGE_SHIFT);
+
+ return mk_pte_phys(physpage, pgprot);
+}
+
+static inline pte_t pfn_pte(unsigned long pfn, pgprot_t pgprot)
+{
+ unsigned long physpage = __pa((pfn) << PAGE_SHIFT);
+
+ return mk_pte_phys(physpage, pgprot);
+}
#ifdef __s390x__
-#define pfn_pmd(pfn, pgprot) \
-({ \
- pgprot_t __pgprot = (pgprot); \
- unsigned long __physpage = __pa((pfn) << PAGE_SHIFT); \
- pmd_t __pmd = __pmd(__physpage + pgprot_val(__pgprot)); \
- __pmd; \
-})
+static inline pmd_t pfn_pmd(unsigned long pfn, pgprot_t pgprot)
+{
+ unsigned long physpage = __pa((pfn) << PAGE_SHIFT);
+
+ return __pmd(physpage + pgprot_val(pgprot));
+}
#endif /* __s390x__ */
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2006-09-08 19:53 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-09-08 11:17 [patch 1/2] own header file for struct page Heiko Carstens, Heiko Carstens
2006-09-08 16:46 ` Andrew Morton
2006-09-08 18:33 ` Heiko Carstens
2006-09-08 19:06 ` Andrew Morton
2006-09-08 19:47 ` [patch 1/2] own header file for struct page v2 Heiko Carstens, Heiko Carstens
2006-09-08 19:48 ` Heiko Carstens, Heiko Carstens [this message]
2006-09-09 21:05 ` [patch 1/2] own header file for struct page Roman Zippel
2006-09-10 7:51 ` Heiko Carstens
2006-09-10 13:07 ` [patch 1/2] own header file for struct page v3 Heiko Carstens, Heiko Carstens
2006-09-10 13:08 ` [patch 2/2] convert s390 page handling macros to functions v3 Heiko Carstens, Heiko Carstens
2006-09-10 16:25 ` Dave Hansen
2006-09-11 4:22 ` Heiko Carstens
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=20060908194807.GB10139@osiris.ibm.com \
--to=heiko.carstens@de.ibm.com \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=schwidefsky@de.ibm.com \
/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