include/linux/trace_seq.h
Source file repositories/reference/linux-study-clean/include/linux/trace_seq.h
File Facts
- System
- Linux kernel
- Corpus path
include/linux/trace_seq.h- Extension
.h- Size
- 5177 bytes
- Lines
- 184
- Domain
- Core OS
- Bucket
- Core Kernel Interface
- Inferred role
- Core OS: implementation source
- Status
- source implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/seq_buf.hasm/page.h
Detected Declarations
struct trace_seqfunction trace_seq_initfunction bufferfunction trace_seq_buffer_ptrfunction trace_seq_has_overflowedfunction trace_seq_popfunction __printffunction trace_seq_to_userfunction trace_seq_puts
Annotated Snippet
struct trace_seq {
struct seq_buf seq;
size_t readpos;
int full;
char buffer[TRACE_SEQ_BUFFER_SIZE];
};
static inline void
trace_seq_init(struct trace_seq *s)
{
seq_buf_init(&s->seq, s->buffer, TRACE_SEQ_BUFFER_SIZE);
s->full = 0;
s->readpos = 0;
}
/**
* trace_seq_used - amount of actual data written to buffer
* @s: trace sequence descriptor
*
* Returns the amount of data written to the buffer.
*
* IMPORTANT!
*
* Use this instead of @s->seq.len if you need to pass the amount
* of data from the buffer to another buffer (userspace, or what not).
* The @s->seq.len on overflow is bigger than the buffer size and
* using it can cause access to undefined memory.
*/
static inline int trace_seq_used(struct trace_seq *s)
{
return seq_buf_used(&s->seq);
}
/**
* trace_seq_buffer_ptr - return pointer to next location in buffer
* @s: trace sequence descriptor
*
* Returns the pointer to the buffer where the next write to
* the buffer will happen. This is useful to save the location
* that is about to be written to and then return the result
* of that write.
*/
static inline char *
trace_seq_buffer_ptr(struct trace_seq *s)
{
return s->buffer + seq_buf_used(&s->seq);
}
/**
* trace_seq_has_overflowed - return true if the trace_seq took too much
* @s: trace sequence descriptor
*
* Returns true if too much data was added to the trace_seq and it is
* now full and will not take anymore.
*/
static inline bool trace_seq_has_overflowed(struct trace_seq *s)
{
return s->full || seq_buf_has_overflowed(&s->seq);
}
/**
* trace_seq_pop - pop off the last written character
* @s: trace sequence descriptor
*
* Removes the last written character to the trace_seq @s.
*
* Returns the last character or -1 if it is empty.
*/
static inline int trace_seq_pop(struct trace_seq *s)
{
return seq_buf_pop(&s->seq);
}
/*
* Currently only defined when tracing is enabled.
*/
#ifdef CONFIG_TRACING
extern __printf(2, 3)
void trace_seq_printf(struct trace_seq *s, const char *fmt, ...);
extern __printf(2, 0)
void trace_seq_vprintf(struct trace_seq *s, const char *fmt, va_list args);
extern __printf(2, 0)
void trace_seq_bprintf(struct trace_seq *s, const char *fmt, const u32 *binary);
extern int trace_print_seq(struct seq_file *m, struct trace_seq *s);
extern int trace_seq_to_user(struct trace_seq *s, char __user *ubuf,
int cnt);
extern void trace_seq_puts(struct trace_seq *s, const char *str);
extern void trace_seq_putc(struct trace_seq *s, unsigned char c);
extern void trace_seq_putmem(struct trace_seq *s, const void *mem, unsigned int len);
extern void trace_seq_putmem_hex(struct trace_seq *s, const void *mem,
Annotation
- Immediate include surface: `linux/seq_buf.h`, `asm/page.h`.
- Detected declarations: `struct trace_seq`, `function trace_seq_init`, `function buffer`, `function trace_seq_buffer_ptr`, `function trace_seq_has_overflowed`, `function trace_seq_pop`, `function __printf`, `function trace_seq_to_user`, `function trace_seq_puts`.
- Atlas domain: Core OS / Core Kernel Interface.
- 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.