函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:kernel\events\core.c Create Date:2022-07-27 14:53:48
Last Modify:2022-05-20 07:50:19 Copyright©Brick
首页 函数Tree
注解内核,赢得工具下载SCCTEnglish

函数名称:Returns a matching context with refcount and pincount.

函数原型:static struct perf_event_context *find_get_context(struct pmu *pmu, struct task_struct *task, struct perf_event *event)

返回类型:struct perf_event_context

参数:

类型参数名称
struct pmu *pmu
struct task_struct *task
struct perf_event *event
4269  struct perf_event_context * ctx, * clone_ctx = NULL
4271  void * task_ctx_data = NULL
4274  cpu等于cpu
4276  如果非task
4278  err等于perf_allow_cpu( & attr)
4279  如果err则返回:错误号
4282  cpuctx等于per_cpu_ptr(pmu_cpu_context, cpu)
4283  ctx等于ctx
4284  get_ctx(ctx)
4285  pin_count先自加
4287  返回:ctx
4290  err等于负EINVAL
4291  ctxn等于task_ctx_nr
4292  如果ctxn小于0则转到:errout
4295  如果attach_state按位与PERF_ATTACH_TASK_DATA
4296  task_ctx_data等于分配内存并置零
4297  如果非task_ctx_data
4298  err等于负ENOMEM
4299  转到:errout
4303  retry :
4304  ctx等于Get the perf_event_context for a task and lock it.* This has to cope with with the fact that until it is locked,* the context could get moved to another task.
4305  如果ctx
4306  clone_ctx等于This must be done under the ctx->lock, such as to serialize against* context_equiv(), therefore we cannot call put_ctx() since that might end up* calling scheduler related locks and ctx->lock nests inside those.
4307  pin_count先自加
4309  如果task_ctx_data且非pmu specific data
4311  task_ctx_data = NULL
4313  raw_spin_unlock_irqrestore( & Protect the states of the events in the list,* nr_active, and the list:, flags)
4315  如果clone_ctxput_ctx(clone_ctx)
4317  否则
4318  ctx等于alloc_perf_context(pmu, task)
4319  err等于负ENOMEM
4320  如果非ctx则转到:errout
4323  如果task_ctx_data
4325  task_ctx_data = NULL
4328  err等于0
4329  mutex_lock( & perf_event_mutex)
4334  如果任务标志按位与Getting shut down err等于负ESRCH
4336  否则如果perf_event_ctxp[ctxn]则err等于负EAGAIN
4338  否则
4339  get_ctx(ctx)
4340  pin_count先自加
4343  mutex_unlock - release the mutex*@lock: the mutex to be released* Unlock a mutex that has been locked by this task previously.* This function must not be used in interrupt context. Unlocking* of a not locked mutex is not allowed.
4346  put_ctx(ctx)
4348  如果err恒等于负EAGAIN则转到:retry
4350  转到:errout
4354  kfree(task_ctx_data)
4355  返回:ctx
4357  errout :
4358  kfree(task_ctx_data)
4359  返回:错误号
调用者
名称描述
perf_event_create_kernel_counterperf_event_create_kernel_counter*@attr: attributes of the counter to create*@cpu: cpu in which the counter is bound*@task: task to profile (NULL for percpu)