linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH, RESEND] asm-generic, mm: pgtable: consolidate zero page helpers
@ 2012-12-07 11:53 Kirill A. Shutemov
  2012-12-12  3:07 ` David Rientjes
  0 siblings, 1 reply; 4+ messages in thread
From: Kirill A. Shutemov @ 2012-12-07 11:53 UTC (permalink / raw)
  To: Andrew Morton, linux-mm, Arnd Bergmann, linux-arch
  Cc: linux-s390, Martin Schwidefsky, Heiko Carstens, linux-mips,
	Ralf Baechle, John Crispin, Kirill A. Shutemov

From: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>

We have two different implementation of is_zero_pfn() and
my_zero_pfn() helpers: for architectures with and without zero page
coloring.

Let's consolidate them in <asm-generic/pgtable.h>.

Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
---
 arch/mips/include/asm/pgtable.h |   11 +----------
 arch/s390/include/asm/pgtable.h |   11 +----------
 include/asm-generic/pgtable.h   |   26 ++++++++++++++++++++++++++
 include/linux/mm.h              |    8 --------
 mm/memory.c                     |    7 -------
 5 files changed, 28 insertions(+), 35 deletions(-)

diff --git a/arch/mips/include/asm/pgtable.h b/arch/mips/include/asm/pgtable.h
index 252202d..ec50d52 100644
--- a/arch/mips/include/asm/pgtable.h
+++ b/arch/mips/include/asm/pgtable.h
@@ -77,16 +77,7 @@ extern unsigned long zero_page_mask;
 
 #define ZERO_PAGE(vaddr) \
 	(virt_to_page((void *)(empty_zero_page + (((unsigned long)(vaddr)) & zero_page_mask))))
-
-#define is_zero_pfn is_zero_pfn
-static inline int is_zero_pfn(unsigned long pfn)
-{
-	extern unsigned long zero_pfn;
-	unsigned long offset_from_zero_pfn = pfn - zero_pfn;
-	return offset_from_zero_pfn <= (zero_page_mask >> PAGE_SHIFT);
-}
-
-#define my_zero_pfn(addr)	page_to_pfn(ZERO_PAGE(addr))
+#define __HAVE_COLOR_ZERO_PAGE
 
 extern void paging_init(void);
 
diff --git a/arch/s390/include/asm/pgtable.h b/arch/s390/include/asm/pgtable.h
index 23d9a8a..c928dc1 100644
--- a/arch/s390/include/asm/pgtable.h
+++ b/arch/s390/include/asm/pgtable.h
@@ -54,16 +54,7 @@ extern unsigned long zero_page_mask;
 #define ZERO_PAGE(vaddr) \
 	(virt_to_page((void *)(empty_zero_page + \
 	 (((unsigned long)(vaddr)) &zero_page_mask))))
-
-#define is_zero_pfn is_zero_pfn
-static inline int is_zero_pfn(unsigned long pfn)
-{
-	extern unsigned long zero_pfn;
-	unsigned long offset_from_zero_pfn = pfn - zero_pfn;
-	return offset_from_zero_pfn <= (zero_page_mask >> PAGE_SHIFT);
-}
-
-#define my_zero_pfn(addr)	page_to_pfn(ZERO_PAGE(addr))
+#define __HAVE_COLOR_ZERO_PAGE
 
 #endif /* !__ASSEMBLY__ */
 
diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h
index d03d0a8..04a398e 100644
--- a/include/asm-generic/pgtable.h
+++ b/include/asm-generic/pgtable.h
@@ -453,6 +453,32 @@ extern void untrack_pfn(struct vm_area_struct *vma, unsigned long pfn,
 			unsigned long size);
 #endif
 
+#ifdef __HAVE_COLOR_ZERO_PAGE
+static inline int is_zero_pfn(unsigned long pfn)
+{
+	extern unsigned long zero_pfn;
+	unsigned long offset_from_zero_pfn = pfn - zero_pfn;
+	return offset_from_zero_pfn <= (zero_page_mask >> PAGE_SHIFT);
+}
+
+static inline unsigned long my_zero_pfn(unsigned long addr)
+{
+	return page_to_pfn(ZERO_PAGE(addr));
+}
+#else
+static inline int is_zero_pfn(unsigned long pfn)
+{
+	extern unsigned long zero_pfn;
+	return pfn == zero_pfn;
+}
+
+static inline unsigned long my_zero_pfn(unsigned long addr)
+{
+	extern unsigned long zero_pfn;
+	return zero_pfn;
+}
+#endif
+
 #ifdef CONFIG_MMU
 
 #ifndef CONFIG_TRANSPARENT_HUGEPAGE
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 2984e07..dad5c73 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -516,14 +516,6 @@ static inline pte_t maybe_mkwrite(pte_t pte, struct vm_area_struct *vma)
 }
 #endif
 
-#ifndef my_zero_pfn
-static inline unsigned long my_zero_pfn(unsigned long addr)
-{
-	extern unsigned long zero_pfn;
-	return zero_pfn;
-}
-#endif
-
 /*
  * Multiple processes may "see" the same page. E.g. for untouched
  * mappings of /dev/null, all processes see the same page full of
diff --git a/mm/memory.c b/mm/memory.c
index 3db03ed..efd870d 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -725,13 +725,6 @@ static inline bool is_cow_mapping(vm_flags_t flags)
 	return (flags & (VM_SHARED | VM_MAYWRITE)) == VM_MAYWRITE;
 }
 
-#ifndef is_zero_pfn
-static inline int is_zero_pfn(unsigned long pfn)
-{
-	return pfn == zero_pfn;
-}
-#endif
-
 /*
  * vm_normal_page -- This function gets the "struct page" associated with a pte.
  *
-- 
1.7.10.4

--
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>

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH, RESEND] asm-generic, mm: pgtable: consolidate zero page helpers
  2012-12-07 11:53 [PATCH, RESEND] asm-generic, mm: pgtable: consolidate zero page helpers Kirill A. Shutemov
@ 2012-12-12  3:07 ` David Rientjes
  2012-12-12 10:55   ` Kirill A. Shutemov
  0 siblings, 1 reply; 4+ messages in thread
From: David Rientjes @ 2012-12-12  3:07 UTC (permalink / raw)
  To: Kirill A. Shutemov
  Cc: Andrew Morton, linux-mm, Arnd Bergmann, linux-arch, linux-s390,
	Martin Schwidefsky, Heiko Carstens, linux-mips, Ralf Baechle,
	John Crispin

On Fri, 7 Dec 2012, Kirill A. Shutemov wrote:

> From: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
> 
> We have two different implementation of is_zero_pfn() and
> my_zero_pfn() helpers: for architectures with and without zero page
> coloring.
> 
> Let's consolidate them in <asm-generic/pgtable.h>.
> 

What's the benefit from doing this other than generalizing some per-arch 
code?  It simply adds on more layer of redirection to try to find the 
implementation that matters for the architecture you're hacking on.

--
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>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH, RESEND] asm-generic, mm: pgtable: consolidate zero page helpers
  2012-12-12  3:07 ` David Rientjes
@ 2012-12-12 10:55   ` Kirill A. Shutemov
  2012-12-12 22:54     ` David Rientjes
  0 siblings, 1 reply; 4+ messages in thread
From: Kirill A. Shutemov @ 2012-12-12 10:55 UTC (permalink / raw)
  To: David Rientjes
  Cc: Andrew Morton, linux-mm, Arnd Bergmann, linux-arch, linux-s390,
	Martin Schwidefsky, Heiko Carstens, linux-mips, Ralf Baechle,
	John Crispin

[-- Attachment #1: Type: text/plain, Size: 878 bytes --]

On Tue, Dec 11, 2012 at 07:07:14PM -0800, David Rientjes wrote:
> On Fri, 7 Dec 2012, Kirill A. Shutemov wrote:
> 
> > From: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
> > 
> > We have two different implementation of is_zero_pfn() and
> > my_zero_pfn() helpers: for architectures with and without zero page
> > coloring.
> > 
> > Let's consolidate them in <asm-generic/pgtable.h>.
> > 
> 
> What's the benefit from doing this other than generalizing some per-arch 
> code?  It simply adds on more layer of redirection to try to find the 
> implementation that matters for the architecture you're hacking on.

The idea of asm-generic is consolidation arch code which can be re-used
for different arches. It also makes support of new arches easier.

Do you think have copy of the same code here and there is any better?

-- 
 Kirill A. Shutemov

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH, RESEND] asm-generic, mm: pgtable: consolidate zero page helpers
  2012-12-12 10:55   ` Kirill A. Shutemov
@ 2012-12-12 22:54     ` David Rientjes
  0 siblings, 0 replies; 4+ messages in thread
From: David Rientjes @ 2012-12-12 22:54 UTC (permalink / raw)
  To: Kirill A. Shutemov
  Cc: Andrew Morton, linux-mm, Arnd Bergmann, linux-arch, linux-s390,
	Martin Schwidefsky, Heiko Carstens, linux-mips, Ralf Baechle,
	John Crispin

On Wed, 12 Dec 2012, Kirill A. Shutemov wrote:

> > What's the benefit from doing this other than generalizing some per-arch 
> > code?  It simply adds on more layer of redirection to try to find the 
> > implementation that matters for the architecture you're hacking on.
> 
> The idea of asm-generic is consolidation arch code which can be re-used
> for different arches. It also makes support of new arches easier.
> 

Yeah, but you're moving is_zero_pfn() unnecessarily into a header file 
when it is only used mm/memory.c and it adds a __HAVE_* definition that we 
always try to reduce (both __HAVE and __ARCH definitions are frowned 
upon).  I don't think it's much of a win to obfuscate the code because 
mips and s390 implement colored zero pages.

--
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>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-12-12 22:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-07 11:53 [PATCH, RESEND] asm-generic, mm: pgtable: consolidate zero page helpers Kirill A. Shutemov
2012-12-12  3:07 ` David Rientjes
2012-12-12 10:55   ` Kirill A. Shutemov
2012-12-12 22:54     ` David Rientjes

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).