From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 97D3E48AFD for ; Thu, 13 Nov 2025 18:29:38 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 86D2440E21; Thu, 13 Nov 2025 18:29:38 +0100 (CET) Received: from mail-ot1-f45.google.com (mail-ot1-f45.google.com [209.85.210.45]) by mails.dpdk.org (Postfix) with ESMTP id 586BA40A7A for ; Thu, 13 Nov 2025 18:29:36 +0100 (CET) Received: by mail-ot1-f45.google.com with SMTP id 46e09a7af769-7c6d3676455so377624a34.2 for ; Thu, 13 Nov 2025 09:29:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1763054975; x=1763659775; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=TV3/bhvVGFDklC0x7Vlc+BjbX8DEVGEMr482rV+Nqxk=; b=yaaXWHkd0xkTtfxh8atIhsHQSpzbWH9fqse/pEZTDEkhu13/crwovbK+Ut0H9CfNRm BtPxOg/vAR+uwKpSJV511olUvvmGWkoMTWpm2JEcqfL77QZucL/eY4IFvP2JSKPmEHyp Gegkuog0A9kmXKGYESKPx+IH1y50VgAo77N+1hYb6zf/glploLFq1rGN95/RRz8pXlgE bLMbhb+4qUSupmfCEfDmiVX5LiwNhcBL88cYRlu+u42Ci8rspvwhKjpkvsbjGi6e0pT9 rD/G0rxFZCAW8GD36YBck2DILSWq5VMalJOAU/dxO3KG5jcWnBVGj8smbeLLxePrOtDx 7jgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763054975; x=1763659775; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=TV3/bhvVGFDklC0x7Vlc+BjbX8DEVGEMr482rV+Nqxk=; b=H3qhMnWNNOzRgE7e4Iq92/ifdvMQD4Vd6K46QdSW4AKTe6dZklpBAde9JvGJEMyXFB EeCRQ1nXKkHZTwB+HuOUpk+f0s3LKu5NCS9pcLlYnY6Rm3A7rxxtLIxnJCex+9o6xPrW FyLlPm4iTbEodnTfCTHHFadUNfid4F7J6/qZLPdoSIXQtw7aD4wWHp9f2aZr6UDnA4ik l4CiV82+odRJJG2jVpqnN1Y/3+SHfdXezuTgkAcMPLMWhsCaNx1r5j+XfvAFoI4kViZI DpIvn/jt2/dSNR9BjUijIoSbSxXxVG3VOhK4Jr9YNCx2cIS1XaYmz1VgdWK/EAgrITok fuxA== X-Forwarded-Encrypted: i=1; AJvYcCW8SQxjyypJm2XB53THJVO6UN3KqNdj2wvjigJTpVKoZYdkrzYNiMnYZPivbdr3NNDxQtgHWrU=@dpdk.org X-Gm-Message-State: AOJu0YwL/KBRqHceFSYS3kwUeWgTi+jGjCOWWKBy/4Q5+eWrKHTVdGpR oFO4cxZrDt7sJLKdX4kW+c2pkKtdUkGa+jDRDf/XICUXPfeT3jq7pyMqy8uNJ+4AeMY= X-Gm-Gg: ASbGncscFY073nY3lqx7sneLRyQel1vqpA4HOuzVPERvd2apUxPtNI8ObLm2o9mIE4d dLy+5DQhZO+RMZ27xfR3risRFQ2p+MirQRIFAl29sNT7m+acToSEy1IFAH9fiEqJuYbi7LXOwSi 26nmeQTIJSo25Lclifz0gzBPTA/svJzNkm7N3dBIcpk2qyDvqg4JsbvdjrOwMY32JQTjYE+pmK8 ZkRx4+v80YaCA2Le8Pp6zFCKzM5tBzidOHLiHQasdhg898K02PvdbOYWIF/F2JNUWNbsOSKeR58 XSAao31I6Lb4jINSq5hzzkLxS7EYeavoYs/uMAieuhEzF59wv/I22uJq0m6fP/qbeHZvUYjiFcK jDxlnUFUf3mg7UKHihgKBqeX5k54yqBX8FQzwJfEhxXNzAzsDiiyOTM9heDYWeS3bAQzGDlczzO 6vcE7jPBQl2OYRIxiz8l/7sjLWhniqAQ95shUgThPjYqM4 X-Google-Smtp-Source: AGHT+IHsS3tNQsHyBY2PGRVSeK0NY6Y+g3admlF4VpQG1iQBQxZydLtkk7UBlFbAH+ejTKiREfy4Iw== X-Received: by 2002:a05:6808:6411:b0:44f:8f27:e3d4 with SMTP id 5614622812f47-450745e4a3cmr3663036b6e.67.1763054975206; Thu, 13 Nov 2025 09:29:35 -0800 (PST) Received: from phoenix (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id 5614622812f47-4508a6d2adasm1262388b6e.19.2025.11.13.09.29.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Nov 2025 09:29:35 -0800 (PST) Date: Thu, 13 Nov 2025 09:29:10 -0800 From: Stephen Hemminger To: Zhichao Zeng Cc: dev@dpdk.org, stable@dpdk.org, Bruce Richardson , Anatoly Burakov , Ferruh Yigit , Wenzhuo Lu , Jeff Guo Subject: Re: [PATCH] net/ice: fix statistics read error Message-ID: <20251113092910.015df6eb@phoenix> In-Reply-To: <20251107074338.957352-1-zhichaox.zeng@intel.com> References: <20251107074338.957352-1-zhichaox.zeng@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org On Fri, 7 Nov 2025 15:43:38 +0800 Zhichao Zeng wrote: > The statistics contain 40 bits. The lower 32 bits are read first, followed > by the upper 8 bits. >=20 > In some cases, after reading the lower 32 bits, a carry occurs from the > lower bits, which causes the final statistics to be incorrect. >=20 > This commit fixes this issue. >=20 > Fixes: a37bde56314d ("net/ice: support statistics") > Cc: stable@dpdk.org >=20 > Signed-off-by: Zhichao Zeng This works but may still have issues under really high load. I have seen code like this (from ChatGPT) /* * Safely read a 64-bit counter split across two 32-bit registers. * Handles rollover and avoids inconsistency if low overflows * between high and low reads. */ static inline uint64_t read_hw_counter_64(void) { uint32_t hi1, lo, hi2; /* * Read high-low-high and check for wraparound: * if high changed, low overflowed during read =E2=80=94 reread. */ do { hi1 =3D read_reg32_high(); lo =3D read_reg32_low(); hi2 =3D read_reg32_high(); } while (hi1 !=3D hi2); return ((uint64_t)hi1 << 32) | lo; }