All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tejun Heo <tj@kernel.org>
To: JBeulich@novell.com, andi@firstfloor.org, mingo@elte.hu,
	linux-kernel-owner@vger.kernel.org, hpa@zytor.com,
	tglx@linutronix.de, linux-kernel@vger.kernel.org
Cc: Tejun Heo <tj@kernel.org>
Subject: [PATCH 5/5] x86: ensure percpu remap doesn't consume too much vmalloc space
Date: Fri, 15 May 2009 13:28:59 +0900	[thread overview]
Message-ID: <1242361739-21186-6-git-send-email-tj@kernel.org> (raw)
In-Reply-To: <1242361739-21186-1-git-send-email-tj@kernel.org>

On extreme configuration (e.g. 32bit 32-way NUMA machine), remap
percpu first chunk allocator can consume too much of vmalloc space.
Make it fall back to 4k allocator if the consumption goes over 20%.

[ Impact: add sanity check for remap percpu first chunk allocator ]

Signed-off-by: Tejun Heo <tj@kernel.org>
Reported-by: Jan Beulich <JBeulich@novell.com>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: Ingo Molnar <mingo@elte.hu>
---
 arch/x86/kernel/setup_percpu.c |   18 +++++++++++++++---
 1 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kernel/setup_percpu.c b/arch/x86/kernel/setup_percpu.c
index 29be178..1f28574 100644
--- a/arch/x86/kernel/setup_percpu.c
+++ b/arch/x86/kernel/setup_percpu.c
@@ -169,9 +169,21 @@ static ssize_t __init setup_pcpu_remap(size_t static_size, bool chosen)
 		return -EINVAL;
 	}
 
-	/* on non-NUMA, embedding is better */
-	if (!chosen && !pcpu_need_numa())
-		return -EINVAL;
+	if (!chosen) {
+		size_t vm_size = VMALLOC_END - VMALLOC_START;
+		size_t tot_size = num_possible_cpus() * PMD_SIZE;
+
+		/* on non-NUMA, embedding is better */
+		if (!pcpu_need_numa())
+			return -EINVAL;
+
+		/* don't consume more than 20% of vmalloc area */
+		if (tot_size > vm_size / 5) {
+			pr_info("PERCPU: too large chunk size %zuMB for "
+				"large page remap\n", tot_size >> 20);
+			return -EINVAL;
+		}
+	}
 
 	/*
 	 * Currently supports only single page.  Supporting multiple
-- 
1.6.0.2


  parent reply	other threads:[~2009-05-15  4:29 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-15  4:28 [GIT PATCH 2.6.30-rc5] x86,percpu: fix pageattr handling with remap allocator, take#2 Tejun Heo
2009-05-15  4:28 ` [PATCH 1/5] x86: prepare setup_pcpu_remap() for pageattr fix Tejun Heo
2009-05-15  4:28 ` [PATCH 2/5] x86: reorganize cpa_process_alias() Tejun Heo
2009-05-15  9:35   ` [PATCH UPDATED " Tejun Heo
2009-05-15  4:28 ` [PATCH 3/5] x86: fix pageattr handling for remap percpu allocator Tejun Heo
2009-05-15  7:58   ` Jan Beulich
2009-05-15  8:18     ` Tejun Heo
2009-05-15  9:35   ` [PATCH UPDATED " Tejun Heo
2009-05-15  4:28 ` [PATCH 4/5] x86: implement percpu_alloc kernel parameter Tejun Heo
2009-05-15  8:04   ` Jan Beulich
2009-05-15  9:27     ` Tejun Heo
2009-05-15  4:28 ` Tejun Heo [this message]
2009-05-15  9:36 ` [GIT PATCH 2.6.30-rc5] x86,percpu: fix pageattr handling with remap allocator, take#2 Tejun Heo
2009-05-15  9:52   ` [GIT PATCH 2.6.30-rc5] x86,percpu: fix pageattr handling withremap " Jan Beulich
     [not found]   ` <4A0D57920200007800001150@novell.com>
2009-05-15 10:08     ` Tejun Heo
  -- strict thread matches above, loose matches on Subject: below --
2009-06-01  6:34 [GIT PATCH core/percpu] x86,percpu: fix pageattr handling with remap allocator, take#3 Tejun Heo
2009-06-01  6:34 ` [PATCH 5/5] x86: ensure percpu remap doesn't consume too much vmalloc space Tejun Heo

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=1242361739-21186-6-git-send-email-tj@kernel.org \
    --to=tj@kernel.org \
    --cc=JBeulich@novell.com \
    --cc=andi@firstfloor.org \
    --cc=hpa@zytor.com \
    --cc=linux-kernel-owner@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=tglx@linutronix.de \
    /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 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.