From patchwork Thu Aug 25 11:36:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Andrzej Siewior X-Patchwork-Id: 12954594 X-Patchwork-Delegate: kuba@kernel.org 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 45F8AC28D13 for ; Thu, 25 Aug 2022 11:37:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239952AbiHYLhO (ORCPT ); Thu, 25 Aug 2022 07:37:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49592 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240538AbiHYLgx (ORCPT ); Thu, 25 Aug 2022 07:36:53 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D3CA2CDC5 for ; Thu, 25 Aug 2022 04:36:52 -0700 (PDT) From: Sebastian Andrzej Siewior DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1661427410; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=n8xzD/4u1H6XLUUMs6D38LTD+KsnylSlHJWwXIAMov4=; b=O/fu8LRCN8ywhU0tosT19GaDEiOXmXXBcYI/zHdGUr89Re7g8TyD1emCVuaRfDZmsccxfW RvGC5Pr/xfkkcWmrrqvi2p53C2j4CRLrtBjVMc4LL9E5GUPPhKXMdUQxHMIdMl1ebdt9D/ AAwmHnep3HiA+JPHlQq7sKFiFeZi4h0DrYVcdRWk9+i4iwI6DmOI23AN8aYxPhiG92fmM9 +9xQXJ+beQfl+qb/CKc2QzbpetLF2jVSrrMHF2yXFx9zmxKeF08TNfOWSUX+BT4G38HKzl +Fa98uQcHhbXHQLW27ttEsAYFumpvLG0rq7/6LFG9FnuXUyIEiS154IruLMMfg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1661427410; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=n8xzD/4u1H6XLUUMs6D38LTD+KsnylSlHJWwXIAMov4=; b=PQbwpf7UadLoBhApCMn33rIOy2PPtouo7UE7hRxVHL2urwK/tKlQ7M4Y3QttY1V0cxH1DZ jIGOwna67H0u0bDA== To: netdev@vger.kernel.org Cc: Jakub Kicinski , "David S. Miller" , Thomas Gleixner , Peter Zijlstra , Sebastian Andrzej Siewior , Andrew Lunn , Florian Fainelli , George McCollister , Vivien Didelot , Vladimir Oltean Subject: [PATCH net 1/2] net: dsa: xrs700x: Use irqsave variant for u64 stats update Date: Thu, 25 Aug 2022 13:36:44 +0200 Message-Id: <20220825113645.212996-2-bigeasy@linutronix.de> In-Reply-To: <20220825113645.212996-1-bigeasy@linutronix.de> References: <20220825113645.212996-1-bigeasy@linutronix.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org xrs700x_read_port_counters() updates the stats from a worker using the u64_stats_update_begin() version. This is okay on 32-UP since on the reader side preemption is disabled. On 32bit-SMP the writer can be preempted by the reader at which point the reader will spin on the seqcount until writer continues and completes the update. Assigning the mib_mutex mutex to the underlying seqcount would ensure proper synchronisation. The API for that on the u64_stats_init() side isn't available. Since it is the only user, just use disable interrupts during the update. Use u64_stats_update_begin_irqsave() on the writer side to ensure an uninterrupted update. Fixes: ee00b24f32eb8 ("net: dsa: add Arrow SpeedChips XRS700x driver") Cc: Andrew Lunn Cc: Florian Fainelli Cc: George McCollister Cc: Vivien Didelot Cc: Vladimir Oltean Signed-off-by: Sebastian Andrzej Siewior Acked-by: George McCollister --- drivers/net/dsa/xrs700x/xrs700x.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/net/dsa/xrs700x/xrs700x.c b/drivers/net/dsa/xrs700x/xrs700x.c index 3887ed33c5fe2..fa622639d6401 100644 --- a/drivers/net/dsa/xrs700x/xrs700x.c +++ b/drivers/net/dsa/xrs700x/xrs700x.c @@ -109,6 +109,7 @@ static void xrs700x_read_port_counters(struct xrs700x *priv, int port) { struct xrs700x_port *p = &priv->ports[port]; struct rtnl_link_stats64 stats; + unsigned long flags; int i; memset(&stats, 0, sizeof(stats)); @@ -138,9 +139,9 @@ static void xrs700x_read_port_counters(struct xrs700x *priv, int port) */ stats.rx_packets += stats.multicast; - u64_stats_update_begin(&p->syncp); + flags = u64_stats_update_begin_irqsave(&p->syncp); p->stats64 = stats; - u64_stats_update_end(&p->syncp); + u64_stats_update_end_irqrestore(&p->syncp, flags); mutex_unlock(&p->mib_mutex); }