Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ref_tracker: allow pr_ostream() to print directly to a seq_file

Allow pr_ostream to also output directly to a seq_file without an
intermediate buffer. The first caller of +ref_tracker_dir_seq_print()
will come in a later patch, so mark that __maybe_unused for now. That
designation will be removed once it is used.

Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
Link: https://patch.msgid.link/20250618-reftrack-dbgfs-v15-5-24fc37ead144@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Jeff Layton and committed by
Jakub Kicinski
f6dbe294 aa7d26c3

+26
+26
lib/ref_tracker.c
··· 8 8 #include <linux/slab.h> 9 9 #include <linux/stacktrace.h> 10 10 #include <linux/stackdepot.h> 11 + #include <linux/seq_file.h> 11 12 12 13 #define REF_TRACKER_STACK_ENTRIES 16 13 14 #define STACK_BUF_SIZE 1024 ··· 67 66 void __ostream_printf (*func)(struct ostream *stream, char *fmt, ...); 68 67 char *prefix; 69 68 char *buf; 69 + struct seq_file *seq; 70 70 int size, used; 71 71 }; 72 72 ··· 302 300 #include <linux/debugfs.h> 303 301 304 302 static struct dentry *ref_tracker_debug_dir = (struct dentry *)-ENOENT; 303 + 304 + static void __ostream_printf pr_ostream_seq(struct ostream *stream, char *fmt, ...) 305 + { 306 + va_list args; 307 + 308 + va_start(args, fmt); 309 + seq_vprintf(stream->seq, fmt, args); 310 + va_end(args); 311 + } 312 + 313 + static __maybe_unused int 314 + ref_tracker_dir_seq_print(struct ref_tracker_dir *dir, struct seq_file *seq) 315 + { 316 + struct ostream os = { .func = pr_ostream_seq, 317 + .prefix = "", 318 + .seq = seq }; 319 + unsigned long flags; 320 + 321 + spin_lock_irqsave(&dir->lock, flags); 322 + __ref_tracker_dir_pr_ostream(dir, 16, &os); 323 + spin_unlock_irqrestore(&dir->lock, flags); 324 + 325 + return os.used; 326 + } 305 327 306 328 static int __init ref_tracker_debugfs_init(void) 307 329 {