Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Linux: Kernel

[PATCH 2/9] perf: Allow pmu to choose cpu on which to install event

 

 

Linux kernel RSS feed   Index | Next | Previous | View Threaded


zheng.z.yan at intel

May 1, 2012, 7:07 PM

Post #1 of 5 (67 views)
Permalink
[PATCH 2/9] perf: Allow pmu to choose cpu on which to install event

From: "Yan, Zheng" <zheng.z.yan [at] intel>

Allow the pmu->event_init callback to change event->cpu, so pmu can
choose cpu on which to install event.

Signed-off-by: Zheng Yan <zheng.z.yan [at] intel>
---
kernel/events/core.c | 13 +++++++++----
1 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/kernel/events/core.c b/kernel/events/core.c
index 32cfc76..84911de 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -6250,6 +6250,8 @@ SYSCALL_DEFINE5(perf_event_open,
}
}

+ get_online_cpus();
+
event = perf_event_alloc(&attr, cpu, task, group_leader, NULL,
NULL, NULL);
if (IS_ERR(event)) {
@@ -6302,7 +6304,7 @@ SYSCALL_DEFINE5(perf_event_open,
/*
* Get the target context (task or percpu):
*/
- ctx = find_get_context(pmu, task, cpu);
+ ctx = find_get_context(pmu, task, event->cpu);
if (IS_ERR(ctx)) {
err = PTR_ERR(ctx);
goto err_alloc;
@@ -6375,20 +6377,22 @@ SYSCALL_DEFINE5(perf_event_open,
mutex_lock(&ctx->mutex);

if (move_group) {
- perf_install_in_context(ctx, group_leader, cpu);
+ perf_install_in_context(ctx, group_leader, event->cpu);
get_ctx(ctx);
list_for_each_entry(sibling, &group_leader->sibling_list,
group_entry) {
- perf_install_in_context(ctx, sibling, cpu);
+ perf_install_in_context(ctx, sibling, event->cpu);
get_ctx(ctx);
}
}

- perf_install_in_context(ctx, event, cpu);
+ perf_install_in_context(ctx, event, event->cpu);
++ctx->generation;
perf_unpin_context(ctx);
mutex_unlock(&ctx->mutex);

+ put_online_cpus();
+
event->owner = current;

mutex_lock(&current->perf_event_mutex);
@@ -6417,6 +6421,7 @@ SYSCALL_DEFINE5(perf_event_open,
err_alloc:
free_event(event);
err_task:
+ put_online_cpus();
if (task)
put_task_struct(task);
err_group_fd:
--
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


khandual at linux

May 8, 2012, 11:38 PM

Post #2 of 5 (59 views)
Permalink
Re: [PATCH 2/9] perf: Allow pmu to choose cpu on which to install event [In reply to]

On Wednesday 02 May 2012 07:37 AM, Yan, Zheng wrote:

> From: "Yan, Zheng" <zheng.z.yan [at] intel>
>
> Allow the pmu->event_init callback to change event->cpu, so pmu can
> choose cpu on which to install event.
>
> Signed-off-by: Zheng Yan <zheng.z.yan [at] intel>
> ---
> kernel/events/core.c | 13 +++++++++----
> 1 files changed, 9 insertions(+), 4 deletions(-)
>
> diff --git a/kernel/events/core.c b/kernel/events/core.c
> index 32cfc76..84911de 100644
> --- a/kernel/events/core.c
> +++ b/kernel/events/core.c
> @@ -6250,6 +6250,8 @@ SYSCALL_DEFINE5(perf_event_open,
> }
> }
>
> + get_online_cpus();

Why this protection against cpu hotplug operation ? Is this because PMU now can change event->cpu
during event initialization (specific to uncore PMU events) or this protection has always been required
for normal on-cpu HW PMU events also and we added it right now ?

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


zheng.z.yan at intel

May 9, 2012, 6:09 PM

Post #3 of 5 (59 views)
Permalink
Re: [PATCH 2/9] perf: Allow pmu to choose cpu on which to install event [In reply to]

On 05/09/2012 02:38 PM, Anshuman Khandual wrote:
> On Wednesday 02 May 2012 07:37 AM, Yan, Zheng wrote:
>
>> From: "Yan, Zheng" <zheng.z.yan [at] intel>
>>
>> Allow the pmu->event_init callback to change event->cpu, so pmu can
>> choose cpu on which to install event.
>>
>> Signed-off-by: Zheng Yan <zheng.z.yan [at] intel>
>> ---
>> kernel/events/core.c | 13 +++++++++----
>> 1 files changed, 9 insertions(+), 4 deletions(-)
>>
>> diff --git a/kernel/events/core.c b/kernel/events/core.c
>> index 32cfc76..84911de 100644
>> --- a/kernel/events/core.c
>> +++ b/kernel/events/core.c
>> @@ -6250,6 +6250,8 @@ SYSCALL_DEFINE5(perf_event_open,
>> }
>> }
>>
>> + get_online_cpus();
>
> Why this protection against cpu hotplug operation ? Is this because PMU now can change event->cpu
> during event initialization (specific to uncore PMU events) or this protection has always been required
> for normal on-cpu HW PMU events also and we added it right now ?
>
I think it's always required. Because when creating a perf event, 'cpu online' is checked by
find_get_context, the cpu can go offline after find_get_context return.

Regards
Yan, Zheng
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


khandual at linux

May 9, 2012, 8:41 PM

Post #4 of 5 (58 views)
Permalink
Re: [PATCH 2/9] perf: Allow pmu to choose cpu on which to install event [In reply to]

On Thursday 10 May 2012 06:39 AM, Yan, Zheng wrote:

> On 05/09/2012 02:38 PM, Anshuman Khandual wrote:
>> On Wednesday 02 May 2012 07:37 AM, Yan, Zheng wrote:
>>
>>> From: "Yan, Zheng" <zheng.z.yan [at] intel>
>>>
>>> Allow the pmu->event_init callback to change event->cpu, so pmu can
>>> choose cpu on which to install event.
>>>
>>> Signed-off-by: Zheng Yan <zheng.z.yan [at] intel>
>>> ---
>>> kernel/events/core.c | 13 +++++++++----
>>> 1 files changed, 9 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/kernel/events/core.c b/kernel/events/core.c
>>> index 32cfc76..84911de 100644
>>> --- a/kernel/events/core.c
>>> +++ b/kernel/events/core.c
>>> @@ -6250,6 +6250,8 @@ SYSCALL_DEFINE5(perf_event_open,
>>> }
>>> }
>>>
>>> + get_online_cpus();
>>
>> Why this protection against cpu hotplug operation ? Is this because PMU now can change event->cpu
>> during event initialization (specific to uncore PMU events) or this protection has always been required
>> for normal on-cpu HW PMU events also and we added it right now ?
>>
> I think it's always required. Because when creating a perf event, 'cpu online' is checked by
> find_get_context, the cpu can go offline after find_get_context return.

Agreed. So here the get_online_cpus()/put_online_cpus() pair solves an existing problem. Could you please
put an additional statement explaining this in the patch documentation. Thank you.


> Regards
> Yan, Zheng
>


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


a.p.zijlstra at chello

May 10, 2012, 3:56 AM

Post #5 of 5 (59 views)
Permalink
Re: [PATCH 2/9] perf: Allow pmu to choose cpu on which to install event [In reply to]

On Thu, 2012-05-10 at 09:11 +0530, Anshuman Khandual wrote:
>
> Agreed. So here the get_online_cpus()/put_online_cpus() pair solves an
> existing problem. Could you please
> put an additional statement explaining this in the patch
> documentation. Thank you.

No, make it a separate patch. If a patch does two separate things its
doing it wrong ;-)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

Linux kernel RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.