History

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.

Peter Zijlstra committed 6 years ago

Commit 9ae1e991 parent 0dfbe4c3 files · +5 −20Browse files

Unified · Split

3 files
  1. tools/include/linux/compiler-gcc.h +0 −12
  2. tools/include/linux/compiler.h +0 −3
  3. tools/perf/tests/dwarf-unwind.c +5 −5
tools/include/linux/compiler-gcc.h+0−12
@@ -27,18 +27,6 @@ · 26 unmodified lines
27#define __pure __attribute__((pure))27#define __pure __attribute__((pure))
28#endif28#endif
29#define noinline __attribute__((noinline))29#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
42#ifndef __packed30#ifndef __packed
43#define __packed __attribute__((packed))31#define __packed __attribute__((packed))
44#endif32#endif
tools/include/linux/compiler.h+0−3
@@ -47,9 +47,6 @@ · 46 unmodified lines
47#ifndef noinline47#ifndef noinline
48#define noinline48#define noinline
49#endif49#endif
50#ifndef __no_tail_call
51#define __no_tail_call
52#endif
53 50
54/* Are two types/vars the same type (ignoring qualifiers)? */51/* Are two types/vars the same type (ignoring qualifiers)? */
55#ifndef __same_type52#ifndef __same_type
tools/perf/tests/dwarf-unwind.c+5−5
@@ -95,7 +95,7 @@ static int unwind_entry(struct unwind_entry *entry, void *arg) · 94 unmodified lines
95 return strcmp((const char *) symbol, funcs[idx]);95 return strcmp((const char *) symbol, funcs[idx]);
96}96}
97 97
98__no_tail_call noinline int test_dwarf_unwind__thread(struct thread *thread)98noinline int test_dwarf_unwind__thread(struct thread *thread)
99{99{
100 struct perf_sample sample;100 struct perf_sample sample;
101 unsigned long cnt = 0;101 unsigned long cnt = 0;
@@ -126,7 +126,7 @@ __no_tail_call noinline int test_dwarf_unwind__thread(struct thread *thread) · 24 unmodified lines
126 126
127static int global_unwind_retval = -INT_MAX;127static int global_unwind_retval = -INT_MAX;
128 128
129__no_tail_call noinline int test_dwarf_unwind__compare(void *p1, void *p2)129noinline int test_dwarf_unwind__compare(void *p1, void *p2)
130{130{
131 /* Any possible value should be 'thread' */131 /* Any possible value should be 'thread' */
132 struct thread *thread = *(struct thread **)p1;132 struct thread *thread = *(struct thread **)p1;
@@ -145,7 +145,7 @@ __no_tail_call noinline int test_dwarf_unwind__compare(void *p1, void *p2) · 12 unmodified lines
145 return p1 - p2;145 return p1 - p2;
146}146}
147 147
148__no_tail_call noinline int test_dwarf_unwind__krava_3(struct thread *thread)148noinline int test_dwarf_unwind__krava_3(struct thread *thread)
149{149{
150 struct thread *array[2] = {thread, thread};150 struct thread *array[2] = {thread, thread};
151 void *fp = &bsearch;151 void *fp = &bsearch;
@@ -164,12 +164,12 @@ __no_tail_call noinline int test_dwarf_unwind__krava_3(struct thread *thread) · 12 unmodified lines
164 return global_unwind_retval;164 return global_unwind_retval;
165}165}
166 166
167__no_tail_call noinline int test_dwarf_unwind__krava_2(struct thread *thread)167noinline int test_dwarf_unwind__krava_2(struct thread *thread)
168{168{
169 return test_dwarf_unwind__krava_3(thread);169 return test_dwarf_unwind__krava_3(thread);
170}170}
171 171
172__no_tail_call noinline int test_dwarf_unwind__krava_1(struct thread *thread)172noinline int test_dwarf_unwind__krava_1(struct thread *thread)
173{173{
174 return test_dwarf_unwind__krava_2(thread);174 return test_dwarf_unwind__krava_2(thread);
175}175}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t