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.

Dependency Surface

Detected Declarations

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

Implementation Notes