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 8F08343FE3; Wed, 8 May 2024 17:15:37 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0FBBF436CD; Wed, 8 May 2024 17:15:37 +0200 (CEST) Received: from mail-pj1-f43.google.com (mail-pj1-f43.google.com [209.85.216.43]) by mails.dpdk.org (Postfix) with ESMTP id 9A997436AB for ; Wed, 8 May 2024 17:15:35 +0200 (CEST) Received: by mail-pj1-f43.google.com with SMTP id 98e67ed59e1d1-2b33d011e5dso726716a91.0 for ; Wed, 08 May 2024 08:15:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1715181334; x=1715786134; 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=S0AvfbReZMjSwMPxSqiuZgCrt06aXIrECLNXHZWHUnQ=; b=2kAiATTvjdKU8vkvxtpvtekSmfB9fVcVBtLqamBq7hoJPkPxXIJRji3JKib3ln8eJ7 1Cd6jfSuN3Y6uxNIOu4Uh+GRmS5Jt0s85g2FAfmJPPfi2cuCM4K/Gpsn6cjGVzFEXJ49 HpfV51LHg975p9XDitOpFjJZ7MdSD+Vrh8iV+5+tan5rsesjaaXufMhNGvvHyd278aPc lPt1tHgCyxhG1ZsZmKb9Ngw5xleBZ2PKIeih1dijFYmhvWuoRi/EvCqRMR8UAHBdMRlC htXJqZQtZ08h8jaB/AI0500aeHzLowXLRr5wqo7/eaQnE0tsLX53xkBNYxXGqpsca37r 0DNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715181334; x=1715786134; 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=S0AvfbReZMjSwMPxSqiuZgCrt06aXIrECLNXHZWHUnQ=; b=qZArJnByqZdNOXydKoF2fulfLSzysM2uP8phmjqigWbStn6HxsXjxY0rsCY+meK9sF kSTeJrOhglSdQznzllhyEXIjRPXFXEA/0QUJxDRyBxYOOc/kC1NLNWvVKb6eGJyG2jEl YCpGU05vk3/q4+Q8Euk0jLrFSpAge6gjj5hVuzQyH9bfWceWmfiU9DLMdM31OHPoJT95 7HgMNzsuyApB3W7obcDdMWBB4zl4hbt5YBQTADHgYxdjQ6w7HBK9FABgE2EfK1ohrUhL oqLxNG7ApHxOm3fLZk1+s+23N7UtGMrdtD8qQBTXIQ30A5azguSMC2DXYzu3sJEBGpSe rsgw== X-Forwarded-Encrypted: i=1; AJvYcCWxLLuJVP/z10a5JhU9MSeqx3iLKPI8qjlRtRtsvu4Rw8K0BehSU9OtBB0rE784wJ+soo1c/cJeqSsZJgU= X-Gm-Message-State: AOJu0YyR5nwIAgPRIr9fg2RVgJMnFO/0Zr2KKpF213HWtRPDq4MwPD6q XxjeZZVY8Hv8OhTd2RPS98aRCJn01HJifmMQ91o+kf2W7xyDIwlChkqlGA2SBt8= X-Google-Smtp-Source: AGHT+IGszF2z3h5S0a+Lx0Vqjdfd098qteDjjj95CEyl4Q/D3X77usYdzC+Tvvq7mVMQdK3QVOcn4Q== X-Received: by 2002:a17:90a:bf0b:b0:2b1:314a:ea26 with SMTP id 98e67ed59e1d1-2b61157dba0mr4554071a91.7.1715181334473; Wed, 08 May 2024 08:15:34 -0700 (PDT) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2b62863a5b2sm1577051a91.6.2024.05.08.08.15.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 May 2024 08:15:34 -0700 (PDT) Date: Wed, 8 May 2024 08:15:30 -0700 From: Stephen Hemminger To: Morten =?UTF-8?B?QnLDuHJ1cA==?= Cc: Mattias =?UTF-8?B?UsO2bm5ibG9t?= , Mattias =?UTF-8?B?UsO2bm5ibG9t?= , , "Heng Wang" , "Tyler Retzlaff" Subject: Re: [RFC v7 3/6] eal: add exactly-once bit access functions Message-ID: <20240508081530.5d5c5d25@hermes.local> In-Reply-To: <98CBD80474FA8B44BF855DF32C47DC35E9F428@smartserver.smartshare.dk> References: <20240502055706.112443-2-mattias.ronnblom@ericsson.com> <20240505083737.118649-1-mattias.ronnblom@ericsson.com> <20240505083737.118649-4-mattias.ronnblom@ericsson.com> <98CBD80474FA8B44BF855DF32C47DC35E9F426@smartserver.smartshare.dk> <355b3d73-94a8-4734-8934-22081d6e7b11@lysator.liu.se> <98CBD80474FA8B44BF855DF32C47DC35E9F428@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, 8 May 2024 09:33:43 +0200 Morten Br=C3=B8rup wrote: > > What more specifically did you have in mind? READ_ONCE() and > > WRITE_ONCE()? They give almost no guarantees. Very much relaxed. =20 >=20 > The way I read it, they do provide memory ordering guarantees. >=20 > Ignore that the kernel's "once" functions operates on words and this RFC = operates on bits, the behavior is the same. Either there are memory orderin= g guarantees, or there are not. The kernel's READ_ONCE/WRITE_ONCE are compiler only ordering, i.e only appl= y to single CPU. RTFM memory-barriers.txt.. GUARANTEES ---------- There are some minimal guarantees that may be expected of a CPU: (*) On any given CPU, dependent memory accesses will be issued in order, w= ith respect to itself. This means that for: Q =3D READ_ONCE(P); D =3D READ_ONCE(*Q); the CPU will issue the following memory operations: Q =3D LOAD P, D =3D LOAD *Q and always in that order. However, on DEC Alpha, READ_ONCE() also emits a memory-barrier instruction, so that a DEC Alpha CPU will instead issue the following memory operations: Q =3D LOAD P, MEMORY_BARRIER, D =3D LOAD *Q, MEMORY_BARRIER Whether on DEC Alpha or not, the READ_ONCE() also prevents compiler mischief. (*) Overlapping loads and stores within a particular CPU will appear to be ordered within that CPU. This means that for: a =3D READ_ONCE(*X); WRITE_ONCE(*X, b); the CPU will only issue the following sequence of memory operations: a =3D LOAD *X, STORE *X =3D b And for: WRITE_ONCE(*X, c); d =3D READ_ONCE(*X); the CPU will only issue: STORE *X =3D c, d =3D LOAD *X (Loads and stores overlap if they are targeted at overlapping pieces of memory).