diff mbox series

[bpf-next] samples/bpf: offwaketime: pretty print

Message ID tencent_1C233A1BC00A0164C55FCAAB24BF768C320A@qq.com (mailing list archive)
State Rejected
Delegated to: BPF
Headers show
Series [bpf-next] samples/bpf: offwaketime: pretty print | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for bpf-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers success CCed 12 of 12 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 37 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
bpf/vmtest-bpf-next-VM_Test-4 success Logs for llvm-toolchain
bpf/vmtest-bpf-next-VM_Test-5 success Logs for set-matrix
bpf/vmtest-bpf-next-VM_Test-2 success Logs for build for x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-3 success Logs for build for x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-1 success Logs for build for s390x with gcc
bpf/vmtest-bpf-next-VM_Test-15 success Logs for test_verifier on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-16 success Logs for test_verifier on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-17 success Logs for test_verifier on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-12 success Logs for test_progs_no_alu32 on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-10 success Logs for test_progs on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-11 success Logs for test_progs on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-13 success Logs for test_progs_no_alu32 on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-14 success Logs for test_progs_no_alu32 on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-7 success Logs for test_maps on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-8 success Logs for test_maps on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-9 fail Logs for test_progs on s390x with gcc
bpf/vmtest-bpf-next-PR fail PR summary
bpf/vmtest-bpf-next-VM_Test-6 success Logs for test_maps on s390x with gcc

Commit Message

Rong Tao Sept. 26, 2022, 2:22 a.m. UTC
From: Rong Tao <rongtao@cestc.cn>

A sample of call stack:
swapper/10 [
	secondary_startup_64_no_verify
	cpu_startup_entry
	do_idle
	schedule_idle
	__schedule
	__traceiter_sched_switch
	__traceiter_sched_switch
	-
	try_to_wake_up
	call_timer_fn
	__run_timers.part.0
	run_timer_softirq
	__softirqentry_text_start
	__irq_exit_rcu
	sysvec_apic_timer_interrupt
	asm_sysvec_apic_timer_interrupt
	cpuidle_enter_state
	cpuidle_enter
	cpuidle_idle_call
	do_idle
	cpu_startup_entry
	secondary_startup_64_no_verify
] swapper/10 1

Signed-off-by: Rong Tao <rongtao@cestc.cn>
---
 samples/bpf/offwaketime_user.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

Comments

Martin KaFai Lau Sept. 27, 2022, 11:37 p.m. UTC | #1
On 9/25/22 7:22 PM, Rong Tao wrote:
> From: Rong Tao <rongtao@cestc.cn>
> 
> A sample of call stack:
> swapper/10 [
> 	secondary_startup_64_no_verify
> 	cpu_startup_entry
> 	do_idle
> 	schedule_idle
> 	__schedule
> 	__traceiter_sched_switch
> 	__traceiter_sched_switch
> 	-
> 	try_to_wake_up
> 	call_timer_fn
> 	__run_timers.part.0
> 	run_timer_softirq
> 	__softirqentry_text_start
> 	__irq_exit_rcu
> 	sysvec_apic_timer_interrupt
> 	asm_sysvec_apic_timer_interrupt
> 	cpuidle_enter_state
> 	cpuidle_enter
> 	cpuidle_idle_call
> 	do_idle
> 	cpu_startup_entry
> 	secondary_startup_64_no_verify
> ] swapper/10 1
> 
> Signed-off-by: Rong Tao <rongtao@cestc.cn>
> ---
>   samples/bpf/offwaketime_user.c | 14 +++++++-------
>   1 file changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/samples/bpf/offwaketime_user.c b/samples/bpf/offwaketime_user.c
> index b6eedcb98fb9..d89278d62e4e 100644
> --- a/samples/bpf/offwaketime_user.c
> +++ b/samples/bpf/offwaketime_user.c
> @@ -30,9 +30,9 @@ static void print_ksym(__u64 addr)
>   	}
>   
>   	if (PRINT_RAW_ADDR)
> -		printf("%s/%llx;", sym->name, addr);
> +		printf("\t%s/%llx\n", sym->name, addr);

The origin commit intention is to have an external script for post processing. 
Beside, there are bcc, bpftrace, and libbpf-tools which are better places to 
have different output options.  The current code is good enough for sample 
purpose and no need for unnecessary code churn.
Rong Tao Sept. 28, 2022, 1:20 a.m. UTC | #2
From: Rong Tao <rongtao@cestc.cn>

Thank you very much for your reply, next time I will know all before
submitting.

--
diff mbox series

Patch

diff --git a/samples/bpf/offwaketime_user.c b/samples/bpf/offwaketime_user.c
index b6eedcb98fb9..d89278d62e4e 100644
--- a/samples/bpf/offwaketime_user.c
+++ b/samples/bpf/offwaketime_user.c
@@ -30,9 +30,9 @@  static void print_ksym(__u64 addr)
 	}
 
 	if (PRINT_RAW_ADDR)
-		printf("%s/%llx;", sym->name, addr);
+		printf("\t%s/%llx\n", sym->name, addr);
 	else
-		printf("%s;", sym->name);
+		printf("\t%s\n", sym->name);
 }
 
 #define TASK_COMM_LEN 16
@@ -50,21 +50,21 @@  static void print_stack(struct key_t *key, __u64 count)
 	static bool warned;
 	int i;
 
-	printf("%s;", key->target);
+	printf("%s [\n", key->target);
 	if (bpf_map_lookup_elem(map_fd[1], &key->tret, ip) != 0) {
-		printf("---;");
+		printf("\t---\n");
 	} else {
 		for (i = PERF_MAX_STACK_DEPTH - 1; i >= 0; i--)
 			print_ksym(ip[i]);
 	}
-	printf("-;");
+	printf("\t-\n");
 	if (bpf_map_lookup_elem(map_fd[1], &key->wret, ip) != 0) {
-		printf("---;");
+		printf("\t---\n");
 	} else {
 		for (i = 0; i < PERF_MAX_STACK_DEPTH; i++)
 			print_ksym(ip[i]);
 	}
-	printf(";%s %lld\n", key->waker, count);
+	printf("] %s %lld\n", key->waker, count);
 
 	if ((key->tret == -EEXIST || key->wret == -EEXIST) && !warned) {
 		printf("stackmap collisions seen. Consider increasing size\n");