Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

tools: Update context analysis macros in compiler_types.h

In sync with the main kernel headers, include a stub version of
compiler-context-analysis.h in tools/include/linux/compiler_types.h and
remove the sparse context tracking definitions.

Since tools/ headers are generally self-contained, provide a standalone
tools/include/linux/compiler-context-analysis.h with no-op stubs for now. Also
clean up redundant stubs in tools/testing/shared/linux/kernel.h that are now
redundant.

This fixes build errors in tools/testing/radix-tree/ where headers from
include/linux/ (like cleanup.h) are used directly and expect these
macros to be defined:

| cc -I../shared -I. -I../../include -I../../arch/x86/include -I../../../lib -g -Og -Wall -D_LGPL_SOURCE -fsanitize=address -fsanitize=undefined -c -o radix-tree.o radix-tree.c
| In file included from ../shared/linux/cleanup.h:2,
| from ../shared/linux/../../../../include/linux/idr.h:18,
| from ../shared/linux/idr.h:5,
| from radix-tree.c:18:
| ../shared/linux/../../../../include/linux/idr.h: In function ‘class_idr_alloc_destructor’:
| ../shared/linux/../../../../include/linux/cleanup.h:283:9: error: expected declaration specifiers before ‘__no_context_analysis’
| 283 | __no_context_analysis \
| | ^~~~~~~~~~~~~~~~~~~~~

Closes: https://lore.kernel.org/oe-lkp/202601261546.d7ae2447-lkp@intel.com
Reported-by: kernel test robot <oliver.sang@intel.com>
Signed-off-by: Marco Elver <elver@google.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Tested-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Link: https://patch.msgid.link/20260127111428.3747328-1-elver@google.com

authored by

Marco Elver and committed by
Peter Zijlstra
944e3f75 e6de0724

+43 -19
+42
tools/include/linux/compiler-context-analysis.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + #ifndef _TOOLS_LINUX_COMPILER_CONTEXT_ANALYSIS_H 3 + #define _TOOLS_LINUX_COMPILER_CONTEXT_ANALYSIS_H 4 + 5 + /* 6 + * Macros and attributes for compiler-based static context analysis. 7 + * No-op stubs for tools. 8 + */ 9 + 10 + #define __guarded_by(...) 11 + #define __pt_guarded_by(...) 12 + 13 + #define context_lock_struct(name, ...) struct __VA_ARGS__ name 14 + 15 + #define __no_context_analysis 16 + #define __context_unsafe(comment) 17 + #define context_unsafe(...) ({ __VA_ARGS__; }) 18 + #define context_unsafe_alias(p) 19 + #define disable_context_analysis() 20 + #define enable_context_analysis() 21 + 22 + #define __must_hold(...) 23 + #define __must_not_hold(...) 24 + #define __acquires(...) 25 + #define __cond_acquires(ret, x) 26 + #define __releases(...) 27 + #define __acquire(x) (void)0 28 + #define __release(x) (void)0 29 + 30 + #define __must_hold_shared(...) 31 + #define __acquires_shared(...) 32 + #define __cond_acquires_shared(ret, x) 33 + #define __releases_shared(...) 34 + #define __acquire_shared(x) (void)0 35 + #define __release_shared(x) (void)0 36 + 37 + #define __acquire_ret(call, expr) (call) 38 + #define __acquire_shared_ret(call, expr) (call) 39 + #define __acquires_ret 40 + #define __acquires_shared_ret 41 + 42 + #endif /* _TOOLS_LINUX_COMPILER_CONTEXT_ANALYSIS_H */
+1 -15
tools/include/linux/compiler_types.h
··· 13 13 #define __has_builtin(x) (0) 14 14 #endif 15 15 16 - #ifdef __CHECKER__ 17 - /* context/locking */ 18 - # define __must_hold(x) __attribute__((context(x,1,1))) 19 - # define __acquires(x) __attribute__((context(x,0,1))) 20 - # define __releases(x) __attribute__((context(x,1,0))) 21 - # define __acquire(x) __context__(x,1) 22 - # define __release(x) __context__(x,-1) 23 - #else /* __CHECKER__ */ 24 - /* context/locking */ 25 - # define __must_hold(x) 26 - # define __acquires(x) 27 - # define __releases(x) 28 - # define __acquire(x) (void)0 29 - # define __release(x) (void)0 30 - #endif /* __CHECKER__ */ 16 + #include <linux/compiler-context-analysis.h> 31 17 32 18 /* Compiler specific macros. */ 33 19 #ifdef __GNUC__
-4
tools/testing/shared/linux/kernel.h
··· 21 21 #define schedule() 22 22 #define PAGE_SHIFT 12 23 23 24 - #define __acquires(x) 25 - #define __releases(x) 26 - #define __must_hold(x) 27 - 28 24 #define EXPORT_PER_CPU_SYMBOL_GPL(x) 29 25 #endif /* _KERNEL_H */