From 3feaa98a2e66120c07f13a5f55f83fdd3cbb7387 Mon Sep 17 00:00:00 2001 From: Gu Bowen Date: Tue, 23 Sep 2025 17:26:04 +0800 Subject: [PATCH] samples/bpf: Fix print issue in dump_swaps() hulk inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/ICA1GK -------------------------------- BPF_SEQ_PRINTF does not support the %*s format for printing, leading to missing print information, fix it. Fixes: be60b1123f28 ("samples/bpf: Add iterator program for swaps") Signed-off-by: Gu Bowen --- samples/bpf/bpf_rvi/bpf_rvi_swaps.bpf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/samples/bpf/bpf_rvi/bpf_rvi_swaps.bpf.c b/samples/bpf/bpf_rvi/bpf_rvi_swaps.bpf.c index db42929bc7d8..f3138321b17e 100644 --- a/samples/bpf/bpf_rvi/bpf_rvi_swaps.bpf.c +++ b/samples/bpf/bpf_rvi/bpf_rvi_swaps.bpf.c @@ -126,8 +126,8 @@ s64 dump_swaps(struct bpf_iter__generic_single *ctx) /* Reference: swap_show(). Aligned with LXCFS. */ BPF_SEQ_PRINTF(m, "Filename\t\t\t\tType\t\tSize\t\tUsed\t\tPriority\n"); if (swaptotal > 0) - BPF_SEQ_PRINTF(m, "none%*svirtual\t\t%llu\t%llu\t0\n", - 36, " ", swaptotal * kb_per_page, + BPF_SEQ_PRINTF(m, "none\t\t\t\tvirtual\t\t%llu\t\t%llu\t\t0\n", + swaptotal * kb_per_page, swapusage * kb_per_page); // in KB bpf_rcu_read_unlock(); -- Gitee