From: Tao Chen <chen.dylane@linux.dev>
To: ast@kernel.org, daniel@iogearbox.net, john.fastabend@gmail.com,
andrii@kernel.org, martin.lau@linux.dev, eddyz87@gmail.com,
song@kernel.org, yonghong.song@linux.dev, kpsingh@kernel.org,
sdf@fomichev.me, haoluo@google.com, jolsa@kernel.org
Cc: bpf@vger.kernel.org, linux-kernel@vger.kernel.org,
Tao Chen <chen.dylane@linux.dev>
Subject: [PATCH bpf-next] bpf: Add load_time in bpf_prog fdinfo
Date: Fri, 20 Jun 2025 13:10:17 +0800 [thread overview]
Message-ID: <20250620051017.111559-1-chen.dylane@linux.dev> (raw)
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
next reply other threads:[~2025-06-20 5:10 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-20 5:10 Tao Chen [this message]
2025-06-20 18:27 ` Alexei Starovoitov
2025-06-20 19:54 ` Tao Chen
2025-06-22 9:22 ` kernel test robot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250620051017.111559-1-chen.dylane@linux.dev \
--to=chen.dylane@linux.dev \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=haoluo@google.com \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kpsingh@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=martin.lau@linux.dev \
--cc=sdf@fomichev.me \
--cc=song@kernel.org \
--cc=yonghong.song@linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®