Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit ff65338

Browse files
namhyungPeter Zijlstra
authored andcommitted
perf core: Allocate perf_event in the target node memory
For cpu events, it'd better allocating them in the corresponding node memory as they would be mostly accessed by the target cpu. Although perf tools sets the cpu affinity before calling perf_event_open, there are places it doesn't (notably perf record) and we should consider other external users too. Signed-off-by: Namhyung Kim <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent bdacfaf commit ff65338

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

kernel/events/core.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11288,13 +11288,16 @@ perf_event_alloc(struct perf_event_attr *attr, int cpu,
1128811288
struct perf_event *event;
1128911289
struct hw_perf_event *hwc;
1129011290
long err = -EINVAL;
11291+
int node;
1129111292

1129211293
if ((unsigned)cpu >= nr_cpu_ids) {
1129311294
if (!task || cpu != -1)
1129411295
return ERR_PTR(-EINVAL);
1129511296
}
1129611297

11297-
event = kmem_cache_zalloc(perf_event_cache, GFP_KERNEL);
11298+
node = (cpu >= 0) ? cpu_to_node(cpu) : -1;
11299+
event = kmem_cache_alloc_node(perf_event_cache, GFP_KERNEL | __GFP_ZERO,
11300+
node);
1129811301
if (!event)
1129911302
return ERR_PTR(-ENOMEM);
1130011303

0 commit comments

Comments
 (0)