bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH bpf-next] bpf: Add load_time in bpf_prog fdinfo
@ 2025-06-20  5:10 Tao Chen
  2025-06-20 18:27 ` Alexei Starovoitov
  2025-06-22  9:22 ` kernel test robot
  0 siblings, 2 replies; 4+ messages in thread
From: Tao Chen @ 2025-06-20  5:10 UTC (permalink / raw)
  To: ast, daniel, john.fastabend, andrii, martin.lau, eddyz87, song,
	yonghong.song, kpsingh, sdf, haoluo, jolsa
  Cc: bpf, linux-kernel, Tao Chen

The field run_time_ns can tell us the run time of the bpf_prog,
and load_time_s can tell us how long the bpf_prog loaded on the
machine.

Signed-off-by: Tao Chen <chen.dylane@linux.dev>
---
 kernel/bpf/syscall.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
index 51ba1a7aa43..407841ea296 100644
--- a/kernel/bpf/syscall.c
+++ b/kernel/bpf/syscall.c
@@ -2438,6 +2438,7 @@ static void bpf_prog_show_fdinfo(struct seq_file *m, struct file *filp)
 	const struct bpf_prog *prog = filp->private_data;
 	char prog_tag[sizeof(prog->tag) * 2 + 1] = { };
 	struct bpf_prog_kstats stats;
+	u64 now = ktime_get_boottime_ns();
 
 	bpf_prog_get_stats(prog, &stats);
 	bin2hex(prog_tag, prog->tag, sizeof(prog->tag));
@@ -2450,7 +2451,8 @@ static void bpf_prog_show_fdinfo(struct seq_file *m, struct file *filp)
 		   "run_time_ns:\t%llu\n"
 		   "run_cnt:\t%llu\n"
 		   "recursion_misses:\t%llu\n"
-		   "verified_insns:\t%u\n",
+		   "verified_insns:\t%u\n"
+		   "load_time_s:\t%llu\n",
 		   prog->type,
 		   prog->jited,
 		   prog_tag,
@@ -2459,7 +2461,8 @@ static void bpf_prog_show_fdinfo(struct seq_file *m, struct file *filp)
 		   stats.nsecs,
 		   stats.cnt,
 		   stats.misses,
-		   prog->aux->verified_insns);
+		   prog->aux->verified_insns,
+		   (now - prog->aux->load_time) / NSEC_PER_SEC);
 }
 #endif
 
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-06-22  9:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-20  5:10 [PATCH bpf-next] bpf: Add load_time in bpf_prog fdinfo Tao Chen
2025-06-20 18:27 ` Alexei Starovoitov
2025-06-20 19:54   ` Tao Chen
2025-06-22  9:22 ` kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).