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 72FFB44098; Wed, 22 May 2024 17:37:45 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EC29D402C2; Wed, 22 May 2024 17:37:44 +0200 (CEST) Received: from mail-pf1-f176.google.com (mail-pf1-f176.google.com [209.85.210.176]) by mails.dpdk.org (Postfix) with ESMTP id F1BC7400D6 for ; Wed, 22 May 2024 17:37:43 +0200 (CEST) Received: by mail-pf1-f176.google.com with SMTP id d2e1a72fcca58-6f447976de7so2418067b3a.1 for ; Wed, 22 May 2024 08:37:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1716392263; x=1716997063; 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=OCsoByC9NfL7ZEf7FKgJF/1Tjsr7yQNB4pkw9bz2O/g=; b=wJDhi4DV8iQ9G5bOulMjnOct3P9G5g77am5W8/iJO7xMODpyUOnrxiGqHX+FeapD3k zTEKneLNA/wGCPXunM45+RHFJoKli+C/yJWKkBWfU+hL4I5Y5mc0Y87eDYfJb9+skcG5 CKtfVgFPY7SThA7SdnZoZBXi7unM7oYT1S3fvwVLL4Cwsp+WRK9U10xcwd9gt9JyAUKu b0ceSM/F70Pv3uMkjUrTOlXOFlI/NKY+ZryhmZdQL93xEK3SyDx/2kC+j1a2mI5tHNID hUN+qFUxFWcqp3/Wwq9OBqy/WkyKn4eMapYAtk0SEu9TXr0Df9dK+6ms8J/lROfDd5e/ 5YmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716392263; x=1716997063; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OCsoByC9NfL7ZEf7FKgJF/1Tjsr7yQNB4pkw9bz2O/g=; b=gF0Kr1t3+vDPR6HVo8315/4JJeQ+5H8L06Cm9KPBLQ2/FapzZ3zPe8mWZptoPFeCvu PxxYTYn+vz+NsKASHtrBWpxMAcF3QBXM/nJ0O4TFpPk74+EVm9Jp1yodmS8WRxH3ck+R CyFdcP6b56+POp7MRSDb/7ebPF0IRalftCMQ9A/z9qxmrjpXNYOZZKN/SM5UHfOs9YwB naqwoVhoQxSH2yrFxWmsPpSXDqCoCVAkDbXMC+Q7KW7psaaAdUSwcd4bRSmjBaDGpbGO nwz8iw4YiZsheZLHte3n+7x7UPS07GABwf8vRem3fCOyF+xhDfxt904YwWQnUu72QfQh YY5Q== X-Gm-Message-State: AOJu0Yz4rwC8xaokxB3NIeMaiRjqTBWbRwwcjLU5iQggg6sf7BFftMyg AEftgT0AAa9lhsVptLufXsqvQhvQR/13mihMh6tVy/lALeP2FaBAsJw7NcHrIxoWs7TVNrKOE7D CSRM= X-Google-Smtp-Source: AGHT+IE4mQVIiuMSIEr0GJGJEWDtSzvHbMImrvTdevHVZBFi+NlddrKrhndk7yH3s+O27BRDl60ULQ== X-Received: by 2002:a05:6a00:2311:b0:6ec:faff:ec1f with SMTP id d2e1a72fcca58-6f6d606a5a9mr2578771b3a.11.1716392263014; Wed, 22 May 2024 08:37:43 -0700 (PDT) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-6f66e4a24f4sm14067354b3a.0.2024.05.22.08.37.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 May 2024 08:37:42 -0700 (PDT) Date: Wed, 22 May 2024 08:37:41 -0700 From: Stephen Hemminger To: Morten =?UTF-8?B?QnLDuHJ1cA==?= Cc: , "Tyler Retzlaff" Subject: Re: [PATCH v9 1/8] eal: generic 64 bit counter Message-ID: <20240522083741.64078d7e@hermes.local> In-Reply-To: <98CBD80474FA8B44BF855DF32C47DC35E9F488@smartserver.smartshare.dk> References: <20240510050507.14381-1-stephen@networkplumber.org> <20240521201801.126886-1-stephen@networkplumber.org> <20240521201801.126886-2-stephen@networkplumber.org> <98CBD80474FA8B44BF855DF32C47DC35E9F488@smartserver.smartshare.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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 On Wed, 22 May 2024 10:31:39 +0200 Morten Br=C3=B8rup wrote: > > +/* On 32 bit platform, need to use atomic to avoid load/store tearing = */ > > +typedef RTE_ATOMIC(uint64_t) rte_counter64_t; =20 >=20 > As shown by Godbolt experiments discussed in a previous thread [2], non-t= earing 64 bit counters can be implemented without using atomic instructions= on all 32 bit architectures supported by DPDK. So we should use the counte= r/offset design pattern for RTE_ARCH_32 too. >=20 > [2]: https://inbox.dpdk.org/dev/98CBD80474FA8B44BF855DF32C47DC35E9F433@sm= artserver.smartshare.dk/ This code built with -O3 and -m32 on godbolt shows split problem. #include typedef uint64_t rte_counter64_t; void rte_counter64_add(rte_counter64_t *counter, uint32_t val) { *counter +=3D val; } =E2=80=A6 *counter =3D val; } rte_counter64_add: push ebx mov eax, DWORD PTR [esp+8] xor ebx, ebx mov ecx, DWORD PTR [esp+12] add DWORD PTR [eax], ecx adc DWORD PTR [eax+4], ebx pop ebx ret rte_counter64_read: mov eax, DWORD PTR [esp+4] mov edx, DWORD PTR [eax+4] mov eax, DWORD PTR [eax] ret rte_counter64_set: movq xmm0, QWORD PTR [esp+8] mov eax, DWORD PTR [esp+4] movq QWORD PTR [eax], xmm0 ret