Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1640767

Re: [PATCH v2] perf/core: Avoid removing shared pmu_context on unregister

From David Carrillo-Cisneros <davidcc@google.com>
Newsgroups linux.kernel
Subject Re: [PATCH v2] perf/core: Avoid removing shared pmu_context on unregister
Date 2017-05-12 23:30 +0200
Message-ID <tGqil-2fu-13@gated-at.bofh.it> (permalink)
References <tGgj0-3aJ-13@gated-at.bofh.it> <tGhf4-3Vf-1@gated-at.bofh.it> <tGpFD-1DN-7@gated-at.bofh.it> <tGpPj-1Im-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


>>
>> Shouldn't be cleaner to keep the check in find_pmu_context, just as it
>> was before commit 1fd7e4169954 ("perf/core: Remove
>> perf_cpu_context::unique_pmu")?
>>
>> (Code below untested)
>>
>> diff --git a/kernel/events/core.c b/kernel/events/core.c
>> index 6e75a5c9412d..50d90cbf8418 100644
>> --- a/kernel/events/core.c
>> +++ b/kernel/events/core.c
>> @@ -8857,7 +8857,8 @@ static struct perf_cpu_context __percpu
>> *find_pmu_context(int ctxn)
>>  static void free_pmu_context(struct pmu *pmu)
>>  {
>>         mutex_lock(&pmus_lock);
>> -       free_percpu(pmu->pmu_cpu_context);
>> +       if (!find_pmu_context(pmu->task_ctx_nr))
>> +               free_percpu(pmu->pmu_cpu_context);
>>         mutex_unlock(&pmus_lock);
>
> We have the problem that find_pmu_context looks for a matching
> task_ctx_nr, but if a second pmu was registered since our list_del and
> before our search, we would wrongly conclude that it was using our pmu
> context, but it had actually allocated a new one for itself.
>

Makes sense. It'd be nice to have that in a comment. Other than that I
am fine with v2.

David

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] perf/core: Avoid removing shared pmu_context on unregister Chris Wilson <chris@chris-wilson.co.uk> - 2017-05-12 12:50 +0200
  [PATCH v2] perf/core: Avoid removing shared pmu_context on unregister Chris Wilson <chris@chris-wilson.co.uk> - 2017-05-12 13:50 +0200
    Re: [PATCH v2] perf/core: Avoid removing shared pmu_context on unregister David Carrillo-Cisneros <davidcc@google.com> - 2017-05-12 22:50 +0200
    Re: [PATCH v2] perf/core: Avoid removing shared pmu_context on unregister David Carrillo-Cisneros <davidcc@google.com> - 2017-05-12 22:50 +0200
      Re: [PATCH v2] perf/core: Avoid removing shared pmu_context on  unregister Chris Wilson <chris@chris-wilson.co.uk> - 2017-05-12 23:00 +0200
        Re: [PATCH v2] perf/core: Avoid removing shared pmu_context on unregister David Carrillo-Cisneros <davidcc@google.com> - 2017-05-12 23:30 +0200
  Re: [PATCH] perf/core: Avoid removing shared pmu_context on  unregister Chris Wilson <chris@chris-wilson.co.uk> - 2017-05-12 13:50 +0200

csiph-web