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 mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by smtp.lore.kernel.org (Postfix) with ESMTP id D983FC10F1A for ; Thu, 9 May 2024 11:37:12 +0000 (UTC) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BF03A402ED; Thu, 9 May 2024 13:37:11 +0200 (CEST) Received: from dkmailrelay1.smartsharesystems.com (smartserver.smartsharesystems.com [77.243.40.215]) by mails.dpdk.org (Postfix) with ESMTP id 04982402E9 for ; Thu, 9 May 2024 13:37:10 +0200 (CEST) Received: from smartserver.smartsharesystems.com (smartserver.smartsharesys.local [192.168.4.10]) by dkmailrelay1.smartsharesystems.com (Postfix) with ESMTP id B197F20FA4; Thu, 9 May 2024 13:37:10 +0200 (CEST) Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Subject: RE: [RFC v3] net/af_packet: make stats reset reliable Date: Thu, 9 May 2024 13:37:09 +0200 X-MimeOLE: Produced By Microsoft Exchange V6.5 Message-ID: <98CBD80474FA8B44BF855DF32C47DC35E9F432@smartserver.smartshare.dk> In-Reply-To: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [RFC v3] net/af_packet: make stats reset reliable Thread-Index: Adqh84CmwFhkYyPPQ4es3DOyZ6mR/wAD/A4Q References: <20240425174617.2126159-1-ferruh.yigit@amd.com> <20240503154547.392069-1-ferruh.yigit@amd.com> <20240503150011.55681b97@hermes.local> <432fb280-96e3-4079-b987-990d509b8c79@lysator.liu.se> <20240508082339.6bf74202@hermes.local> <834102e5-8f4b-4b67-9f62-8e8f61403b39@amd.com> <20240508135418.55505105@hermes.local> <98CBD80474FA8B44BF855DF32C47DC35E9F431@smartserver.smartshare.dk> From: =?iso-8859-1?Q?Morten_Br=F8rup?= To: "Bruce Richardson" Cc: "Stephen Hemminger" , "Ferruh Yigit" , =?iso-8859-1?Q?Mattias_R=F6nnblom?= , "John W. Linville" , "Thomas Monjalon" , , =?iso-8859-1?Q?Mattias_R=F6nnblom?= X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org > From: Bruce Richardson [mailto:bruce.richardson@intel.com] > Sent: Thursday, 9 May 2024 11.30 >=20 > On Thu, May 09, 2024 at 09:43:16AM +0200, Morten Br=F8rup wrote: > > > From: Stephen Hemminger [mailto:stephen@networkplumber.org] > > > Sent: Wednesday, 8 May 2024 22.54 > > > > > > On Wed, 8 May 2024 20:48:06 +0100 > > > Ferruh Yigit wrote: > > > > > > > > > > > > > The idea of load tearing is crazy talk of integral types. It > would > > > break so many things. > > > > > It is the kind of stupid compiler thing that would send Linus = on > a > > > rant and get > > > > > the GCC compiler writers in trouble. > > > > > > > > > > The DPDK has always favored performance over strict safety = guard > > > rails everywhere. > > > > > Switching to making every statistic an atomic operation is not > in > > > the spirit of > > > > > what is required. There is no strict guarantee necessary here. > > > > > > > > > > > > > I kind of agree with Stephen. > > > > > > > > Thanks Mattias, Morten & Stephen, it was informative discussion. > But > > > for > > > > *SW drivers* stats update and reset is not core functionality = and > I > > > > think we can be OK to get hit on corner cases, instead of > > > > over-engineering or making code more complex. > > > > > > > > > I forgot the case of 64 bit values on 32 bit platforms! > > > Mostly because haven't cared about 32 bit for years... > > > > > > The Linux kernel uses some wrappers to handle this. > > > On 64 bit platforms they become noop. > > > On 32 bit platform, they are protected by a seqlock and updates = are > > > wrapped by the sequence count. > > > > > > If we go this way, then doing similar Noop on 64 bit and atomic or > > > seqlock > > > on 32 bit should be done, but in common helper. > > > > > > Looking inside FreeBSD, it looks like that has changed over the > years as > > > well. > > > > > > if_inc_counter > > > counter_u64_add > > > atomic_add_64 > > > But the counters are always per-cpu in this case. So although it > does > > > use > > > locked operation, will always be uncontended. > > > > > > > > > PS: Does DPDK still actually support 32 bit on x86? Can it be > dropped > > > this cycle? > > > > We cannot drop 32 bit architecture support altogether. > > > > But, unlike the Linux kernel, DPDK doesn't need to support ancient = 32 > bit architectures. > > If the few 32 bit architectures supported by DPDK provide = non-tearing > 64 bit loads/stores, we don't need locks (in the fast path) for 64 bit > counters. > > > > In addition to 32 bit x86, DPDK supports ARMv7-A (a 32 bit > architecture) and 32 bit ARMv8. > > I don't think DPDK support any other 32 bit architectures. > > > > > > As Mattias mentioned, 32 bit x86 can use xmm registers to provide 64 > bit non-tearing load/store. > > >=20 > Testing this a little in godbolt, I see gcc using xmm registers on 32- > bit > when updating 64-bit counters, but clang doesn't seem to do so, but > instead > does 2 stores when writing back the 64 value. (I tried with both > volatile > and non-volatile 64-bit values, just to see if volatile would = encourage > clang to do a single store). >=20 > GCC: https://godbolt.org/z/9eqKfT3hz > Clang: https://godbolt.org/z/PT5EqKn4c Interesting. I guess this can be fixed by manually implementing what GCC does. I'm more concerned about finding a high-performance (in the fast path) = 64 bit counter solution for 32 bit ARM.