Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

Name:perf_pmu_register

Proto:int perf_pmu_register(struct pmu *pmu, const char *name, int type)

Type:int

Parameter:

TypeParameterName
struct pmu *pmu
const char *name
inttype
10283  max = -ABI
10285  mutex_lock( & pmus_lock)
10286  ret = -ENOMEM
10287  pmu_disable_count = alloc_percpu(int)
10288  If Not pmu_disable_count Then Go to unlock
10291  type = -1
10292  If Not name Then Go to skip_type
10294  name = name
10296  If type != PERF_TYPE_SOFTWARE Then
10297  If type >= 0 Then max = type
10300  ret = dr_alloc() - Allocate an ID.*@idr: IDR handle.*@ptr: Pointer to be associated with the new ID.*@start: The minimum ID (inclusive).*@end: The maximum ID (exclusive).*@gfp: Memory allocation flags.
10301  If ret < 0 Then Go to free_pdc
10304  WARN_ON(type >= 0 && ret != type)
10306  type = ret
10308  type = type
10310  If pmu_bus_running Then
10311  ret = pmu_dev_alloc(pmu)
10312  If ret Then Go to free_idr
10316  skip_type :
10317  If task_ctx_nr == perf_hw_context Then
10318  hw_context_taken = 0
10325  If WARN_ON_ONCE(hw_context_taken && !(various common per-pmu feature flags & PERF_PMU_CAP_HETEROGENEOUS_CPUS)) Then task_ctx_nr = perf_invalid_context
10329  hw_context_taken = 1
10332  pmu_cpu_context = Ensures all contexts with the same task_ctx_nr have the same* pmu_cpu_context too.
10333  If pmu_cpu_context Then Go to got_cpu_context
10336  ret = -ENOMEM
10337  pmu_cpu_context = alloc_percpu(structperf_cpu_context)
10338  If Not pmu_cpu_context Then Go to free_dev
10341  for_each_possible_cpu(cpu)
10344  cpuctx = per_cpu_ptr(pmu_cpu_context, cpu)
10345  Initialize the perf_event context in a task_struct:
10346  lockdep_set_class( & Protect the list of events. Locking either mutex or lock* is sufficient to ensure the list doesn't change; to change* the list you need to lock both the mutex and the spinlock., & cpuctx_mutex)
10347  lockdep_set_class( & Protect the states of the events in the list,* nr_active, and the list:, & cpuctx_lock)
10348  pmu = pmu
10349  online = pumask_test_cpu - test for a cpu in a cpumask*@cpu: cpu number (< nr_cpu_ids)*@cpumask: the cpumask pointer* Returns 1 if @cpu is set in @cpumask, else returns 0
10351  __perf_mux_hrtimer_init(cpuctx, cpu)
10354  got_cpu_context :
10355  If Not start_txn Then
10356  If pmu_enable Then
10365  Else
10372  If Not pmu_enable Then
10373  pmu_enable = perf_pmu_nop_void
10374  pmu_disable = perf_pmu_nop_void
10377  If Not check_period Then check_period = perf_event_nop_int
10380  If Not event_idx Then event_idx = perf_event_idx_default
10388  If type == PERF_TYPE_SOFTWARE || Not name Then list_add_rcu - add a new entry to rcu-protected list*@new: new entry to be added*@head: list head to add it after* Insert a new entry after the specified head
10390  Else list_add_tail_rcu - add a new entry to rcu-protected list*@new: new entry to be added*@head: list head to add it before* Insert a new entry before the specified head
10393  atomic_set( & < 0: cpu; > 0: tsk , 0)
10394  ret = 0
10395  unlock :
10396  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.
10398  Return ret
10400  free_dev :
10401  device_del(dev)
10402  put_device(dev)
10404  free_idr :
10405  If type != PERF_TYPE_SOFTWARE Then dr_remove() - Remove an ID from the IDR
10408  free_pdc :
10409  free previously allocated percpu memory
10410  Go to unlock
Caller
NameDescribe
perf_event_init
init_hw_breakpoint