LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Andi Kleen <ak@suse.de>
To: tglx@linutronix.de, mingo@elte.hu, linux-kernel@vger.kernel.org
Subject: [PATCH] [4/8] CPA: Ifdef the cpa pool for DEBUG_PAGEALLOC
Date: Mon, 11 Feb 2008 10:50:19 +0100 (CET)	[thread overview]
Message-ID: <20080211095019.6ED761B41CE@basil.firstfloor.org> (raw)
In-Reply-To: <200802111050.372086035@suse.de>


When DEBUG_PAGEALLOC is not set there is no need for the complicated 
cpa pool because no recursion is possible in the memory allocator. 

So ifdef this case. This will save some memory because
the pool won't be needed for normal operation.

Signed-off-by: Andi Kleen <ak@suse.de>

---
 arch/x86/mm/pageattr.c |   27 +++++++++++++++++++++++++--
 1 file changed, 25 insertions(+), 2 deletions(-)

Index: linux/arch/x86/mm/pageattr.c
===================================================================
--- linux.orig/arch/x86/mm/pageattr.c
+++ linux/arch/x86/mm/pageattr.c
@@ -345,6 +345,8 @@ out_unlock:
 	return do_split;
 }
 
+#ifdef CONFIG_DEBUG_PAGEALLOC
+
 static LIST_HEAD(page_pool);
 static unsigned long pool_size, pool_pages, pool_low;
 static unsigned long pool_used, pool_failed, pool_refill;
@@ -365,14 +367,12 @@ static void cpa_fill_pool(void)
 	if (pool_pages >= pool_size || test_and_set_bit_lock(0, &pool_refill))
 		return;
 
-#ifdef CONFIG_DEBUG_PAGEALLOC
 	/*
 	 * We could do:
 	 * gfp = in_atomic() ? GFP_ATOMIC : GFP_KERNEL;
 	 * but this fails on !PREEMPT kernels
 	 */
 	gfp =  GFP_ATOMIC | __GFP_NORETRY | __GFP_NOWARN;
-#endif
 
 	while (pool_pages < pool_size) {
 		p = alloc_pages(gfp, 0);
@@ -416,6 +416,16 @@ void __init cpa_init(void)
 	       pool_pages, pool_size);
 }
 
+#else
+void __init cpa_init(void)
+{
+}
+
+static inline void cpa_fill_pool(void)
+{
+}
+#endif
+
 static int split_large_page(pte_t *kpte, unsigned long address)
 {
 	unsigned long flags, pfn, pfninc = 1;
@@ -424,12 +434,19 @@ static int split_large_page(pte_t *kpte,
 	pgprot_t ref_prot;
 	struct page *base;
 
+#ifndef CONFIG_DEBUG_PAGEALLOC
+	base = alloc_page(GFP_KERNEL);
+	if (!base)
+		return -ENOMEM;
+#endif
+
 	/*
 	 * Get a page from the pool. The pool list is protected by the
 	 * pgd_lock, which we have to take anyway for the split
 	 * operation:
 	 */
 	spin_lock_irqsave(&pgd_lock, flags);
+#ifdef CONFIG_DEBUG_PAGEALLOC
 	if (list_empty(&page_pool)) {
 		spin_unlock_irqrestore(&pgd_lock, flags);
 		return -ENOMEM;
@@ -441,6 +458,7 @@ static int split_large_page(pte_t *kpte,
 
 	if (pool_pages < pool_low)
 		pool_low = pool_pages;
+#endif
 
 	/*
 	 * Check for races, another CPU might have split this page
@@ -486,6 +504,7 @@ static int split_large_page(pte_t *kpte,
 	base = NULL;
 
 out_unlock:
+#ifdef CONFIG_DEBUG_PAGEALLOC
 	/*
 	 * If we dropped out via the lookup_address check under
 	 * pgd_lock then stick the page back into the pool:
@@ -495,6 +514,10 @@ out_unlock:
 		pool_pages++;
 	} else
 		pool_used++;
+#else
+	if (base)
+		__free_page(base);
+#endif
 	spin_unlock_irqrestore(&pgd_lock, flags);
 
 	return 0;

  parent reply	other threads:[~2008-02-11  9:51 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-11  9:50 [PATCH] [0/8] Misc CPA patchkit Andi Kleen
2008-02-11  9:50 ` [PATCH] [1/8] CPA: Remove my copyright notice Andi Kleen
2008-02-12  0:42   ` Thomas Gleixner
2008-02-11  9:50 ` [PATCH] [2/8] CPA: Remove inline from static_protections Andi Kleen
2008-02-11 14:04   ` Ingo Molnar
2008-02-11  9:50 ` [PATCH] [3/8] CPA: Fix some incorrect comments in the debug pagealloc code Andi Kleen
2008-02-11  9:50 ` Andi Kleen [this message]
2008-02-11  9:50 ` [PATCH] [5/8] CPA: Move pool allocation/free into separate functions Andi Kleen
2008-02-11  9:50 ` [PATCH] [6/8] CPA: Remove BUG_ON for LRU/Compound pages Andi Kleen
2008-02-17 14:07   ` Thomas Gleixner
2008-02-11  9:50 ` [PATCH] [7/8] CPA: Don't flush caches on CPUs that support self-snoop Andi Kleen
2008-02-11 15:04   ` Arjan van de Ven
2008-02-11 15:12     ` Andi Kleen
2008-02-11 15:21       ` Arjan van de Ven
2008-02-11 15:27         ` Andi Kleen
2008-02-11 17:36           ` Siddha, Suresh B
2008-02-11 17:58             ` Andi Kleen
2008-02-11 19:47               ` Siddha, Suresh B
2008-02-11 20:36                 ` Arjan van de Ven
2008-02-12  8:45                   ` Andi Kleen
2008-02-11  9:50 ` [PATCH] [8/8] CPA: Add statistics about state of direct mapping Andi Kleen

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=20080211095019.6ED761B41CE@basil.firstfloor.org \
    --to=ak@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=tglx@linutronix.de \
    --subject='Re: [PATCH] [4/8] CPA: Ifdef the cpa pool for DEBUG_PAGEALLOC' \
    /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

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