From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1E0BBC27C75 for ; Tue, 11 Jun 2024 15:36:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:From:References:Cc:To: Subject:MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=K8RUDhBMX0+yLAULNRGdDf0gADmeOoykZqvkcbRrcEM=; b=O0XpQVAqKGx5x6 7bGpli/N/fn6r1sJhQJif4ge/B4NpZC7zGRFQu6aeKYEAwnDDr5MNvuUjumH2l2H3lYt2Jul3CMd0 wAYN2kcwl/HjgWVtRsdlWG59HBNqnOvfd2PGVaFSm5XPvFfRyboG5wlREXC07+ShFPgYcMPae8B2x 3+BycQNkNhyqO8qKsDfDxG12VQDd9N8j4R/r8op/QrIWPLT70FOLTm5RNhxNSeBIdKs41bOJarKeL +B3OjK7znUMMpHfoqskTJrk2C/PL1s2Ge7XzuCB/EHjRoXiHloQDAvhCG57He2/TJqbWi8u00R/zA b5vlt72EnF8LFk3wRMPA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sH3YB-00000009Lra-3hUb; Tue, 11 Jun 2024 15:36:43 +0000 Received: from out-183.mta0.migadu.com ([2001:41d0:1004:224b::b7]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sH3Y6-00000009Lon-2QMt for linux-arm-kernel@lists.infradead.org; Tue, 11 Jun 2024 15:36:41 +0000 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 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> X-Migadu-Flow: FLOW_OUT X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240611_083639_412149_24018633 X-CRM114-Status: GOOD ( 13.67 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel