From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933647AbYDQBXQ (ORCPT ); Wed, 16 Apr 2008 21:23:16 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1760480AbYDQBIs (ORCPT ); Wed, 16 Apr 2008 21:08:48 -0400 Received: from sous-sol.org ([216.99.217.87]:58954 "EHLO sous-sol.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760372AbYDQBIr (ORCPT ); Wed, 16 Apr 2008 21:08:47 -0400 Message-Id: <20080417010329.742004783@sous-sol.org> References: <20080417010122.148289106@sous-sol.org> User-Agent: quilt/0.46-1 Date: Wed, 16 Apr 2008 18:01:38 -0700 From: Chris Wright To: linux-kernel@vger.kernel.org, stable@kernel.org Cc: Justin Forbes , Zwane Mwaikambo , "Theodore Ts'o" , Randy Dunlap , Dave Jones , Chuck Wolber , Chris Wedgwood , Michael Krufky , Chuck Ebbert , Domenico Andreoli , torvalds@linux-foundation.org, akpm@linux-foundation.org, alan@lxorguk.ukuu.org.uk, snitzer@gmail.com, clameter@sgi.com, davem@davemloft.net, dada1@cosmosbay.com Subject: PERCPU : __percpu_alloc_mask() can dynamically size percpu_data storage Content-Disposition: inline; filename=percpu-__percpu_alloc_mask-can-dynamically-size-percpu_data-storage.patch Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org -stable review patch. If anyone has any objections, please let us know. --------------------- From: Eric Dumazet upstream commit: b3242151906372f30f57feaa43b4cac96a23edb1 Instead of allocating a fix sized array of NR_CPUS pointers for percpu_data, we can use nr_cpu_ids, which is generally < NR_CPUS. Signed-off-by: Eric Dumazet Cc: Christoph Lameter Cc: "David S. Miller" Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Chris Wright --- include/linux/percpu.h | 2 +- mm/allocpercpu.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) This is appropriate for 2.6.24.y --- a/include/linux/percpu.h +++ b/include/linux/percpu.h @@ -34,7 +34,7 @@ #ifdef CONFIG_SMP struct percpu_data { - void *ptrs[NR_CPUS]; + void *ptrs[1]; }; #define __percpu_disguise(pdata) (struct percpu_data *)~(unsigned long)(pdata) --- a/mm/allocpercpu.c +++ b/mm/allocpercpu.c @@ -98,7 +98,7 @@ EXPORT_SYMBOL_GPL(__percpu_populate_mask */ void *__percpu_alloc_mask(size_t size, gfp_t gfp, cpumask_t *mask) { - void *pdata = kzalloc(sizeof(struct percpu_data), gfp); + void *pdata = kzalloc(nr_cpu_ids * sizeof(void *), gfp); void *__pdata = __percpu_disguise(pdata); if (unlikely(!pdata)) --