tools/perf/util/thread.h
Source file repositories/reference/linux-study-clean/tools/perf/util/thread.h
File Facts
- System
- Linux kernel
- Corpus path
tools/perf/util/thread.h- Extension
.h- Size
- 9866 bytes
- Lines
- 378
- 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
linux/refcount.hlinux/list.hstdio.hunistd.hsys/types.hsrccode.hsymbol_conf.hstrlist.hintlist.hrwsem.hcallchain.hinternal/rc_check.h
Detected Declarations
struct addr_locationstruct mapstruct perf_record_namespacesstruct thread_stackstruct unwind_libunwind_opsstruct lbr_stitchstruct machinestruct namespacesstruct commfunction __thread__zputfunction thread__set_commfunction thread__set_mapsfunction thread__pidfunction thread__set_pidfunction thread__tidfunction thread__set_tidfunction thread__ppidfunction thread__set_ppidfunction thread__cpufunction thread__set_cpufunction thread__guest_cpufunction thread__set_guest_cpufunction thread__set_exitedfunction thread__comm_setfunction thread__set_comm_setfunction thread__var_comm_lenfunction thread__set_comm_lenfunction thread__namespaces_list_emptyfunction thread__db_idfunction thread__set_db_idfunction thread__set_privfunction thread__set_tsfunction thread__filterfunction thread__set_filterfunction thread__filter_entry_depthfunction thread__set_filter_entry_depthfunction thread__set_e_machinefunction thread__e_flagsfunction thread__set_e_flagsfunction thread__lbr_stitch_enablefunction thread__set_lbr_stitch_enablefunction thread__set_lbr_stitchfunction thread__is_filtered
Annotated Snippet
struct lbr_stitch {
struct list_head lists;
struct list_head free_lists;
struct perf_sample prev_sample;
struct callchain_cursor_node *prev_lbr_cursor;
unsigned int prev_lbr_cursor_size;
};
DECLARE_RC_STRUCT(thread) {
/** @maps: mmaps associated with this thread. */
struct maps *maps;
pid_t pid_; /* Not all tools update this */
/** @tid: thread ID number unique to a machine. */
pid_t tid;
/** @ppid: parent process of the process this thread belongs to. */
pid_t ppid;
int cpu;
int guest_cpu; /* For QEMU thread */
refcount_t refcnt;
/**
* @exited: Has the thread had an exit event. Such threads are usually
* removed from the machine's threads but some events/tools require
* access to dead threads.
*/
bool exited;
bool comm_set;
int comm_len;
struct list_head namespaces_list;
struct rw_semaphore namespaces_lock;
struct list_head comm_list;
struct rw_semaphore comm_lock;
u64 db_id;
void *priv;
struct thread_stack *ts;
struct nsinfo *nsinfo;
struct srccode_state srccode_state;
bool filter;
int filter_entry_depth;
/**
* @e_flags: The ELF EF_* associated with the thread. Valid if e_machine != EM_NONE.
*/
uint16_t e_flags;
/**
* @e_machine: The ELF EM_* associated with the thread. EM_NONE if not
* computed.
*/
uint16_t e_machine;
/* LBR call stack stitch */
bool lbr_stitch_enable;
struct lbr_stitch *lbr_stitch;
};
struct machine;
struct namespaces;
struct comm;
struct thread *thread__new(pid_t pid, pid_t tid);
int thread__init_maps(struct thread *thread, struct machine *machine);
void thread__delete(struct thread *thread);
void thread__set_priv_destructor(void (*destructor)(void *priv));
struct thread *thread__get(struct thread *thread);
void thread__put(struct thread *thread);
static inline void __thread__zput(struct thread **thread)
{
thread__put(*thread);
*thread = NULL;
}
#define thread__zput(thread) __thread__zput(&thread)
struct namespaces *thread__namespaces(struct thread *thread);
int thread__set_namespaces(struct thread *thread, u64 timestamp,
struct perf_record_namespaces *event);
int __thread__set_comm(struct thread *thread, const char *comm, u64 timestamp,
bool exec);
static inline int thread__set_comm(struct thread *thread, const char *comm,
u64 timestamp)
{
return __thread__set_comm(thread, comm, timestamp, false);
}
int thread__set_comm_from_proc(struct thread *thread);
int thread__comm_len(struct thread *thread);
struct comm *thread__comm(struct thread *thread);
Annotation
- Immediate include surface: `linux/refcount.h`, `linux/list.h`, `stdio.h`, `unistd.h`, `sys/types.h`, `srccode.h`, `symbol_conf.h`, `strlist.h`.
- Detected declarations: `struct addr_location`, `struct map`, `struct perf_record_namespaces`, `struct thread_stack`, `struct unwind_libunwind_ops`, `struct lbr_stitch`, `struct machine`, `struct namespaces`, `struct comm`, `function __thread__zput`.
- 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.