Skip to content

Commit

Permalink
PERCPU : __percpu_alloc_mask() can dynamically size percpu_data storage
Browse files Browse the repository at this point in the history
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 <dada1@cosmosbay.com>
Cc: Christoph Lameter <clameter@sgi.com>
Cc: "David S. Miller" <davem@davemloft.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Eric Dumazet authored and Linus Torvalds committed Feb 6, 2008
1 parent e7ca2d4 commit b324215
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion include/linux/percpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
#ifdef CONFIG_SMP

struct percpu_data {
void *ptrs[NR_CPUS];
void *ptrs[1];
};

#define __percpu_disguise(pdata) (struct percpu_data *)~(unsigned long)(pdata)
Expand Down
2 changes: 1 addition & 1 deletion mm/allocpercpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit b324215

Please sign in to comment.