Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:kernel\events\core.c Create Date:2022-07-28 13:41:32
Last Modify:2022-05-20 07:50:19 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:Inherit an event from parent task to child task.* Returns:* - valid pointer on success* - NULL for orphaned events* - IS_ERR() on error

Proto:static struct perf_event *inherit_event(struct perf_event *parent_event, struct task_struct *parent, struct perf_event_context *parent_ctx, struct task_struct *child, struct perf_event *group_leader, struct perf_event_context *child_ctx)

Type:struct perf_event

Parameter:

TypeParameterName
struct perf_event *parent_event
struct task_struct *parent
struct perf_event_context *parent_ctx
struct task_struct *child
struct perf_event *group_leader
struct perf_event_context *child_ctx
12067  parent_state = state
12077  If parent Then parent_event = parent
12080  child_event = Allocate and initialize an event structure
12085  If IS_ERR(child_event) Then Return child_event
12089  If attach_state & PERF_ATTACH_TASK_DATA && Not pmu specific data Then
12091  pmu = pmu
12093  pmu specific data = kzalloc - allocate memory. The memory is set to zero.*@size: how many bytes of memory are required.*@flags: the type of memory to allocate (see kmalloc).
12095  If Not pmu specific data Then
12097  Return ERR_PTR( - ENOMEM)
12107  mutex_lock( & child_mutex)
12108  If is_orphaned_event(parent_event) || Not atomic_long_inc_not_zero( & refcount) Then
12110  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.
12112  Used to free events which have a known refcount of 1, such as in error paths* where the event isn't exposed yet and inherited events.
12113  Return NULL
12116  get_ctx(child_ctx)
12123  If parent_state >= PERF_EVENT_STATE_INACTIVE Then state = PERF_EVENT_STATE_INACTIVE
12125  Else state = PERF_EVENT_STATE_OFF
12128  If freq Then
12129  sample_period = sample_period
12130  hwc = hw
12132  sample_period = sample_period
12133  last_period = sample_period
12135  local64_set( & period_left, sample_period)
12138  ctx = child_ctx
12139  overflow_handler = overflow_handler
12140  overflow_handler_context = overflow_handler_context
12146  Called at perf_event creation and when events are attached/detached from a* group.
12147  perf_event__id_header_size(child_event)
12152  raw_spin_lock_irqsave( & Protect the states of the events in the list,* nr_active, and the list:, flags)
12153  add_event_to_ctx(child_event, child_ctx)
12154  raw_spin_unlock_irqrestore( & Protect the states of the events in the list,* nr_active, and the list:, flags)
12159  list_add_tail - add a new entry*@new: new entry to be added*@head: list head to add it before* Insert a new entry before the specified head.* This is useful for implementing queues.
12160  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.
12162  Return child_event
Caller
NameDescribe
inherit_groupInherits an event group.* This will quietly suppress orphaned events; !inherit_event() is not an error.* This matches with perf_event_release_kernel() removing all child events.* Returns:* - 0 on success* - <0 on error