From patchwork Wed Nov 16 11:12:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 82486 Delivered-To: patch@linaro.org Received: by 10.140.97.165 with SMTP id m34csp92021qge; Wed, 16 Nov 2016 03:13:47 -0800 (PST) X-Received: by 10.99.65.65 with SMTP id o62mr7106323pga.73.1479294827376; Wed, 16 Nov 2016 03:13:47 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x62si31436396pgd.199.2016.11.16.03.13.47; Wed, 16 Nov 2016 03:13:47 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755609AbcKPLNj (ORCPT + 26 others); Wed, 16 Nov 2016 06:13:39 -0500 Received: from foss.arm.com ([217.140.101.70]:47984 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1422667AbcKPLNc (ORCPT ); Wed, 16 Nov 2016 06:13:32 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 08B56AD7; Wed, 16 Nov 2016 03:13:32 -0800 (PST) Received: from leverpostej.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 0739D3F318; Wed, 16 Nov 2016 03:13:30 -0800 (PST) From: Mark Rutland To: linux-kernel@vger.kernel.org Cc: Mark Rutland , David Howells , Jonathan Corbet , "Paul E. McKenney" , linux-doc@vger.kernel.org Subject: [PATCH] Documentation: circular-buffers: use READ_ONCE() Date: Wed, 16 Nov 2016 11:12:49 +0000 Message-Id: <1479294769-12723-1-git-send-email-mark.rutland@arm.com> X-Mailer: git-send-email 1.9.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org While the {READ,WRITE}_ONCE() macros should be used in preference to ACCESS_ONCE(), the circular buffer documentation uses the latter exclusively. To point people in the right direction, and as a step towards the eventual removal of ACCESS_ONCE(), update the documentation to use READ_ONCE(), as ACCESS_ONCE() is only used in a reader context in the circular buffer documentation. Signed-off-by: Mark Rutland Cc: David Howells Cc: Jonathan Corbet Cc: Paul E. McKenney Cc: linux-doc@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- Documentation/circular-buffers.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 1.9.1 Acked-by: David Howells Acked-by: Paul E. McKenney diff --git a/Documentation/circular-buffers.txt b/Documentation/circular-buffers.txt index 88951b1..4a824d2 100644 --- a/Documentation/circular-buffers.txt +++ b/Documentation/circular-buffers.txt @@ -161,7 +161,7 @@ The producer will look something like this: unsigned long head = buffer->head; /* The spin_unlock() and next spin_lock() provide needed ordering. */ - unsigned long tail = ACCESS_ONCE(buffer->tail); + unsigned long tail = READ_ONCE(buffer->tail); if (CIRC_SPACE(head, tail, buffer->size) >= 1) { /* insert one item into the buffer */ @@ -222,7 +222,7 @@ This will instruct the CPU to make sure the index is up to date before reading the new item, and then it shall make sure the CPU has finished reading the item before it writes the new tail pointer, which will erase the item. -Note the use of ACCESS_ONCE() and smp_load_acquire() to read the +Note the use of READ_ONCE() and smp_load_acquire() to read the opposition index. This prevents the compiler from discarding and reloading its cached value - which some compilers will do across smp_read_barrier_depends(). This isn't strictly needed if you can