Skip to content

Commit 9ae1e99

Browse files
Peter Zijlstraacmel
authored andcommitted
perf tools: Remove broken __no_tail_call attribute
The GCC specific __attribute__((optimize)) attribute does not what is commonly expected and is explicitly recommended against using in production code by the GCC people. Unlike what is often expected, it doesn't add to the optimization flags, but it fully replaces them, loosing any and all optimization flags provided by the compiler commandline. The only guaranteed upon means of inhibiting tail-calls is by placing a volatile asm with side-effects after the call such that the tail-call simply cannot be done. Given the original commit wasn't specific on which calls were the problem, this removal might re-introduce the problem, which can then be re-analyzed and cured properly. Signed-off-by: Peter Zijlstra <peterz@infradead.org> Acked-by: Ard Biesheuvel <ardb@kernel.org> Acked-by: Miguel Ojeda <ojeda@kernel.org> Cc: Alexei Starovoitov <ast@kernel.org> Cc: Arnd Bergmann <arnd@arndb.de> Cc: Arvind Sankar <nivedita@alum.mit.edu> Cc: Daniel Borkmann <daniel@iogearbox.net> Cc: Geert Uytterhoeven <geert@linux-m68k.org> Cc: Ian Rogers <irogers@google.com> Cc: Josh Poimboeuf <jpoimboe@redhat.com> Cc: Kees Kook <keescook@chromium.org> Cc: Martin Liška <mliska@suse.cz> Cc: Nick Desaulniers <ndesaulniers@google.com> Cc: Randy Dunlap <rdunlap@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Link: http://lore.kernel.org/lkml/20201028081123.GT2628@hirez.programming.kicks-ass.net Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent 0dfbe4c commit 9ae1e99

3 files changed

Lines changed: 5 additions & 20 deletions

File tree

‎tools/include/linux/compiler-gcc.h‎

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,6 @@
2727
#define __pure __attribute__((pure))
2828
#endif
2929
#define noinline __attribute__((noinline))
30-
#ifdef __has_attribute
31-
#if __has_attribute(disable_tail_calls)
32-
#define __no_tail_call __attribute__((disable_tail_calls))
33-
#endif
34-
#endif
35-
#ifndef __no_tail_call
36-
#if GCC_VERSION > 40201
37-
#define __no_tail_call __attribute__((optimize("no-optimize-sibling-calls")))
38-
#else
39-
#define __no_tail_call
40-
#endif
41-
#endif
4230
#ifndef __packed
4331
#define __packed __attribute__((packed))
4432
#endif

‎tools/include/linux/compiler.h‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,6 @@
4747
#ifndef noinline
4848
#define noinline
4949
#endif
50-
#ifndef __no_tail_call
51-
#define __no_tail_call
52-
#endif
5350

5451
/* Are two types/vars the same type (ignoring qualifiers)? */
5552
#ifndef __same_type

‎tools/perf/tests/dwarf-unwind.c‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ static int unwind_entry(struct unwind_entry *entry, void *arg)
9595
return strcmp((const char *) symbol, funcs[idx]);
9696
}
9797

98-
__no_tail_call noinline int test_dwarf_unwind__thread(struct thread *thread)
98+
noinline int test_dwarf_unwind__thread(struct thread *thread)
9999
{
100100
struct perf_sample sample;
101101
unsigned long cnt = 0;
@@ -126,7 +126,7 @@ __no_tail_call noinline int test_dwarf_unwind__thread(struct thread *thread)
126126

127127
static int global_unwind_retval = -INT_MAX;
128128

129-
__no_tail_call noinline int test_dwarf_unwind__compare(void *p1, void *p2)
129+
noinline int test_dwarf_unwind__compare(void *p1, void *p2)
130130
{
131131
/* Any possible value should be 'thread' */
132132
struct thread *thread = *(struct thread **)p1;
@@ -145,7 +145,7 @@ __no_tail_call noinline int test_dwarf_unwind__compare(void *p1, void *p2)
145145
return p1 - p2;
146146
}
147147

148-
__no_tail_call noinline int test_dwarf_unwind__krava_3(struct thread *thread)
148+
noinline int test_dwarf_unwind__krava_3(struct thread *thread)
149149
{
150150
struct thread *array[2] = {thread, thread};
151151
void *fp = &bsearch;
@@ -164,12 +164,12 @@ __no_tail_call noinline int test_dwarf_unwind__krava_3(struct thread *thread)
164164
return global_unwind_retval;
165165
}
166166

167-
__no_tail_call noinline int test_dwarf_unwind__krava_2(struct thread *thread)
167+
noinline int test_dwarf_unwind__krava_2(struct thread *thread)
168168
{
169169
return test_dwarf_unwind__krava_3(thread);
170170
}
171171

172-
__no_tail_call noinline int test_dwarf_unwind__krava_1(struct thread *thread)
172+
noinline int test_dwarf_unwind__krava_1(struct thread *thread)
173173
{
174174
return test_dwarf_unwind__krava_2(thread);
175175
}

0 commit comments

Comments
 (0)