All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86, cpa: Cleanup split_large_page and its callee
@ 2013-03-21 17:16 Borislav Petkov
  2013-03-26 20:56 ` Thomas Gleixner
  2013-04-10 13:50 ` [tip:x86/mm] x86/mm/cpa: Cleanup split_large_page() " tip-bot for Borislav Petkov
  0 siblings, 2 replies; 3+ messages in thread
From: Borislav Petkov @ 2013-03-21 17:16 UTC (permalink / raw)
  To: X86 ML; +Cc: LKML, Borislav Petkov

From: Borislav Petkov <bp@suse.de>

So basically we're generating the pte_t * from a struct page and we're
handing it down to the __split_large_page internal version which then
goes and gets back struct page * from it because it needs it.

Change the caller to hand down struct page * directly and the callee can
compute the pte_t itself.

Net save is one virt_to_page() call and simpler code. While at it, make
__split_large_page static.

Signed-off-by: Borislav Petkov <bp@suse.de>
---
 arch/x86/include/asm/pgtable_types.h | 1 -
 arch/x86/mm/pageattr.c               | 9 ++++-----
 2 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/arch/x86/include/asm/pgtable_types.h b/arch/x86/include/asm/pgtable_types.h
index 567b5d0632b2..e6423002c10b 100644
--- a/arch/x86/include/asm/pgtable_types.h
+++ b/arch/x86/include/asm/pgtable_types.h
@@ -351,7 +351,6 @@ static inline void update_page_count(int level, unsigned long pages) { }
  * as a pte too.
  */
 extern pte_t *lookup_address(unsigned long address, unsigned int *level);
-extern int __split_large_page(pte_t *kpte, unsigned long address, pte_t *pbase);
 extern phys_addr_t slow_virt_to_phys(void *__address);
 
 #endif	/* !__ASSEMBLY__ */
diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
index 091934e1d0d9..25b1d35c76cb 100644
--- a/arch/x86/mm/pageattr.c
+++ b/arch/x86/mm/pageattr.c
@@ -542,13 +542,14 @@ out_unlock:
 	return do_split;
 }
 
-int __split_large_page(pte_t *kpte, unsigned long address, pte_t *pbase)
+static int
+__split_large_page(pte_t *kpte, unsigned long address, struct page *base)
 {
+	pte_t *pbase = (pte_t *)page_address(base);
 	unsigned long pfn, pfninc = 1;
 	unsigned int i, level;
 	pte_t *tmp;
 	pgprot_t ref_prot;
-	struct page *base = virt_to_page(pbase);
 
 	spin_lock(&pgd_lock);
 	/*
@@ -633,7 +634,6 @@ int __split_large_page(pte_t *kpte, unsigned long address, pte_t *pbase)
 
 static int split_large_page(pte_t *kpte, unsigned long address)
 {
-	pte_t *pbase;
 	struct page *base;
 
 	if (!debug_pagealloc)
@@ -644,8 +644,7 @@ static int split_large_page(pte_t *kpte, unsigned long address)
 	if (!base)
 		return -ENOMEM;
 
-	pbase = (pte_t *)page_address(base);
-	if (__split_large_page(kpte, address, pbase))
+	if (__split_large_page(kpte, address, base))
 		__free_page(base);
 
 	return 0;
-- 
1.8.1.3.535.ga923c31


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

* Re: [PATCH] x86, cpa: Cleanup split_large_page and its callee
  2013-03-21 17:16 [PATCH] x86, cpa: Cleanup split_large_page and its callee Borislav Petkov
@ 2013-03-26 20:56 ` Thomas Gleixner
  2013-04-10 13:50 ` [tip:x86/mm] x86/mm/cpa: Cleanup split_large_page() " tip-bot for Borislav Petkov
  1 sibling, 0 replies; 3+ messages in thread
From: Thomas Gleixner @ 2013-03-26 20:56 UTC (permalink / raw)
  To: Borislav Petkov; +Cc: X86 ML, LKML, Borislav Petkov

On Thu, 21 Mar 2013, Borislav Petkov wrote:

> From: Borislav Petkov <bp@suse.de>
> 
> So basically we're generating the pte_t * from a struct page and we're
> handing it down to the __split_large_page internal version which then
> goes and gets back struct page * from it because it needs it.
> 
> Change the caller to hand down struct page * directly and the callee can
> compute the pte_t itself.
> 
> Net save is one virt_to_page() call and simpler code. While at it, make
> __split_large_page static.
> 
> Signed-off-by: Borislav Petkov <bp@suse.de>

Acked-by: Thomas Gleixner <tglx@linutronix.de>

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

* [tip:x86/mm] x86/mm/cpa: Cleanup split_large_page() and its callee
  2013-03-21 17:16 [PATCH] x86, cpa: Cleanup split_large_page and its callee Borislav Petkov
  2013-03-26 20:56 ` Thomas Gleixner
@ 2013-04-10 13:50 ` tip-bot for Borislav Petkov
  1 sibling, 0 replies; 3+ messages in thread
From: tip-bot for Borislav Petkov @ 2013-04-10 13:50 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, tglx, bp

Commit-ID:  5952886bfeec065041d04dfcc2693b581e8f2424
Gitweb:     http://git.kernel.org/tip/5952886bfeec065041d04dfcc2693b581e8f2424
Author:     Borislav Petkov <bp@suse.de>
AuthorDate: Thu, 21 Mar 2013 18:16:57 +0100
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Wed, 10 Apr 2013 14:39:08 +0200

x86/mm/cpa: Cleanup split_large_page() and its callee

So basically we're generating the pte_t * from a struct page and
we're handing it down to the __split_large_page() internal version
which then goes and gets back struct page * from it because it
needs it.

Change the caller to hand down struct page * directly and the
callee can compute the pte_t itself.

Net save is one virt_to_page() call and simpler code. While at
it, make __split_large_page() static.

Signed-off-by: Borislav Petkov <bp@suse.de>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/1363886217-24703-1-git-send-email-bp@alien8.de
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/include/asm/pgtable_types.h | 1 -
 arch/x86/mm/pageattr.c               | 9 ++++-----
 2 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/arch/x86/include/asm/pgtable_types.h b/arch/x86/include/asm/pgtable_types.h
index 567b5d0..e642300 100644
--- a/arch/x86/include/asm/pgtable_types.h
+++ b/arch/x86/include/asm/pgtable_types.h
@@ -351,7 +351,6 @@ static inline void update_page_count(int level, unsigned long pages) { }
  * as a pte too.
  */
 extern pte_t *lookup_address(unsigned long address, unsigned int *level);
-extern int __split_large_page(pte_t *kpte, unsigned long address, pte_t *pbase);
 extern phys_addr_t slow_virt_to_phys(void *__address);
 
 #endif	/* !__ASSEMBLY__ */
diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
index 091934e..25b1d35 100644
--- a/arch/x86/mm/pageattr.c
+++ b/arch/x86/mm/pageattr.c
@@ -542,13 +542,14 @@ out_unlock:
 	return do_split;
 }
 
-int __split_large_page(pte_t *kpte, unsigned long address, pte_t *pbase)
+static int
+__split_large_page(pte_t *kpte, unsigned long address, struct page *base)
 {
+	pte_t *pbase = (pte_t *)page_address(base);
 	unsigned long pfn, pfninc = 1;
 	unsigned int i, level;
 	pte_t *tmp;
 	pgprot_t ref_prot;
-	struct page *base = virt_to_page(pbase);
 
 	spin_lock(&pgd_lock);
 	/*
@@ -633,7 +634,6 @@ int __split_large_page(pte_t *kpte, unsigned long address, pte_t *pbase)
 
 static int split_large_page(pte_t *kpte, unsigned long address)
 {
-	pte_t *pbase;
 	struct page *base;
 
 	if (!debug_pagealloc)
@@ -644,8 +644,7 @@ static int split_large_page(pte_t *kpte, unsigned long address)
 	if (!base)
 		return -ENOMEM;
 
-	pbase = (pte_t *)page_address(base);
-	if (__split_large_page(kpte, address, pbase))
+	if (__split_large_page(kpte, address, base))
 		__free_page(base);
 
 	return 0;

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

end of thread, other threads:[~2013-04-10 13:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-21 17:16 [PATCH] x86, cpa: Cleanup split_large_page and its callee Borislav Petkov
2013-03-26 20:56 ` Thomas Gleixner
2013-04-10 13:50 ` [tip:x86/mm] x86/mm/cpa: Cleanup split_large_page() " tip-bot for Borislav Petkov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.