From patchwork Tue Oct 24 10:22:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Will Deacon X-Patchwork-Id: 116934 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp5632609qgn; Tue, 24 Oct 2017 03:23:26 -0700 (PDT) X-Google-Smtp-Source: ABhQp+RH0PAeEI4a9oywNTssfBnmz0IybK0ecHNYRC4APPny2BJrDgYcida6nbxp5O0yWvfXB2ir X-Received: by 10.98.245.21 with SMTP id n21mr16083792pfh.68.1508840606406; Tue, 24 Oct 2017 03:23:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508840606; cv=none; d=google.com; s=arc-20160816; b=RNQDa+BJpQzggdc3NyVmDgN5uHO3NG0Z87iaEdqUQLDVSDWGS39m+fNrmLGXGBKurm 5ooANpybI5udPLUgjzGGcLwFb1Z+FO8D0MDj50+IPIBXYh3uTsjKqnW0Adu1LQAVugyq aTp/U+pGdGSxBKSiRdCrhB4M5q4J1NnoKtFfoljvAksUfqIxSslfTT9rcthjzz/YDQTn dLiiVmuHiVaJKJbKzRKUy5qSQoSxFp7Cp46p6BkZmu7zTgXFfleYPVPSfhrXRqLWVlDy 4puRY2wl3AhCjMghnDfqs7qg+PuMQjNj4aF0YnZcEy9KUtnTa1gWqw8ova9sJbR6Wnj3 Rv8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=yWgVFjXSrodRr/Kc1P2vdxUsVuaVMh1rWhr8b8boYDg=; b=VYdwoyis1mtKKlATz8mraPZnkHvwMVQGzjtaGF4UpWTnJgKR02bU94gY5CDzzFkzQ+ IImmlr7UpYemgfc9e05h+Hhy8VkK8AR1wWeEoL+oBzgvaWW/Mp0peZC5mU/I6Ml5E0R0 xtM2UBeoAgr2ZOCtaEZKfBNacOKJ9gHX5qABhkEV1oToEhVjlwxaqWTbiaypTX6bUBFM KQiCVsjUnsrGm5GyRPZVUNJU9XKRy67q9L41rgy3OoJ5hgzcC7q/qPwLJ1vX0nWV1r01 1INj4hPADr4XzNOjskconfYDtWEyKfivQvQYlzWoHggZkbf3yYxPxhrFgq5uhINbAldE 4ODw== ARC-Authentication-Results: i=1; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g65si6836276pfk.453.2017.10.24.03.23.26; Tue, 24 Oct 2017 03:23:26 -0700 (PDT) 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 S932688AbdJXKXX (ORCPT + 27 others); Tue, 24 Oct 2017 06:23:23 -0400 Received: from foss.arm.com ([217.140.101.70]:53036 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932502AbdJXKWv (ORCPT ); Tue, 24 Oct 2017 06:22:51 -0400 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 C776B15BF; Tue, 24 Oct 2017 03:22:50 -0700 (PDT) Received: from edgewater-inn.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 977DA3F25D; Tue, 24 Oct 2017 03:22:50 -0700 (PDT) Received: by edgewater-inn.cambridge.arm.com (Postfix, from userid 1000) id 1E4D91AE3528; Tue, 24 Oct 2017 11:22:51 +0100 (BST) From: Will Deacon To: mingo@kernel.org Cc: linux-kernel@vger.kernel.org, Will Deacon , "Paul E. McKenney" Subject: [PATCH v2 4/5] locking/barriers: Kill lockless_dereference() Date: Tue, 24 Oct 2017 11:22:49 +0100 Message-Id: <1508840570-22169-5-git-send-email-will.deacon@arm.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1508840570-22169-1-git-send-email-will.deacon@arm.com> References: <1508840570-22169-1-git-send-email-will.deacon@arm.com> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org lockless_dereference() is a nice idea, but it gained little traction in kernel code since its introduction three years ago. This is partly because it's a pain to type, but also because using READ_ONCE() instead has worked correctly on all architectures apart from Alpha, which is a fully supported but somewhat niche architecture these days. Now that READ_ONCE() has been upgraded to contain an implicit smp_read_barrier_depends() and the few callers of lockless_dereference() have been converted, we can remove lockless_dereference() altogether. Cc: Ingo Molnar Cc: "Paul E. McKenney" Signed-off-by: Will Deacon --- Documentation/memory-barriers.txt | 12 ------------ Documentation/translations/ko_KR/memory-barriers.txt | 12 ------------ include/linux/compiler.h | 20 -------------------- 3 files changed, 44 deletions(-) -- 2.1.4 diff --git a/Documentation/memory-barriers.txt b/Documentation/memory-barriers.txt index b759a60624fd..470a682f3fa4 100644 --- a/Documentation/memory-barriers.txt +++ b/Documentation/memory-barriers.txt @@ -1886,18 +1886,6 @@ There are some more advanced barrier functions: See Documentation/atomic_{t,bitops}.txt for more information. - (*) lockless_dereference(); - - This can be thought of as a pointer-fetch wrapper around the - smp_read_barrier_depends() data-dependency barrier. - - This is also similar to rcu_dereference(), but in cases where - object lifetime is handled by some mechanism other than RCU, for - example, when the objects removed only when the system goes down. - In addition, lockless_dereference() is used in some data structures - that can be used both with and without RCU. - - (*) dma_wmb(); (*) dma_rmb(); diff --git a/Documentation/translations/ko_KR/memory-barriers.txt b/Documentation/translations/ko_KR/memory-barriers.txt index a7a813258013..ec3b46e27b7a 100644 --- a/Documentation/translations/ko_KR/memory-barriers.txt +++ b/Documentation/translations/ko_KR/memory-barriers.txt @@ -1858,18 +1858,6 @@ Mandatory 배리어들은 SMP 시스템에서도 UP 시스템에서도 SMP 효 참고하세요. - (*) lockless_dereference(); - - 이 함수는 smp_read_barrier_depends() 데이터 의존성 배리어를 사용하는 - 포인터 읽어오기 래퍼(wrapper) 함수로 생각될 수 있습니다. - - 객체의 라이프타임이 RCU 외의 메커니즘으로 관리된다는 점을 제외하면 - rcu_dereference() 와도 유사한데, 예를 들면 객체가 시스템이 꺼질 때에만 - 제거되는 경우 등입니다. 또한, lockless_dereference() 은 RCU 와 함께 - 사용될수도, RCU 없이 사용될 수도 있는 일부 데이터 구조에 사용되고 - 있습니다. - - (*) dma_wmb(); (*) dma_rmb(); diff --git a/include/linux/compiler.h b/include/linux/compiler.h index 7d7b77da9716..5a1cab48442c 100644 --- a/include/linux/compiler.h +++ b/include/linux/compiler.h @@ -346,24 +346,4 @@ static __always_inline void __write_once_size(volatile void *p, void *res, int s (volatile typeof(x) *)&(x); }) #define ACCESS_ONCE(x) (*__ACCESS_ONCE(x)) -/** - * lockless_dereference() - safely load a pointer for later dereference - * @p: The pointer to load - * - * Similar to rcu_dereference(), but for situations where the pointed-to - * object's lifetime is managed by something other than RCU. That - * "something other" might be reference counting or simple immortality. - * - * The seemingly unused variable ___typecheck_p validates that @p is - * indeed a pointer type by using a pointer to typeof(*p) as the type. - * Taking a pointer to typeof(*p) again is needed in case p is void *. - */ -#define lockless_dereference(p) \ -({ \ - typeof(p) _________p1 = READ_ONCE(p); \ - typeof(*(p)) *___typecheck_p __maybe_unused; \ - smp_read_barrier_depends(); /* Dependency order vs. p above. */ \ - (_________p1); \ -}) - #endif /* __LINUX_COMPILER_H */