Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 86785
b: refs/heads/master
c: be85279
h: refs/heads/master
i:
  86783: d60ca20
v: v3
  • Loading branch information
Eric Dumazet authored and Linus Torvalds committed Mar 5, 2008
1 parent 86297e1 commit 3d86aaa
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: e3892296de632e3f9299d9fabe0c746740004891
refs/heads/master: be852795e1c8d3829ddf3cb1ce806113611fa555
15 changes: 14 additions & 1 deletion trunk/mm/allocpercpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
#include <linux/mm.h>
#include <linux/module.h>

#ifndef cache_line_size
#define cache_line_size() L1_CACHE_BYTES
#endif

/**
* percpu_depopulate - depopulate per-cpu data for given cpu
* @__pdata: per-cpu data to depopulate
Expand Down Expand Up @@ -52,6 +56,11 @@ void *percpu_populate(void *__pdata, size_t size, gfp_t gfp, int cpu)
struct percpu_data *pdata = __percpu_disguise(__pdata);
int node = cpu_to_node(cpu);

/*
* We should make sure each CPU gets private memory.
*/
size = roundup(size, cache_line_size());

BUG_ON(pdata->ptrs[cpu]);
if (node_online(node))
pdata->ptrs[cpu] = kmalloc_node(size, gfp|__GFP_ZERO, node);
Expand Down Expand Up @@ -98,7 +107,11 @@ EXPORT_SYMBOL_GPL(__percpu_populate_mask);
*/
void *__percpu_alloc_mask(size_t size, gfp_t gfp, cpumask_t *mask)
{
void *pdata = kzalloc(nr_cpu_ids * sizeof(void *), gfp);
/*
* We allocate whole cache lines to avoid false sharing
*/
size_t sz = roundup(nr_cpu_ids * sizeof(void *), cache_line_size());
void *pdata = kzalloc(sz, gfp);
void *__pdata = __percpu_disguise(pdata);

if (unlikely(!pdata))
Expand Down

0 comments on commit 3d86aaa

Please sign in to comment.