函数逻辑报告 |
Source Code:kernel\events\core.c |
Create Date:2022-07-27 15:00:49 |
Last Modify:2022-05-20 07:50:19 | Copyright©Brick |
首页 | 函数Tree |
注解内核,赢得工具 | 下载SCCT | English |
函数名称:Allocate and initialize an event structure
函数原型:static struct perf_event *perf_event_alloc(struct perf_event_attr *attr, int cpu, struct task_struct *task, struct perf_event *group_leader, struct perf_event *parent_event, perf_overflow_handler_t overflow_handler, void *context, int cgroup_fd)
返回类型:struct perf_event
参数:
类型 | 参数 | 名称 |
---|---|---|
struct perf_event_attr * | attr | |
int | cpu | |
struct task_struct * | task | |
struct perf_event * | group_leader | |
struct perf_event * | parent_event | |
perf_overflow_handler_t | overflow_handler | |
void * | context | |
int | cgroup_fd |
10698 | 如果非group_leader则group_leader等于event |
10701 | mutex_init - initialize the mutex*@mutex: the mutex to be initialized* Initialize the mutex to unlocked state.* It is not allowed to initialize an already locked mutex.( & child_mutex) |
10702 | 初始化链表头 |
10704 | 初始化链表头 |
10705 | 初始化链表头 |
10706 | 初始化链表头 |
10708 | 初始化链表头 |
10709 | 初始化链表头 |
10710 | 初始化链表头 |
10711 | INIT_HLIST_NODE( & hlist_entry) |
10714 | init_waitqueue_head( & waitq) |
10715 | pending_disable等于负1 |
10716 | init_irq_work( & pending, perf_pending_event) |
10718 | mutex_init - initialize the mutex*@mutex: the mutex to be initialized* Initialize the mutex to unlocked state.* It is not allowed to initialize an already locked mutex.( & mmap_mutex) |
10719 | raw_spin_lock_init( & lock) |
10721 | atomic_long_set( & refcount, 1) |
10724 | group_leader等于group_leader |
10725 | pmu = NULL |
10726 | oncpu等于负1 |
10728 | parent等于parent_event |
10730 | ns等于get_pid_ns(取进程的空间) |
10731 | id等于atomic64_inc_return( & perf_event_id) |
10733 | state等于PERF_EVENT_STATE_INACTIVE |
10735 | 如果task则 |
10736 | attach_state等于PERF_ATTACH_TASK |
10742 | target等于get_task_struct(task) |
10745 | clock等于local_clock |
10746 | 如果parent_event则clock等于clock |
10749 | 如果非overflow_handler且parent_event则 |
10750 | overflow_handler等于overflow_handler |
10751 | context等于overflow_handler_context |
10764 | 如果overflow_handler则 |
10765 | overflow_handler等于overflow_handler |
10766 | overflow_handler_context等于context |
10767 | 否则如果is_write_backward(event)则 |
10769 | overflow_handler_context = NULL |
10770 | 否则 |
10772 | overflow_handler_context = NULL |
10777 | pmu = NULL |
10780 | sample_period等于sample_period |
10781 | 如果use freq, not period 且sample_freq则sample_period等于1 |
10783 | last_period等于sample_period |
10785 | local64_set( & period_left, sample_period) |
10791 | 如果children inherit it 且sample_type按位与PERF_SAMPLE_READ则转到:err_ns |
10794 | 如果非has_branch_stack(event)则branch_sample_type等于0 |
10797 | 如果cgroup_fd不等于负1则 |
10798 | err等于perf_cgroup_connect(cgroup_fd, event, attr, group_leader) |
10803 | pmu等于perf_init_event(event) |
10804 | 如果是错误则 |
10813 | 如果task_ctx_nr恒等于perf_invalid_context且cgroup_fd不等于负1则 |
10820 | err等于负EOPNOTSUPP |
10821 | 转到:err_pmu |
10824 | err等于The following implement mutual exclusion of events on "exclusive" pmus* (PERF_PMU_CAP_EXCLUSIVE) |
10828 | 如果has_addr_filter(event)则 |
10829 | addr_filter_ranges等于分配数组内存并置零 |
10832 | 如果非addr_filter_ranges则 |
10834 | 转到:err_per_task |
10841 | 如果parent则 |
10842 | ifh等于perf_event_addr_filters(event) |
10845 | 内存复制(addr_filter_ranges, addr_filter_ranges, umber of address filters this PMU can do * sizeof(structperf_addr_filter_range)) |
10848 | raw_spin_unlock_irq( & lock) |
10852 | addr_filters_gen等于1 |
10855 | 如果非parent则 |
10856 | 如果sample_type按位与PERF_SAMPLE_CALLCHAIN则 |
10857 | err等于get_callchain_buffers(sample_max_stack) |
10858 | 如果err则转到:err_addr_filters |
10863 | err等于security_perf_event_alloc(event) |
10864 | 如果err则转到:err_callchain_buffer |
10868 | account_event(event) |
10870 | 返回:event |
10872 | err_callchain_buffer : |
10873 | 如果非parent则 |
10874 | 如果sample_type按位与PERF_SAMPLE_CALLCHAIN则put_callchain_buffers() |
10877 | err_addr_filters : |
10878 | kfree(addr_filter_ranges) |
10880 | err_per_task : |
10881 | exclusive_event_destroy(event) |
10883 | err_pmu : |
10886 | module_put(module) |
10887 | err_ns : |
10888 | 如果is_cgroup_event(event)则perf_detach_cgroup(event) |
10890 | 如果ns则put_pid_ns(ns) |
10892 | 如果target则put_task_struct(target) |
10896 | 返回:错误号 |
名称 | 描述 |
---|---|
perf_event_create_kernel_counter | perf_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) |
inherit_event | Inherit an event from parent task to child task.* Returns:* - valid pointer on success* - NULL for orphaned events* - IS_ERR() on error |
源代码转换工具 开放的插件接口 | X |
---|---|
支持:c/c++/esqlc/java Oracle/Informix/Mysql 插件可实现:逻辑报告 代码生成和批量转换代码 |