Skip to content

Commit 59ecbbe

Browse files
wildea01Ingo Molnar
authored andcommitted
locking/barriers: Kill lockless_dereference()
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. Signed-off-by: Will Deacon <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Paul E. McKenney <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Thomas Gleixner <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent 506458e commit 59ecbbe

File tree

3 files changed

+0
-44
lines changed

3 files changed

+0
-44
lines changed

Documentation/memory-barriers.txt

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1886,18 +1886,6 @@ There are some more advanced barrier functions:
18861886
See Documentation/atomic_{t,bitops}.txt for more information.
18871887

18881888

1889-
(*) lockless_dereference();
1890-
1891-
This can be thought of as a pointer-fetch wrapper around the
1892-
smp_read_barrier_depends() data-dependency barrier.
1893-
1894-
This is also similar to rcu_dereference(), but in cases where
1895-
object lifetime is handled by some mechanism other than RCU, for
1896-
example, when the objects removed only when the system goes down.
1897-
In addition, lockless_dereference() is used in some data structures
1898-
that can be used both with and without RCU.
1899-
1900-
19011889
(*) dma_wmb();
19021890
(*) dma_rmb();
19031891

Documentation/translations/ko_KR/memory-barriers.txt

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1858,18 +1858,6 @@ Mandatory 배리어들은 SMP 시스템에서도 UP 시스템에서도 SMP 효
18581858
참고하세요.
18591859

18601860

1861-
(*) lockless_dereference();
1862-
1863-
이 함수는 smp_read_barrier_depends() 데이터 의존성 배리어를 사용하는
1864-
포인터 읽어오기 래퍼(wrapper) 함수로 생각될 수 있습니다.
1865-
1866-
객체의 라이프타임이 RCU 외의 메커니즘으로 관리된다는 점을 제외하면
1867-
rcu_dereference() 와도 유사한데, 예를 들면 객체가 시스템이 꺼질 때에만
1868-
제거되는 경우 등입니다. 또한, lockless_dereference() 은 RCU 와 함께
1869-
사용될수도, RCU 없이 사용될 수도 있는 일부 데이터 구조에 사용되고
1870-
있습니다.
1871-
1872-
18731861
(*) dma_wmb();
18741862
(*) dma_rmb();
18751863

include/linux/compiler.h

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -346,24 +346,4 @@ static __always_inline void __write_once_size(volatile void *p, void *res, int s
346346
(volatile typeof(x) *)&(x); })
347347
#define ACCESS_ONCE(x) (*__ACCESS_ONCE(x))
348348

349-
/**
350-
* lockless_dereference() - safely load a pointer for later dereference
351-
* @p: The pointer to load
352-
*
353-
* Similar to rcu_dereference(), but for situations where the pointed-to
354-
* object's lifetime is managed by something other than RCU. That
355-
* "something other" might be reference counting or simple immortality.
356-
*
357-
* The seemingly unused variable ___typecheck_p validates that @p is
358-
* indeed a pointer type by using a pointer to typeof(*p) as the type.
359-
* Taking a pointer to typeof(*p) again is needed in case p is void *.
360-
*/
361-
#define lockless_dereference(p) \
362-
({ \
363-
typeof(p) _________p1 = READ_ONCE(p); \
364-
typeof(*(p)) *___typecheck_p __maybe_unused; \
365-
smp_read_barrier_depends(); /* Dependency order vs. p above. */ \
366-
(_________p1); \
367-
})
368-
369349
#endif /* __LINUX_COMPILER_H */

0 commit comments

Comments
 (0)