tools/accounting/delaytop.c
Source file repositories/reference/linux-study-clean/tools/accounting/delaytop.c
File Facts
- System
- Linux kernel
- Corpus path
tools/accounting/delaytop.c- Extension
.c- Size
- 31548 bytes
- Lines
- 1146
- 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
stdio.hstdlib.hstring.herrno.hunistd.hfcntl.hgetopt.hsignal.htime.hdirent.hctype.hstdbool.hsys/types.hsys/stat.hsys/socket.hsys/select.htermios.hlimits.hlinux/genetlink.hlinux/taskstats.hlinux/cgroupstats.hstddef.h
Detected Declarations
struct psi_statsstruct task_infostruct container_statsstruct field_descstruct configfunction enable_raw_modefunction disable_raw_modefunction display_available_fieldsfunction usagefunction parse_argsfunction set_mem_delay_totalfunction set_mem_countfunction create_nl_socketfunction send_cmdfunction get_family_idfunction read_psi_statsfunction read_commfunction fetch_and_fill_task_infofunction get_task_delaysfunction average_msfunction compare_tasksfunction sort_tasksfunction get_container_statsfunction display_resultsfunction check_for_keypressfunction toggle_display_modefunction handle_keypressfunction main
Annotated Snippet
struct psi_stats {
double cpu_some_avg10, cpu_some_avg60, cpu_some_avg300;
unsigned long long cpu_some_total;
double cpu_full_avg10, cpu_full_avg60, cpu_full_avg300;
unsigned long long cpu_full_total;
double memory_some_avg10, memory_some_avg60, memory_some_avg300;
unsigned long long memory_some_total;
double memory_full_avg10, memory_full_avg60, memory_full_avg300;
unsigned long long memory_full_total;
double io_some_avg10, io_some_avg60, io_some_avg300;
unsigned long long io_some_total;
double io_full_avg10, io_full_avg60, io_full_avg300;
unsigned long long io_full_total;
double irq_full_avg10, irq_full_avg60, irq_full_avg300;
unsigned long long irq_full_total;
};
/* Task delay information structure */
struct task_info {
int pid;
int tgid;
char command[TASK_COMM_LEN];
unsigned long long cpu_count;
unsigned long long cpu_delay_total;
unsigned long long blkio_count;
unsigned long long blkio_delay_total;
unsigned long long swapin_count;
unsigned long long swapin_delay_total;
unsigned long long freepages_count;
unsigned long long freepages_delay_total;
unsigned long long thrashing_count;
unsigned long long thrashing_delay_total;
unsigned long long compact_count;
unsigned long long compact_delay_total;
unsigned long long wpcopy_count;
unsigned long long wpcopy_delay_total;
unsigned long long irq_count;
unsigned long long irq_delay_total;
unsigned long long mem_count;
unsigned long long mem_delay_total;
};
/* Container statistics structure */
struct container_stats {
int nr_sleeping; /* Number of sleeping processes */
int nr_running; /* Number of running processes */
int nr_stopped; /* Number of stopped processes */
int nr_uninterruptible; /* Number of uninterruptible processes */
int nr_io_wait; /* Number of processes in IO wait */
};
/* Delay field structure */
struct field_desc {
const char *name; /* Field name for cmdline argument */
const char *cmd_char; /* Interactive command */
unsigned long total_offset; /* Offset of total delay in task_info */
unsigned long count_offset; /* Offset of count in task_info */
size_t supported_modes; /* Supported display modes */
};
/* Program settings structure */
struct config {
int delay; /* Update interval in seconds */
int iterations; /* Number of iterations, 0 == infinite */
int max_processes; /* Maximum number of processes to show */
int output_one_time; /* Output once and exit */
int monitor_pid; /* Monitor specific PID */
char *container_path; /* Path to container cgroup */
const struct field_desc *sort_field; /* Current sort field */
size_t display_mode; /* Current display mode */
};
/* Global variables */
static struct config cfg;
static struct psi_stats psi;
static struct task_info tasks[MAX_TASKS];
static int task_count;
static int running = 1;
static struct container_stats container_stats;
static const struct field_desc sort_fields[] = {
SORT_FIELD(cpu, c, MODE_DEFAULT),
SORT_FIELD(blkio, i, MODE_DEFAULT),
SORT_FIELD(irq, q, MODE_DEFAULT),
SORT_FIELD(mem, m, MODE_DEFAULT | MODE_MEMVERBOSE),
SORT_FIELD(swapin, s, MODE_MEMVERBOSE),
SORT_FIELD(freepages, r, MODE_MEMVERBOSE),
SORT_FIELD(thrashing, t, MODE_MEMVERBOSE),
SORT_FIELD(compact, p, MODE_MEMVERBOSE),
SORT_FIELD(wpcopy, w, MODE_MEMVERBOSE),
END_FIELD
Annotation
- Immediate include surface: `stdio.h`, `stdlib.h`, `string.h`, `errno.h`, `unistd.h`, `fcntl.h`, `getopt.h`, `signal.h`.
- Detected declarations: `struct psi_stats`, `struct task_info`, `struct container_stats`, `struct field_desc`, `struct config`, `function enable_raw_mode`, `function disable_raw_mode`, `function display_available_fields`, `function usage`, `function parse_args`.
- 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.