From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-172.mta0.migadu.com (out-172.mta0.migadu.com [91.218.175.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 058582253EB for ; Fri, 20 Jun 2025 19:54:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750449283; cv=none; b=igkCzqk7/rTnGb3ZyjBXm1Ge4iyfI1AkUJRR1DIkGiPUvI/xg2IwaAgHCmEPNcPboTA7+v0HS8JiaxJqUqfAiEbtK7JTnxDmu98QbC8BhiggfxIfpDFEG5GKre/JTq0+7FeSdh5Os7FAu/REY6CJzhZQ+ACpseT5PfzY9OkCRNw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750449283; c=relaxed/simple; bh=gwW/ZJH1VLIkz6MGwVX4aHnvXoTlVx/vj9jo9qbl9zI=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=KXjPsdJKhCthCLTPYF6qttQeodERZSpUDqmcYSPalaCvy1c9XCn/OTDJpCxd3AI7nW9qrgO+vSQ84A/ZAD9re+zVALkdPfzQlixX1ez75UFD7sLIyLW8+MpnQ4k5hrMdq6TMvMcSrVBLR1+Pe/xSpW5Hb76Qov12OvF0uPo1CDQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=VgxayH6b; arc=none smtp.client-ip=91.218.175.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="VgxayH6b" Message-ID: <5ff84c99-46a2-4dde-a1f4-f49b09b0b15f@linux.dev> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1750449278; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=B9890C/fAgtvvt0ndaoyPFp5S+6tCMCjaOU36i0zlJk=; b=VgxayH6bRXn9jSnHSGefKyUi69i6ZbZ1L2hKf+wfXjXRHL5Peg5g2TxObTti+rt28g2NUr BRiLjX9Ne+JoQOQy0iykdbVrDVjTb9fVLsqrTxwC0pFXvDJS8S/cX1rnb53Bmfh4gxSqwI S6a6ddIFT7t8OsyGaKDNe6uhnID9Jf8= Date: Sat, 21 Jun 2025 03:54:29 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Subject: Re: [PATCH bpf-next] bpf: Add load_time in bpf_prog fdinfo 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 References: <20250620051017.111559-1-chen.dylane@linux.dev> X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Tao Chen In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT 在 2025/6/21 02:27, Alexei Starovoitov 写道: > On Thu, Jun 19, 2025 at 10:10 PM Tao Chen 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 >> --- >> 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