tools/perf/util/evlist.c
Source file repositories/reference/linux-study-clean/tools/perf/util/evlist.c
File Facts
- System
- Linux kernel
- Corpus path
tools/perf/util/evlist.c- Extension
.c- Size
- 62928 bytes
- Lines
- 2696
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: implementation source
- Status
- source implementation candidate
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
api/fs/fs.herrno.hinttypes.hpoll.hcpumap.hutil/mmap.hthread_map.htarget.hdwarf-regs.hevlist.hevsel.hrecord.hdebug.hunits.hbpf_counter.hinternal/lib.haffinity.h../perf.hasm/bug.hbpf-event.hutil/event.hutil/string2.hutil/perf_api_probe.hutil/evsel_fprintf.hutil/pmu.hutil/sample.hutil/bpf-filter.hutil/stat.hutil/util.hutil/env.hutil/intel-tpebs.hutil/metricgroup.h
Detected Declarations
struct event_enable_timestruct event_enable_timerenum actionfunction evlist__initfunction evlist__set_id_posfunction evlist__update_id_posfunction evlist__purgefunction evlist__for_each_entry_safefunction evlist__exitfunction evlist__deletefunction evlist__addfunction evlist__removefunction evlist__splice_list_tailfunction __evlist__for_each_entry_safefunction __evlist__for_each_entry_safefunction __evlist__set_tracepoints_handlersfunction evlist__set_leaderfunction evlist__add_dummyfunction evlist__for_each_entryfunction evlist__add_newtpfunction evlist__use_affinityfunction evlist__for_each_entryfunction evlist_cpu_iterator__initfunction evlist_cpu_iterator__exitfunction evlist_cpu_iterator__nextfunction evsel__strcmpfunction evlist__is_enabledfunction evlist__for_each_entryfunction __evlist__disablefunction evlist__for_each_cpufunction evlist__for_each_entryfunction evlist__disablefunction evlist__disable_non_dummyfunction evlist__disable_evselfunction __evlist__enablefunction evlist__for_each_cpufunction evlist__enablefunction evlist__enable_non_dummyfunction evlist__enable_evselfunction evlist__toggle_enablefunction evlist__add_pollfdfunction evlist__filter_pollfdfunction evlist__add_wakeup_eventfdfunction evlist__pollfunction evlist__event2idfunction hlist_for_each_entryfunction evlist__set_pausedfunction evlist__pause
Annotated Snippet
struct event_enable_time {
int start;
int end;
};
static int parse_event_enable_time(const char *str, struct event_enable_time *range, bool first)
{
const char *fmt = first ? "%u - %u %n" : " , %u - %u %n";
int ret, start, end, n;
ret = sscanf(str, fmt, &start, &end, &n);
if (ret != 2 || end <= start)
return -EINVAL;
if (range) {
range->start = start;
range->end = end;
}
return n;
}
static ssize_t parse_event_enable_times(const char *str, struct event_enable_time *range)
{
int incr = !!range;
bool first = true;
ssize_t ret, cnt;
for (cnt = 0; *str; cnt++) {
ret = parse_event_enable_time(str, range, first);
if (ret < 0)
return ret;
/* Check no overlap */
if (!first && range && range->start <= range[-1].end)
return -EINVAL;
str += ret;
range += incr;
first = false;
}
return cnt;
}
/**
* struct event_enable_timer - control structure for perf record -D/--delay.
* @evlist: event list
* @times: time ranges that events are enabled (N.B. this is also accessed as an
* array of int)
* @times_cnt: number of time ranges
* @timerfd: timer file descriptor
* @pollfd_pos: position in @evlist array of file descriptors to poll (fdarray)
* @times_step: current position in (int *)@times)[],
* refer event_enable_timer__process()
*
* Note, this structure is only used when there are time ranges, not when there
* is only an initial delay.
*/
struct event_enable_timer {
struct evlist *evlist;
struct event_enable_time *times;
size_t times_cnt;
int timerfd;
int pollfd_pos;
size_t times_step;
};
static int str_to_delay(const char *str)
{
char *endptr;
long d;
d = strtol(str, &endptr, 10);
if (*endptr || d > INT_MAX || d < -1)
return 0;
return d;
}
int evlist__parse_event_enable_time(struct evlist *evlist, struct record_opts *opts,
const char *str, int unset)
{
enum fdarray_flags flags = fdarray_flag__nonfilterable | fdarray_flag__non_perf_event;
struct event_enable_timer *eet;
ssize_t times_cnt;
ssize_t ret;
int err;
if (unset)
return 0;
opts->target.initial_delay = str_to_delay(str);
if (opts->target.initial_delay)
return 0;
Annotation
- Immediate include surface: `api/fs/fs.h`, `errno.h`, `inttypes.h`, `poll.h`, `cpumap.h`, `util/mmap.h`, `thread_map.h`, `target.h`.
- Detected declarations: `struct event_enable_time`, `struct event_enable_timer`, `enum action`, `function evlist__init`, `function evlist__set_id_pos`, `function evlist__update_id_pos`, `function evlist__purge`, `function evlist__for_each_entry_safe`, `function evlist__exit`, `function evlist__delete`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.