Re: [PATCH 03/12] perf: add perf_event_task_migrate()

Tejun Heo
2010-05-05T05:17:38Z

Hello,

On 05/05/2010 07:08 AM, Frederic Weisbecker wrote:
>> /*
>> + * Called from scheduler set_task_cpu() to notify migration events.
>> + * If the task is moving to a different cpu, generate a migration sw
>> + * event.
>> + */
>> +void perf_event_task_migrate(struct task_struct *task, int new_cpu)
>> +{
>> + if (task_cpu(task) != new_cpu)
>> + perf_sw_event(PERF_COUNT_SW_CPU_MIGRATIONS, 1, 1, NULL, 0);
>> +}
>
> This needs to be static and inline (I haven't seem external users in this
> patchset).

Hmm... after the last patch, this one becomes a TP probe function
which can't be inlined.

> And we want it to be inlined because we save the caller address and the frame
> pointer from perf_sw_event(), and a new level of call is not wanted here.

Oh I see. So, to use it with TP, I would need increase the @skip
parameter to perf_fetch_caller_regs() somehow, right? Also, it
probably would be a good idea to add a comment w/ big fat warning to
perf_sw_event().

>> @@ -2084,11 +2084,10 @@ void set_task_cpu(struct task_struct *p, unsigned int new_cpu)
>> #endif
>>
>> trace_sched_migrate_task(p, new_cpu);
>> + perf_event_task_migrate(p, new_cpu);
>>
>> - if (task_cpu(p) != new_cpu) {
>> + if (task_cpu(p) != new_cpu)
>
> In fact why not moving both tracing calls under this check.
> This is going to fix the migrate trace event that gets called
> even on "spurious" migrations, and you avoid the duplicate check
> in the perf callback.

Yeah, that would be my preferred choice too. I just didn't know that
could be changed. Cool. I'll.

Thanks.

--
tejun