Subject: perf: Clarify perf_event_exit_task_context() From: Peter Zijlstra Date: Mon Jul 15 13:39:03 CEST 2019 The variables in perf_event_exit_task_context() are all called 'child' even though it must be current, this is confusing, apply: s/child/task/ Signed-off-by: Peter Zijlstra (Intel) --- kernel/events/core.c | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -11434,15 +11434,15 @@ perf_event_exit_event(struct perf_event put_event(parent_event); } -static void perf_event_exit_task_context(struct task_struct *child, int ctxn) +static void perf_event_exit_task_context(struct task_struct *task, int ctxn) { - struct perf_event_context *child_ctx, *clone_ctx = NULL; - struct perf_event *child_event, *next; + struct perf_event_context *task_ctx, *clone_ctx = NULL; + struct perf_event *task_event, *next; - WARN_ON_ONCE(child != current); + WARN_ON_ONCE(task != current); - child_ctx = perf_pin_task_context(child, ctxn); - if (!child_ctx) + task_ctx = perf_pin_task_context(task, ctxn); + if (!task_ctx) return; /* @@ -11455,27 +11455,27 @@ static void perf_event_exit_task_context * without ctx::mutex (it cannot because of the move_group double mutex * lock thing). See the comments in perf_install_in_context(). */ - mutex_lock(&child_ctx->mutex); + mutex_lock(&task_ctx->mutex); /* * In a single ctx::lock section, de-schedule the events and detach the * context from the task such that we cannot ever get it scheduled back * in. */ - raw_spin_lock_irq(&child_ctx->lock); - task_ctx_sched_out(__get_cpu_context(child_ctx), child_ctx, EVENT_ALL); + raw_spin_lock_irq(&task_ctx->lock); + task_ctx_sched_out(__get_cpu_context(task_ctx), task_ctx, EVENT_ALL); /* * Now that the context is inactive, destroy the task <-> ctx relation * and mark the context dead. */ - RCU_INIT_POINTER(child->perf_event_ctxp[ctxn], NULL); - put_ctx(child_ctx); /* cannot be last */ - WRITE_ONCE(child_ctx->task, TASK_TOMBSTONE); + RCU_INIT_POINTER(task->perf_event_ctxp[ctxn], NULL); + put_ctx(task_ctx); /* cannot be last */ + WRITE_ONCE(task_ctx->task, TASK_TOMBSTONE); put_task_struct(current); /* cannot be last */ - clone_ctx = unclone_ctx(child_ctx); - raw_spin_unlock_irq(&child_ctx->lock); + clone_ctx = unclone_ctx(task_ctx); + raw_spin_unlock_irq(&task_ctx->lock); if (clone_ctx) put_ctx(clone_ctx); @@ -11485,14 +11485,14 @@ static void perf_event_exit_task_context * won't get any samples after PERF_RECORD_EXIT. We can however still * get a few PERF_RECORD_READ events. */ - perf_event_task(child, child_ctx, 0); + perf_event_task(task, task_ctx, 0); - list_for_each_entry_safe(child_event, next, &child_ctx->event_list, event_entry) - perf_event_exit_event(child_event, child_ctx, child); + list_for_each_entry_safe(task_event, next, &task_ctx->event_list, event_entry) + perf_event_exit_event(task_event, task_ctx, task); - mutex_unlock(&child_ctx->mutex); + mutex_unlock(&task_ctx->mutex); - put_ctx(child_ctx); + put_ctx(task_ctx); } /*