🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #4104

Re: [RFC net-next v2 1/5] selftests: net: py: add timestamped metric output

#4104
From: Jakub Kicinski
Date: Fri, 16 Oct 2026 16:52
42 lines
7046 bytes
On Mon,  5 Oct 2026 13:11:10 -0700 Stanislav Fomichev wrote:
> +ksft_metric()
> +~~~~~~~~~~~~~
> +
> +Use ``ksft_metric()`` to report a numeric measurement for the current test
> +case. The helper records the time relative to the start of the case and emits
> +each observation immediately before the test result as compact JSON. For
> +example::
> +
> +  ksft_metric("throughput", 100.5, kind="scalar")
> +
> +emits output similar to::
> +
> +  # ktap-metric-json: {"name":"throughput","time":1.234,"type":"scalar","value":100.5}

Should time be optional? In case some test wants to report single metric
not value over time? Maybe just mention that it's an option if someone
needs it in the future?

> +When ``run_kselftest.sh`` nests the test output, its diagnostic prefix makes
> +this ``# # ktap-metric-json: <json>``. 

This sentence needs to go, it's out of place and obvious to anyone who
worked with ksft.

> A background sampler can call
> +``ksft_metric()`` repeatedly. Pass ``kind`` explicitly; it is emitted as the
> +``type`` field. Supported kinds are ``scalar`` for one numeric value and
> +``per-cpu`` for an array indexed by CPU number, with ``None`` for a missing or
> +offline CPU::
> +
> +  ksft_metric("cpu.utilization", [75.0, 22.0, None, 100.0],
> +              kind="per-cpu", host="local")

Should we say something about what the values for "kind" are?
Or should this be internal - IOW create ksft_metric_X for supported
types, like ksft_metric_scalar, which would be more self-documenting?

> +The helper does not infer the kind from the Python value, since an array may
> +represent something other than per-CPU data. Metrics are measurements only and
> +do not affect the pass or fail result.
Technical Details
Message-ID: <20261016095201.0f5686f6@kernel.org>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-347450-linux-kernel-netdev=dewy.ru
References: <20261005201115.2690830-1-sdf@fomichev.me> <20261005201115.2690830-2-sdf@fomichev.me>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-347450-linux-kernel-netdev=dewy.ru
From: kuba@kernel.org (Jakub Kicinski)
Newsgroups: linux.kernel.netdev
Subject: Re: [RFC net-next v2 1/5] selftests: net: py: add timestamped
 metric output
Date: Fri, 16 Oct 2026 09:52:01 -0700
Organization: Usenet Network
Message-ID: <20261016095201.0f5686f6@kernel.org>
References: <20261005201115.2690830-1-sdf@fomichev.me>
	<20261005201115.2690830-2-sdf@fomichev.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: usenet.network;
	logging-data="2840354"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:rBGfUpHtuuhZSX+UujTO5xmCo+Q= sha256:AUixGBn2AAR0/+Lx7NPLl/yoKkx4/yRlWazLLAKZtII=
	sha1:WgYYhipzBTTsS90vy3t9gC6SbWY= sha256:OVb6Jxoch/odwcAbMcjoMepj80WlA5n38rrOiFurlqU=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id D9FCB1105BA; Fri, 16 Oct 2026 21:23:10 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.64
X-Spam-Status: No, score=-3.64 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.24, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id Ald0yTGcmXDC;
	Fri, 16 Oct 2026 21:23:07 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-347450-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id E9FAE1105B7; Fri, 16 Oct 2026 21:22:56 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1])
	by sea.lore.kernel.org (Postfix) with ESMTP id B056A63FF9; Fri, 16 Oct 2026 16:52:06 +0000 (UTC)
X-Received: from localhost.localdomain (localhost.localdomain [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id B091F52F288;
	Fri, 16 Oct 2026 16:52:05 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="WfTQVS+J"
X-Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18])
	(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 F2CBA4CE699
	for <netdev@vger.kernel.org>; Fri, 16 Oct 2026 16:52:02 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18
X-ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;
	t=1792169525; cv=none; b=NPsIXyqARDFILzmOyUq00DJkhKs0RjToHW9dPy3qh4WCwpzBY4H3vLpYPvIY5EK+cs9XVepMUk5s/TsdBeCtL2uUbuAff8cvTc25orLFvXcYdNbtjaCB82eRCQgNQd4s/N5FVmNvkdvqCkpBu2IWvx4bjBiQaamqx8JGoCZv9CU=
X-ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org;
	s=arc-20240116; t=1792169525; c=relaxed/simple;
	bh=c+1wFwMtjYZL5jvdhQePrUCLHTKdHQahsHgz6+PHb6A=;
	h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References:
	 MIME-Version:Content-Type; b=FqcSjNFhFHxLCH2wfWHRCjMBNJiS/YS2afA1oKV2TcpWwAjhUGJDfK6U/e12N/h65piXsKeK67NjaDb/ll0M9RvwOxqzS6Rp514Zg0SW7xr1wSxQsCgZP0wEWSdEal5LuTw5aTUJeuIpjzIAa42dUnzmdamBtjfBjIUQ8z0kif0=
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=WfTQVS+J; arc=none smtp.client-ip=100.103.45.18
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 64C4F1F000CA;
	Fri, 16 Oct 2026 16:52:02 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1792169522;
	bh=kdNbANgrNe6FBaArNZERMwWSFqQ2R3GUk4nqF+drWwQ=;
	h=Date:From:To:Cc:Subject:In-Reply-To:References;
	b=WfTQVS+J3wvtV0uo3yPHbsgdpn49EjaUmbG3jQDgB+yi69lm00W0dTPOuPhbbaMnN
	 ZBf55pQamj6EuQx2dkdv6mLDLQlbW3UZZbXKptgukbAQx/EisU+Kc3ajJJUNlysBin
	 GoenRMLDyCIEFjVI3PisCj/DdKUSOygaK+V9UqJTs4+sNYy3u4SlT+JBkE/fWrXc1P
	 9MxGyiNx8hjRczzCXZdln08B3tDRhD0KED+kilkp3slP/sD8wrBDGctOi+d1hwRcnI
	 9SRIMtmDdztvim5ZSZLv9OholDK/m++yRBCMa27KdC9cJxqr4PmhyK43gV/lnAG3z6
	 HsrW5ZKiZTvuA==
X-Cc: netdev@vger.kernel.org, davem@davemloft.net, edumazet@google.com,
 pabeni@redhat.com
X-In-Reply-To: <20261005201115.2690830-2-sdf@fomichev.me>
X-Precedence: bulk
X-Mailing-List: netdev@vger.kernel.org
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>