tools/tracing/rtla/src/utils.c
Source file repositories/reference/linux-study-clean/tools/tracing/rtla/src/utils.c
File Facts
- System
- Linux kernel
- Corpus path
tools/tracing/rtla/src/utils.c- Extension
.c- Size
- 22513 bytes
- Lines
- 1070
- 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
cpuidle.hdirent.hstdarg.hstdlib.hstring.hunistd.hctype.herrno.hfcntl.hsched.hstdio.hlimits.hcommon.h
Detected Declarations
function err_msgfunction debug_msgfunction fatalfunction get_llong_from_strfunction get_durationfunction parse_cpu_setfunction parse_stack_formatfunction parse_seconds_durationfunction match_time_unitfunction parse_ns_durationfunction syscall_sched_setattrfunction __set_sched_attrfunction procfs_is_workload_pidfunction set_comm_sched_attrfunction get_long_ns_after_colonfunction get_long_after_colonfunction parse_priofunction set_cpu_dma_latencyfunction save_cpu_idle_disable_statefunction restore_cpu_idle_disable_statefunction free_cpu_idle_disable_statesfunction deepest_statefunction find_mountfunction get_self_cgroupfunction open_cgroup_procsfunction set_pid_cgroupfunction set_comm_cgroupfunction auto_house_keepingfunction strtoifunction fatal_alloc
Annotated Snippet
if (*p == '-') {
p++;
end_cpu = atoi(p);
if (end_cpu < cpu || (!end_cpu && *p != '0') || end_cpu >= nr_cpus)
goto err;
while (isdigit(*p))
p++;
} else
end_cpu = cpu;
if (cpu == end_cpu) {
debug_msg("cpu_set: adding cpu %d\n", cpu);
CPU_SET(cpu, set);
} else {
for (i = cpu; i <= end_cpu; i++) {
debug_msg("cpu_set: adding cpu %d\n", i);
CPU_SET(i, set);
}
}
if (*p == ',')
p++;
}
return 0;
err:
debug_msg("Error parsing the cpu set %s\n", cpu_list);
return 1;
}
/*
* parse_stack_format - parse the stack format
*
* Return: the stack format on success, -1 otherwise.
*/
int parse_stack_format(char *arg)
{
if (!strcmp(arg, "truncate"))
return STACK_FORMAT_TRUNCATE;
if (!strcmp(arg, "skip"))
return STACK_FORMAT_SKIP;
if (!strcmp(arg, "full"))
return STACK_FORMAT_FULL;
debug_msg("Error parsing the stack format %s\n", arg);
return -1;
}
/*
* parse_duration - parse duration with s/m/h/d suffix converting it to seconds
*/
long parse_seconds_duration(char *val)
{
char *end;
long t;
t = strtol(val, &end, 10);
if (end) {
switch (*end) {
case 's':
case 'S':
break;
case 'm':
case 'M':
t *= 60;
break;
case 'h':
case 'H':
t *= 60 * 60;
break;
case 'd':
case 'D':
t *= 24 * 60 * 60;
break;
}
}
return t;
}
/*
* match_time_unit - check if str starts with unit followed by end-of-string or ':'
*
* This allows the time unit parser to work both in standalone duration strings
* like "100ms" and in colon-delimited SCHED_DEADLINE specifications like
* "d:10ms:100ms", while still rejecting malformed input like "100msx".
*/
static bool match_time_unit(const char *str, const char *unit)
Annotation
- Immediate include surface: `cpuidle.h`, `dirent.h`, `stdarg.h`, `stdlib.h`, `string.h`, `unistd.h`, `ctype.h`, `errno.h`.
- Detected declarations: `function err_msg`, `function debug_msg`, `function fatal`, `function get_llong_from_str`, `function get_duration`, `function parse_cpu_set`, `function parse_stack_format`, `function parse_seconds_duration`, `function match_time_unit`, `function parse_ns_duration`.
- 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.