* [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
* Re: [PATCH bpf-next] bpf: Add load_time in bpf_prog fdinfo
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
1 sibling, 1 reply; 4+ messages in thread
From: Alexei Starovoitov @ 2025-06-20 18:27 UTC (permalink / raw)
To: Tao Chen
Cc: Alexei Starovoitov, Daniel Borkmann, John Fastabend,
Andrii Nakryiko, Martin KaFai Lau, Eduard, Song Liu,
Yonghong Song, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa,
bpf, LKML
On Thu, Jun 19, 2025 at 10:10 PM Tao Chen <chen.dylane@linux.dev> wrote:
>
> 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);
I don't like where it's going.
Soon fdinfo will be printing the xlated insns of the prog too,
since why not?
Let's stop here. We have syscall query api-s for that and
bpftool to print such things.
No more fdinfo "improvements".
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH bpf-next] bpf: Add load_time in bpf_prog fdinfo
2025-06-20 18:27 ` Alexei Starovoitov
@ 2025-06-20 19:54 ` Tao Chen
0 siblings, 0 replies; 4+ messages in thread
From: Tao Chen @ 2025-06-20 19:54 UTC (permalink / raw)
To: Alexei Starovoitov
Cc: Alexei Starovoitov, Daniel Borkmann, John Fastabend,
Andrii Nakryiko, Martin KaFai Lau, Eduard, Song Liu,
Yonghong Song, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa,
bpf, LKML
在 2025/6/21 02:27, Alexei Starovoitov 写道:
> On Thu, Jun 19, 2025 at 10:10 PM Tao Chen <chen.dylane@linux.dev> wrote:
>>
>> 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);
>
> I don't like where it's going.
> Soon fdinfo will be printing the xlated insns of the prog too,
> since why not?
> Let's stop here. We have syscall query api-s for that and
> bpftool to print such things.
> No more fdinfo "improvements".
Got it, Alexei, thanks for your patient explanation.
--
Best Regards
Tao Chen
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH bpf-next] bpf: Add load_time in bpf_prog fdinfo
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-22 9:22 ` kernel test robot
1 sibling, 0 replies; 4+ messages in thread
From: kernel test robot @ 2025-06-22 9:22 UTC (permalink / raw)
To: Tao Chen, ast, daniel, john.fastabend, andrii, martin.lau,
eddyz87, song, yonghong.song, kpsingh, sdf, haoluo, jolsa
Cc: oe-kbuild-all, bpf, linux-kernel, Tao Chen
Hi Tao,
kernel test robot noticed the following build errors:
[auto build test ERROR on bpf-next/master]
url: https://github.com/intel-lab-lkp/linux/commits/Tao-Chen/bpf-Add-load_time-in-bpf_prog-fdinfo/20250620-131249
base: https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git master
patch link: https://lore.kernel.org/r/20250620051017.111559-1-chen.dylane%40linux.dev
patch subject: [PATCH bpf-next] bpf: Add load_time in bpf_prog fdinfo
config: m68k-randconfig-r123-20250622 (https://download.01.org/0day-ci/archive/20250622/202506221641.xWzKiW3U-lkp@intel.com/config)
compiler: m68k-linux-gcc (GCC) 8.5.0
reproduce: (https://download.01.org/0day-ci/archive/20250622/202506221641.xWzKiW3U-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202506221641.xWzKiW3U-lkp@intel.com/
All errors (new ones prefixed by >>):
m68k-linux-ld: kernel/bpf/syscall.o: in function `bpf_prog_show_fdinfo':
>> syscall.c:(.text+0x1088): undefined reference to `__udivdi3'
m68k-linux-ld: drivers/clocksource/timer-tegra186.o: in function `tegra186_wdt_get_timeleft':
timer-tegra186.c:(.text+0x130): undefined reference to `__udivdi3'
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [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).