Received: by 2002:ab2:69cc:0:b0:1fd:c486:4f03 with SMTP id n12csp435934lqp; Tue, 11 Jun 2024 08:38:32 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUM87tGnuqifsfMyXQaj3Hy1LAMl94Tf4DKJZoJo5uGxfhyDFAdnYV7FBq3O/5IP4x1tdCL0UgoxHld/JuqUaBwRjXURgiiWOK4BngXow== X-Google-Smtp-Source: AGHT+IF59sU5yJvUKG6FhpuL1tVkQvjp5xCDRxa74ysmyBPlGTkSp26Orp9gYeFwoksViq0AlZeX X-Received: by 2002:a05:6358:6188:b0:19f:1d0f:b636 with SMTP id e5c5f4694b2df-19f1fd10c28mr1695623555d.9.1718120312606; Tue, 11 Jun 2024 08:38:32 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718120312; cv=pass; d=google.com; s=arc-20160816; b=dHaM2OJgOaqUALcPEVwRkC/mv1zr3yF1j41HIhrerXThAp+eUZ538Pdx6loWYR9W92 hdn90CpcyZHbK2o4gxZbNctD7x6m14WD3wR1iXkkzweZQvZKnbqaS5j7siAnPgezxpP6 TRCNMFbSL8w45b4q0Qq84sW+vBSNbll3/1zF2OdAOhOOk5QMisHrw63jXeOO95HSDDBf fGO+FT8FykUzaQ7wwGJDfHbRL19G1zIsnzOzfY+mwVGJ362QaCmNwPpMd2/8dKbwpd/R Tlp+U4zq58PQLydA2QsAARpkb/QtqUq3WKGMVORpafDpbRHcBfSM4uQmV6cNgK1W+6Ge EUIg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=CDf/Var0If69rFPJqIDSKQIuhIfmeNAqiQ/6ESKmNKs=; fh=0Glcw7RBki3KfGdwu4bsUQHx5cfZZIKaK4tPxOnlS7o=; b=FLTZsyFw79nuVPdvzbVgcKRTNKQFzDWjI1uGZOdgIADbb9fePvG4e4WSDaUlbWLYW3 rEVfdajyiYxBlpi+Qe9jVgMVajg1058zDtpwOka6SP9wPRPE9XewEg8Z4R1x6BGQu6Id MbJiSP88lWyA5BYpIjgaQk1GA0uxhcCV3emhRS0IsOebKmdH8LfFKVri6qp8AykDRLHQ 0YyUGfrvVEfc5mJHT6r3r5gCS2Q1vHLzmcDClaCd8uINSY6b7+fQzvgTDJF1ZtSAugH2 ZbEvGofKGtUQ1BeLM2BplgGk+Mwwn5H0TPXrBMR8vbAg26r9+8J+A8BKFU83Vk5wYpFr Hs5Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=pcPuA6Fp; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-210163-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-210163-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 41be03b00d2f7-6f8bd6f102dsi484861a12.711.2024.06.11.08.38.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jun 2024 08:38:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-210163-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=pcPuA6Fp; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-210163-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-210163-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id BA3F7281D55 for ; Tue, 11 Jun 2024 15:37:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5D56F39FD4; Tue, 11 Jun 2024 15:36:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="pcPuA6Fp" Received: from out-182.mta0.migadu.com (out-182.mta0.migadu.com [91.218.175.182]) (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 D902338FA0 for ; Tue, 11 Jun 2024 15:36:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718120200; cv=none; b=sU8seZB9rdDsXRwUX+43RMevgjsmoATCvu1WeCJXXcvQCFf4zIP6pzHauGW0LWGSO7iNUv+fHp6NG3qNCpj8ohaJhgOTQhTOaTces/I9G/AT9s2L5d60UdbV2+H/rON0nE/5S6hEG3wFMKfBb2FUatmM76vexSyXftRXsWQNlzs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718120200; c=relaxed/simple; bh=r57qrLhmwHMKnHrFKmWypm9nE6+c8sNnIXim4c8y74s=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=kT5TIDOym3GydS5ugPPq1gSsyAN/J2kHkZunmTEDgDAJJGGSXGGhQ0TOV1xkY4tUHjfbZRxPGB/zDpvcDDv+Oc3dhOFwSH+7wgqsHx0Sn3HeZycq/djwmWJYozu5u6TNU6MKNDSLyEPmUBVuC9tuSvj8y0wUJj7UITEn3zHCj4s= 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=pcPuA6Fp; arc=none smtp.client-ip=91.218.175.182 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 X-Envelope-To: andrew@lunn.ch DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1718120196; 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=CDf/Var0If69rFPJqIDSKQIuhIfmeNAqiQ/6ESKmNKs=; b=pcPuA6FptuahJYYDigDXzfvPCr9O1DORzHlUYC4NlO5Oie8SCuI7zLrkehHQs6qOGO0tuj M+ht37ApsnW65T4u6kNmUAEV6yrjciG6KskOq39MuD+Loq5n8kgJ3i/YFWZiSq/6i3xPkl STUEy3q1USjAcA/DBpzO/x+hUKG72Hw= X-Envelope-To: radhey.shyam.pandey@amd.com X-Envelope-To: netdev@vger.kernel.org X-Envelope-To: linux-arm-kernel@lists.infradead.org X-Envelope-To: michal.simek@amd.com X-Envelope-To: kuba@kernel.org X-Envelope-To: linux@armlinux.org.uk X-Envelope-To: pabeni@redhat.com X-Envelope-To: edumazet@google.com X-Envelope-To: linux-kernel@vger.kernel.org X-Envelope-To: davem@davemloft.net Message-ID: <4d3871c1-afa1-4402-ad62-2fdb9d58dc3c@linux.dev> Date: Tue, 11 Jun 2024 11:36:31 -0400 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Subject: Re: [PATCH net-next 3/3] net: xilinx: axienet: Add statistics support To: Andrew Lunn Cc: Radhey Shyam Pandey , netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Michal Simek , Jakub Kicinski , Russell King , Paolo Abeni , Eric Dumazet , linux-kernel@vger.kernel.org, "David S . Miller" References: <20240610231022.2460953-1-sean.anderson@linux.dev> <20240610231022.2460953-4-sean.anderson@linux.dev> <40cff9a6-bad3-4f85-8cbc-6d4bc72f9b9f@lunn.ch> Content-Language: en-US X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Sean Anderson In-Reply-To: <40cff9a6-bad3-4f85-8cbc-6d4bc72f9b9f@lunn.ch> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_OUT On 6/10/24 20:26, Andrew Lunn wrote: >> +static u64 axienet_stat(struct axienet_local *lp, enum temac_stat stat) >> +{ >> + return u64_stats_read(&lp->hw_stats[stat]); >> +} >> @@ -1695,6 +1760,35 @@ axienet_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats) >> stats->tx_packets = u64_stats_read(&lp->tx_packets); >> stats->tx_bytes = u64_stats_read(&lp->tx_bytes); >> } while (u64_stats_fetch_retry(&lp->tx_stat_sync, start)); >> + >> + if (!(lp->features & XAE_FEATURE_STATS)) >> + return; >> + >> + do { >> + start = u64_stats_fetch_begin(&lp->hw_stat_sync); >> + stats->rx_length_errors = >> + axienet_stat(lp, STAT_RX_LENGTH_ERRORS); > > I'm i reading this correctly. You are returning the counters from the > last refresh period. What is that? 2.5Gbps would wrapper around a 32 > byte counter in 13 seconds. I hope these statistics are not 13 seconds > out of date? By default we use a 1 Hz refresh period. You can of course configure this up to 13 seconds, but we refuse to raise it further since we risk missing a wrap-around. It's configurable by userspace so they can determine how out-of-date they like their stats (vs how often they want to wake up the CPU). > Since axienet_stats_update() also uses the lp->hw_stat_sync, i don't > see why you cannot read the hardware counter value and update to the > latest value. We would need to synchronize against updates to hw_last_counter. Imagine a scenario like CPU 1 CPU 2 __axienet_device_reset() axienet_stats_update() axienet_stat() u64_stats_read() axienet_ior() /* device reset */ hw_last_counter = 0 stats->foo = ... - hw_last_counter[...] and now we have a glitch in the counter values, since we effectively are double-counting the current counter value. Alternatively, we could read the counter after reset but before hw_last_counter was updated and get a glitch due to underflow. --Sean