Commit 2cddfc2e authored by Aaron Tomlin's avatar Aaron Tomlin Committed by Steven Rostedt (Google)
Browse files

tracing: Add bitmask-list option for human-readable bitmask display

Add support for displaying bitmasks in human-readable list format (e.g.,
0,2-5,7) in addition to the default hexadecimal bitmap representation.
This is particularly useful when tracing CPU masks and other large
bitmasks where individual bit positions are more meaningful than their
hexadecimal encoding.

When the "bitmask-list" option is enabled, the printk "%*pbl" format
specifier is used to render bitmasks as comma-separated ranges, making
trace output easier to interpret for complex CPU configurations and
large bitmask values.

Link: https://patch.msgid.link/20251226160724.2246493-2-atomlin@atomlin.com


Signed-off-by: default avatarAaron Tomlin <atomlin@atomlin.com>
Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
parent a4e0ea0e
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -1290,6 +1290,15 @@ Here are the available options:
        This will be useful if you want to find out which hashed
        value is corresponding to the real value in trace log.

  bitmask-list
        When enabled, bitmasks are displayed as a human-readable list of
        ranges (e.g., 0,2-5,7) using the printk "%*pbl" format specifier.
        When disabled (the default), bitmasks are displayed in the
        traditional hexadecimal bitmap representation. The list format is
        particularly useful for tracing CPU masks and other large bitmasks
        where individual bit positions are more meaningful than their
        hexadecimal encoding.

  record-cmd
	When any event or tracer is enabled, a hook is enabled
	in the sched_switch trace point to fill comm cache
+4 −4
Original line number Diff line number Diff line
@@ -38,7 +38,10 @@ const char *trace_print_symbols_seq_u64(struct trace_seq *p,
								 *symbol_array);
#endif

const char *trace_print_bitmask_seq(struct trace_seq *p, void *bitmask_ptr,
struct trace_iterator;
struct trace_event;

const char *trace_print_bitmask_seq(struct trace_iterator *iter, void *bitmask_ptr,
				    unsigned int bitmask_size);

const char *trace_print_hex_seq(struct trace_seq *p,
@@ -54,9 +57,6 @@ trace_print_hex_dump_seq(struct trace_seq *p, const char *prefix_str,
			 int prefix_type, int rowsize, int groupsize,
			 const void *buf, size_t len, bool ascii);

struct trace_iterator;
struct trace_event;

int trace_raw_output_prep(struct trace_iterator *iter,
			  struct trace_event *event);
extern __printf(2, 3)
+11 −1
Original line number Diff line number Diff line
@@ -116,6 +116,10 @@ extern int trace_seq_path(struct trace_seq *s, const struct path *path);
extern void trace_seq_bitmask(struct trace_seq *s, const unsigned long *maskp,
			      int nmaskbits);

extern void trace_seq_bitmask_list(struct trace_seq *s,
				   const unsigned long *maskp,
				   int nmaskbits);

extern int trace_seq_hex_dump(struct trace_seq *s, const char *prefix_str,
			      int prefix_type, int rowsize, int groupsize,
			      const void *buf, size_t len, bool ascii);
@@ -137,6 +141,12 @@ trace_seq_bitmask(struct trace_seq *s, const unsigned long *maskp,
{
}

static inline void
trace_seq_bitmask_list(struct trace_seq *s, const unsigned long *maskp,
		       int nmaskbits)
{
}

static inline int trace_print_seq(struct seq_file *m, struct trace_seq *s)
{
	return 0;
+2 −2
Original line number Diff line number Diff line
@@ -39,7 +39,7 @@
		void *__bitmask = __get_dynamic_array(field);		\
		unsigned int __bitmask_size;				\
		__bitmask_size = __get_dynamic_array_len(field);	\
		trace_print_bitmask_seq(p, __bitmask, __bitmask_size);	\
		trace_print_bitmask_seq(iter, __bitmask, __bitmask_size);	\
	})

#undef __get_cpumask
@@ -51,7 +51,7 @@
		void *__bitmask = __get_rel_dynamic_array(field);		\
		unsigned int __bitmask_size;				\
		__bitmask_size = __get_rel_dynamic_array_len(field);	\
		trace_print_bitmask_seq(p, __bitmask, __bitmask_size);	\
		trace_print_bitmask_seq(iter, __bitmask, __bitmask_size);	\
	})

#undef __get_rel_cpumask
+1 −0
Original line number Diff line number Diff line
@@ -1411,6 +1411,7 @@ extern int trace_get_user(struct trace_parser *parser, const char __user *ubuf,
		C(COPY_MARKER,		"copy_trace_marker"),	\
		C(PAUSE_ON_TRACE,	"pause-on-trace"),	\
		C(HASH_PTR,		"hash-ptr"),	/* Print hashed pointer */ \
		C(BITMASK_LIST,		"bitmask-list"),	\
		FUNCTION_FLAGS					\
		FGRAPH_FLAGS					\
		STACK_FLAGS					\
Loading