lkml.org 
[lkml]   [2021]   [Mar]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH v4 RESEND 3/5] perf/x86/lbr: Move cpuc->lbr_xsave allocation out of sleeping region
On Wed, Mar 24, 2021 at 12:47 PM Like Xu <like.xu@linux.intel.com> wrote:
>
> Hi Namhyung,
>
> On 2021/3/24 9:32, Namhyung Kim wrote:
> > Hello,
> >
> > On Mon, Mar 22, 2021 at 3:14 PM Like Xu <like.xu@linux.intel.com> wrote:
> >> +void reserve_lbr_buffers(struct perf_event *event)
> >> +{
> >> + struct kmem_cache *kmem_cache = x86_get_pmu()->task_ctx_cache;
> >> + struct cpu_hw_events *cpuc;
> >> + int cpu;
> >> +
> >> + if (!static_cpu_has(X86_FEATURE_ARCH_LBR))
> >> + return;
> >> +
> >> + for_each_possible_cpu(cpu) {
> >> + cpuc = per_cpu_ptr(&cpu_hw_events, cpu);
> >> + if (kmem_cache && !cpuc->lbr_xsave && !event->attr.precise_ip)
> >> + cpuc->lbr_xsave = kmem_cache_alloc(kmem_cache, GFP_KERNEL);
> >> + }
> >> +}
> >
> > I think we should use kmem_cache_alloc_node().
>
> "kmem_cache_alloc_node - Allocate an object on the specified node"
>
> The reserve_lbr_buffers() is called in __x86_pmu_event_init().
> When the LBR perf_event is scheduled to another node, it seems
> that we will not call init() and allocate again.
>
> Do you mean use kmem_cache_alloc_node() for each numa_nodes_parsed ?

I assume cpuc->lbr_xsave will be accessed for that cpu only.
Then it needs to allocate it in the node that cpu belongs to.
Something like below..

cpuc->lbr_xsave = kmem_cache_alloc_node(kmem_cache, GFP_KERNEL,
cpu_to_node(cpu));

Thanks,
Namhyung

\
 
 \ /
  Last update: 2021-03-24 05:06    [W:0.064 / U:0.304 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site