Received: by 2002:a05:7412:98c1:b0:fa:551:50a7 with SMTP id kc1csp1542600rdb; Mon, 8 Jan 2024 02:35:15 -0800 (PST) X-Google-Smtp-Source: AGHT+IEWc3ZxOElo3fyG0/M+NMhq5WooSc+aoDqFZkJVUwpOXar0d00fkdefYIpWg3UyatNjhgYe X-Received: by 2002:a05:620a:4722:b0:781:ba94:b535 with SMTP id bs34-20020a05620a472200b00781ba94b535mr4862696qkb.7.1704710115010; Mon, 08 Jan 2024 02:35:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704710114; cv=none; d=google.com; s=arc-20160816; b=QllGVb/WjYpFOtq/u0vIACWwbZZ8VY3lz224WGjEgivB3eFkdTip/6wjNtbRil3Wh7 jMp66ervJVKa9sb/9EMMr9CDQBWiSflzqYaQRmbj7r2K39wbAda0xIe6/4OamI5y3OzI BSeHej6uOpCdxjmugzcZZL9uo+F9qxMXR199Kc/Vrn7H9I4B14G3xfTRboIaCxYzDor7 TNE56AT3YQmhk6RB9yAPWnbRhi3nMkhpXx5hme1jACkwoB5W7aXGAUkbCyT+3GMxx9Nd x7duIREjkxc2GAgqDNzNtiQ7ShVVmxPFCDt2Pf0BbD3LT8zcuNbH4bpKip/4XrJrlzbF Raug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:content-language:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:accept-language :in-reply-to:references:message-id:date:thread-index:thread-topic :subject:cc:to:from; bh=MULm8cSl1rOWdI4Z+I9EJhhWx9IxpqpPnaHIARCpafU=; fh=YuQ2HYM0ogrOAXuvY8ydVB2W+pbPvBp+UkRrPI8gy6s=; b=DkW/RJJ72Rcs04EHHnp8pctCloSJGrtV+f4cCDxYmAAgUDMWCehPBb3/bVEWiuBBQ2 zjdAc/O1SUK9kjMntpx1xFZ5cfqpqUNqfuV4fV9Np4jivx5h+xh5tBeuXURcRLpmUsvv T9QAjoOdpTDpwDZcjIKDqN9DvA4VVh4zisGar0wv5E4xXehoYLPcGNUdaLEu0gsU+eD0 IXmcP4txO0LjKCAw2APSULetcS0r/nCSFShAov8BzZsDXP12k3Zt20XoQSMgSQBbVlZq ETiYZNZldIUBQhp6x03ScexHn5tQALyzcqXn6AB2RIz2G0NkpGpAZGNFQahFadQolhwH XakQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-19338-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-19338-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id i7-20020a05620a0a0700b0078324a9ede1si1162759qka.524.2024.01.08.02.35.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jan 2024 02:35:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-19338-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-19338-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-19338-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id C0CA51C2209F for ; Mon, 8 Jan 2024 10:35:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BC23F14003; Mon, 8 Jan 2024 10:35:05 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from eu-smtp-delivery-151.mimecast.com (eu-smtp-delivery-151.mimecast.com [185.58.86.151]) (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 BD35C13FF5 for ; Mon, 8 Jan 2024 10:35:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ACULAB.COM Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=aculab.com Received: from AcuMS.aculab.com (156.67.243.121 [156.67.243.121]) by relay.mimecast.com with ESMTP with both STARTTLS and AUTH (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id uk-mta-131-SSdTflTDNiSgu7lU4QYbVg-1; Mon, 08 Jan 2024 10:35:00 +0000 X-MC-Unique: SSdTflTDNiSgu7lU4QYbVg-1 Received: from AcuMS.Aculab.com (10.202.163.6) by AcuMS.aculab.com (10.202.163.6) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Mon, 8 Jan 2024 10:34:35 +0000 Received: from AcuMS.Aculab.com ([::1]) by AcuMS.aculab.com ([::1]) with mapi id 15.00.1497.048; Mon, 8 Jan 2024 10:34:35 +0000 From: David Laight To: 'Andrew Lunn' , =?iso-8859-2?Q?Petr_Tesa=F8=EDk?= CC: Eric Dumazet , Alexandre Torgue , Jose Abreu , "David S. Miller" , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , "Chen-Yu Tsai" , Jernej Skrabec , "Samuel Holland" , "open list:STMMAC ETHERNET DRIVER" , "moderated list:ARM/STM32 ARCHITECTURE" , "moderated list:ARM/STM32 ARCHITECTURE" , open list , "open list:ARM/Allwinner sunXi SoC support" , Jiri Pirko Subject: RE: [PATCH] net: stmmac: protect statistics updates with a spinlock Thread-Topic: [PATCH] net: stmmac: protect statistics updates with a spinlock Thread-Index: AQHaP/3Ni9qIc9t6xUGHU0aBdMePobDPuW8A Date: Mon, 8 Jan 2024 10:34:35 +0000 Message-ID: References: <20240105091556.15516-1-petr@tesarici.cz> <20240105113402.0f5f1232@meshulam.tesarici.cz> <20240105121447.11ae80d1@meshulam.tesarici.cz> <20240105142732.1903bc70@meshulam.tesarici.cz> <20240105154558.2ca38aca@meshulam.tesarici.cz> In-Reply-To: Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable From: Andrew Lunn > Sent: 05 January 2024 17:37 >=20 > > This only leaves an atomic_t in hard irq context. I have tried to find > > something that could relax the requirement, but AFAICS at least some > > setups use several interrupts that can be delivered to different CPUs > > simultaneously, and all of them will walk over all channels. So we're > > left with an atomic_t here. >=20 > You might want to consider per CPU statistics. Since each CPU has its > own structure of statistics, you don't need atomic. >=20 > The code actually using the statistics then needs to sum up the per > CPU statistics, and using syncp should be sufficient for that. Doesn't that consume rather a lot of memory on systems with 'silly numbers' of cpu? Updating an atomic_t is (pretty much) the same as taking a lock. unlock() is also likely to also contain an atomic operation. So if you update more than two atomic_t it is likely that a lock will be faster. =09David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1= PT, UK Registration No: 1397386 (Wales)