Messages in this thread | | | Subject | Re: [PATCH v4 RESEND 3/5] perf/x86/lbr: Move cpuc->lbr_xsave allocation out of sleeping region | From | Like Xu <> | Date | Wed, 24 Mar 2021 13:42:24 +0800 |
| |
On 2021/3/24 12:04, Namhyung Kim wrote: > 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, it helps and I will apply it in the next version.
> > Thanks, > Namhyung >
| |