Patches contributed by Eötvös Lorand University
commit 2b7d0390a6d6d595f43ea3806639664afe5b9ebe
Author: Ingo Molnar <mingo@elte.hu>
Date: Wed Nov 12 13:17:38 2008 +0100
tracing: branch tracer, fix vdso crash
Impact: fix bootup crash
the branch tracer missed arch/x86/vdso/vclock_gettime.c from
disabling tracing, which caused such bootup crashes:
[ 201.840097] init[1]: segfault at 7fffed3fe7c0 ip 00007fffed3fea2e sp 000077
also clean up the ugly ifdefs in arch/x86/kernel/vsyscall_64.c by
creating DISABLE_UNLIKELY_PROFILE facility for code to turn off
instrumentation on a per file basis.
Signed-off-by: Ingo Molnar <mingo@elte.hu>
diff --git a/arch/x86/kernel/vsyscall_64.c b/arch/x86/kernel/vsyscall_64.c
index 2f90202e59b3..ece02932ea57 100644
--- a/arch/x86/kernel/vsyscall_64.c
+++ b/arch/x86/kernel/vsyscall_64.c
@@ -17,13 +17,8 @@
* want per guest time just set the kernel.vsyscall64 sysctl to 0.
*/
-/* Protect userspace from profiling */
-#ifdef CONFIG_TRACE_UNLIKELY_PROFILE
-# undef likely
-# undef unlikely
-# define likely(x) likely_notrace(x)
-# define unlikely(x) unlikely_notrace(x)
-#endif
+/* Disable profiling for userspace code: */
+#define DISABLE_UNLIKELY_PROFILE
#include <linux/time.h>
#include <linux/init.h>
diff --git a/arch/x86/vdso/vclock_gettime.c b/arch/x86/vdso/vclock_gettime.c
index 1ef0f90813d6..6e667631e7dc 100644
--- a/arch/x86/vdso/vclock_gettime.c
+++ b/arch/x86/vdso/vclock_gettime.c
@@ -9,6 +9,9 @@
* Also alternative() doesn't work.
*/
+/* Disable profiling for userspace code: */
+#define DISABLE_UNLIKELY_PROFILE
+
#include <linux/kernel.h>
#include <linux/posix-timers.h>
#include <linux/time.h>
diff --git a/include/linux/compiler.h b/include/linux/compiler.h
index 935e30cfaf3c..63b7d9089d6e 100644
--- a/include/linux/compiler.h
+++ b/include/linux/compiler.h
@@ -59,7 +59,11 @@ extern void __chk_io_ptr(const volatile void __iomem *);
* specific implementations come from the above header files
*/
-#ifdef CONFIG_TRACE_UNLIKELY_PROFILE
+/*
+ * Note: DISABLE_UNLIKELY_PROFILE can be used by special lowlevel code
+ * to disable branch tracing on a per file basis.
+ */
+#if defined(CONFIG_TRACE_UNLIKELY_PROFILE) && !defined(DISABLE_UNLIKELY_PROFILE)
struct ftrace_likely_data {
const char *func;
const char *file;
commit e25cf3db560e803292946ef23a30c69e341ce56f
Author: Ingo Molnar <mingo@elte.hu>
Date: Fri Oct 17 15:55:07 2008 +0200
lockdep: include/linux/lockdep.h - fix warning in net/bluetooth/af_bluetooth.c
fix this warning:
net/bluetooth/af_bluetooth.c:60: warning: ‘bt_key_strings’ defined but not used
net/bluetooth/af_bluetooth.c:71: warning: ‘bt_slock_key_strings’ defined but not used
this is a lockdep macro problem in the !LOCKDEP case.
We cannot convert it to an inline because the macro works on multiple types,
but we can mark the parameter used.
[ also clean up a misaligned tab in sock_lock_init_class_and_name() ]
[ also remove #ifdefs from around af_family_clock_key strings - which
were certainly added to get rid of the ugly build warnings. ]
Signed-off-by: Ingo Molnar <mingo@elte.hu>
diff --git a/include/linux/lockdep.h b/include/linux/lockdep.h
index fc9f8e88123b..8956daf64abd 100644
--- a/include/linux/lockdep.h
+++ b/include/linux/lockdep.h
@@ -336,10 +336,11 @@ static inline void lockdep_on(void)
# define lock_set_subclass(l, s, i) do { } while (0)
# define lockdep_init() do { } while (0)
# define lockdep_info() do { } while (0)
-# define lockdep_init_map(lock, name, key, sub) do { (void)(key); } while (0)
+# define lockdep_init_map(lock, name, key, sub) \
+ do { (void)(name); (void)(key); } while (0)
# define lockdep_set_class(lock, key) do { (void)(key); } while (0)
# define lockdep_set_class_and_name(lock, key, name) \
- do { (void)(key); } while (0)
+ do { (void)(key); (void)(name); } while (0)
#define lockdep_set_class_and_subclass(lock, key, sub) \
do { (void)(key); } while (0)
#define lockdep_set_subclass(lock, sub) do { } while (0)
diff --git a/include/net/sock.h b/include/net/sock.h
index c04f9e18ea22..2f47107f6d0f 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -815,7 +815,7 @@ static inline void sk_wmem_free_skb(struct sock *sk, struct sk_buff *skb)
*/
#define sock_lock_init_class_and_name(sk, sname, skey, name, key) \
do { \
- sk->sk_lock.owned = 0; \
+ sk->sk_lock.owned = 0; \
init_waitqueue_head(&sk->sk_lock.wq); \
spin_lock_init(&(sk)->sk_lock.slock); \
debug_check_no_locks_freed((void *)&(sk)->sk_lock, \
diff --git a/net/core/sock.c b/net/core/sock.c
index 5e2a3132a8c9..341e39456952 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -136,7 +136,6 @@
static struct lock_class_key af_family_keys[AF_MAX];
static struct lock_class_key af_family_slock_keys[AF_MAX];
-#ifdef CONFIG_DEBUG_LOCK_ALLOC
/*
* Make lock validator output more readable. (we pre-construct these
* strings build-time, so that runtime initialization of socket
@@ -187,7 +186,6 @@ static const char *af_family_clock_key_strings[AF_MAX+1] = {
"clock-AF_RXRPC" , "clock-AF_ISDN" , "clock-AF_PHONET" ,
"clock-AF_MAX"
};
-#endif
/*
* sk_callback_lock locking rules are per-address-family,
commit 708b8eae0fd532af73ea8350e6dcc10255ff7376
Merge: d98d38f2014a f21f237cf554
Author: Ingo Molnar <mingo@elte.hu>
Date: Wed Nov 12 12:39:21 2008 +0100
Merge branch 'linus' into core/locking
commit f88c4ae9f8c3939bee4337c75c7a673b5de7a8a7
Author: Ingo Molnar <mingo@elte.hu>
Date: Wed Nov 12 11:55:41 2008 +0100
tracing: branch tracer, tweak output
Impact: modify the tracer output, to make it a bit easier to read
Change the output from:
> bash-3471 [003] 357.014755: [INCORRECT] sched_info_dequeued:sched_stats.h:177
> bash-3471 [003] 357.014756: [correct] update_curr:sched_fair.c:489
> bash-3471 [003] 357.014758: [correct] calc_delta_fair:sched_fair.c:411
to:
> bash-3471 [003] 357.014755: [ MISS ] sched_info_dequeued:sched_stats.h:177
> bash-3471 [003] 357.014756: [ .... ] update_curr:sched_fair.c:489
> bash-3471 [003] 357.014758: [ .... ] calc_delta_fair:sched_fair.c:411
it's good to have fields aligned vertically, and the only important
information is a prediction miss, so display only that information.
Signed-off-by: Ingo Molnar <mingo@elte.hu>
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 83d38634bc90..728a46ec6b06 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -1657,7 +1657,7 @@ print_lat_fmt(struct trace_iterator *iter, unsigned int trace_idx, int cpu)
trace_assign_type(field, entry);
trace_seq_printf(s, "[%s] %s:%s:%d\n",
- field->correct ? "correct" : "INCORRECT",
+ field->correct ? " .... " : " MISS ",
field->func,
field->file,
field->line);
@@ -1808,7 +1808,7 @@ static enum print_line_t print_trace_fmt(struct trace_iterator *iter)
trace_assign_type(field, entry);
trace_seq_printf(s, "[%s] %s:%s:%d\n",
- field->correct ? "correct" : "INCORRECT",
+ field->correct ? " .... " : " MISS ",
field->func,
field->file,
field->line);
commit cb9382e5a94e54d0356d730954396c746ae66d6e
Merge: 74239072830e 642edba5f5c5
Author: Ingo Molnar <mingo@elte.hu>
Date: Wed Nov 12 11:50:51 2008 +0100
Merge branches 'tracing/fastboot', 'tracing/function-return-tracer' and 'tracing/ring-buffer' into tracing/core
commit 60a011c736e7dd09a0b01ca6a051a416f3f52ffb
Merge: d06bbd669539 19b3e9671c5a
Author: Ingo Molnar <mingo@elte.hu>
Date: Wed Nov 12 10:17:09 2008 +0100
Merge branch 'tracing/function-return-tracer' into tracing/fastboot
commit d06bbd669539215405874d8fe32ab65105e6c4bb
Merge: d844222a54c3 3e89c7bb92fc c1e7abbc7afc
Author: Ingo Molnar <mingo@elte.hu>
Date: Wed Nov 12 10:11:37 2008 +0100
Merge branches 'tracing/ftrace' and 'tracing/urgent' into tracing/core
Conflicts:
kernel/trace/ring_buffer.c
diff --cc kernel/trace/ring_buffer.c
index a6b8f9d7ac96,8c5cacb25a18,b08ee9f00c8d..c04c433fbc59
--- a/kernel/trace/ring_buffer.c
+++ b/kernel/trace/ring_buffer.c
@@@@ -18,6 -18,6 -18,33 +18,35 @@@@
#include "trace.h"
++ /* Global flag to disable all recording to ring buffers */
++ static int ring_buffers_off __read_mostly;
++
++ /**
++ * tracing_on - enable all tracing buffers
++ *
++ * This function enables all tracing buffers that may have been
++ * disabled with tracing_off.
++ */
++ void tracing_on(void)
++ {
++ ring_buffers_off = 0;
++ }
++
++ /**
++ * tracing_off - turn off all tracing buffers
++ *
++ * This function stops all tracing buffers from recording data.
++ * It does not disable any overhead the tracers themselves may
++ * be causing. This function simply causes all recording to
++ * the ring buffers to fail.
++ */
++ void tracing_off(void)
++ {
++ ring_buffers_off = 1;
++ }
++
+++#include "trace.h"
+++
/* Up this if you want to test the TIME_EXTENTS and normalization */
#define DEBUG_SHIFT 0
@@@@ -154,7 -154,8 -181,7 +183,8 @@@@ static inline int test_time_stamp(u64 d
struct ring_buffer_per_cpu {
int cpu;
struct ring_buffer *buffer;
- spinlock_t lock;
+ + spinlock_t reader_lock; /* serialize readers */
+ raw_spinlock_t lock;
struct lock_class_key lock_key;
struct list_head pages;
struct buffer_page *head_page; /* read from head */
@@@@ -188,62 -189,16 -215,32 +218,16 @@@@ struct ring_buffer_iter
u64 read_stamp;
};
+/* buffer may be either ring_buffer or ring_buffer_per_cpu */
#define RB_WARN_ON(buffer, cond) \
- do { \
- if (unlikely(cond)) { \
- atomic_inc(&buffer->record_disabled); \
- WARN_ON(1); \
- } \
- } while (0)
-
-#define RB_WARN_ON_RET(buffer, cond) \
- - do { \
- - if (unlikely(cond)) { \
+ + ({ \
+ + int _____ret = unlikely(cond); \
+ + if (_____ret) { \
atomic_inc(&buffer->record_disabled); \
WARN_ON(1); \
- return -1; \
} \
- } while (0)
-
- #define RB_WARN_ON_RET(buffer, cond) \
- do { \
- if (unlikely(cond)) { \
- atomic_inc(&buffer->record_disabled); \
- WARN_ON(1); \
- return; \
- } \
- } while (0)
-
- #define RB_WARN_ON_RET_INT(buffer, cond) \
- do { \
- if (unlikely(cond)) { \
- atomic_inc(&buffer->record_disabled); \
- WARN_ON(1); \
- return -1; \
- } \
- } while (0)
-
- #define RB_WARN_ON_RET_NULL(buffer, cond) \
- do { \
- if (unlikely(cond)) { \
- atomic_inc(&buffer->record_disabled); \
- WARN_ON(1); \
- return NULL; \
- } \
- - } while (0)
- -
- -#define RB_WARN_ON_ONCE(buffer, cond) \
- - do { \
- - static int once; \
- - if (unlikely(cond) && !once) { \
- - once++; \
- atomic_inc(&buffer->record_disabled); \
- WARN_ON(1); \
- } \
- } while (0)
-
- /* buffer must be ring_buffer not per_cpu */
- #define RB_WARN_ON_UNLOCK(buffer, cond) \
- do { \
- if (unlikely(cond)) { \
- mutex_unlock(&buffer->mutex); \
- - atomic_inc(&buffer->record_disabled); \
- - WARN_ON(1); \
- return -1; \
- - } \
- - } while (0)
+ + _____ret; \
+ + })
/**
* check_pages - integrity check of buffer pages
@@@@ -257,14 -212,18 -254,14 +241,18 @@@@ static int rb_check_pages(struct ring_b
struct list_head *head = &cpu_buffer->pages;
struct buffer_page *page, *tmp;
- RB_WARN_ON_RET_INT(cpu_buffer, head->next->prev != head);
- RB_WARN_ON_RET_INT(cpu_buffer, head->prev->next != head);
- RB_WARN_ON_RET(cpu_buffer, head->next->prev != head);
- RB_WARN_ON_RET(cpu_buffer, head->prev->next != head);
+ + if (RB_WARN_ON(cpu_buffer, head->next->prev != head))
+ + return -1;
+ + if (RB_WARN_ON(cpu_buffer, head->prev->next != head))
+ + return -1;
list_for_each_entry_safe(page, tmp, head, list) {
- RB_WARN_ON_RET_INT(cpu_buffer,
- RB_WARN_ON_RET(cpu_buffer,
- - page->list.next->prev != &page->list);
- RB_WARN_ON_RET_INT(cpu_buffer,
- RB_WARN_ON_RET(cpu_buffer,
- - page->list.prev->next != &page->list);
+ + if (RB_WARN_ON(cpu_buffer,
+ + page->list.next->prev != &page->list))
+ + return -1;
+ + if (RB_WARN_ON(cpu_buffer,
+ + page->list.prev->next != &page->list))
+ + return -1;
}
return 0;
@@@@ -321,7 -280,8 -318,7 +309,8 @@@@ rb_allocate_cpu_buffer(struct ring_buff
cpu_buffer->cpu = cpu;
cpu_buffer->buffer = buffer;
- spin_lock_init(&cpu_buffer->lock);
+ + spin_lock_init(&cpu_buffer->reader_lock);
+ cpu_buffer->lock = (raw_spinlock_t)__RAW_SPIN_LOCK_UNLOCKED;
INIT_LIST_HEAD(&cpu_buffer->pages);
page = kzalloc_node(ALIGN(sizeof(*page), cache_line_size()),
@@@@ -470,13 -430,15 -467,13 +459,15 @@@@ rb_remove_pages(struct ring_buffer_per_
synchronize_sched();
for (i = 0; i < nr_pages; i++) {
- RB_WARN_ON_RET(cpu_buffer, list_empty(&cpu_buffer->pages));
- BUG_ON(list_empty(&cpu_buffer->pages));
+ + if (RB_WARN_ON(cpu_buffer, list_empty(&cpu_buffer->pages)))
+ + return;
p = cpu_buffer->pages.next;
page = list_entry(p, struct buffer_page, list);
list_del_init(&page->list);
free_buffer_page(page);
}
- RB_WARN_ON_RET(cpu_buffer, list_empty(&cpu_buffer->pages));
- BUG_ON(list_empty(&cpu_buffer->pages));
+ + if (RB_WARN_ON(cpu_buffer, list_empty(&cpu_buffer->pages)))
+ + return;
rb_reset_cpu(cpu_buffer);
@@@@ -498,7 -460,8 -495,7 +489,8 @@@@ rb_insert_pages(struct ring_buffer_per_
synchronize_sched();
for (i = 0; i < nr_pages; i++) {
- RB_WARN_ON_RET(cpu_buffer, list_empty(pages));
- BUG_ON(list_empty(pages));
+ + if (RB_WARN_ON(cpu_buffer, list_empty(pages)))
+ + return;
p = pages->next;
page = list_entry(p, struct buffer_page, list);
list_del_init(&page->list);
@@@@ -553,7 -516,10 -550,7 +545,10 @@@@ int ring_buffer_resize(struct ring_buff
if (size < buffer_size) {
/* easy case, just free pages */
- RB_WARN_ON_UNLOCK(buffer, nr_pages >= buffer->pages);
- BUG_ON(nr_pages >= buffer->pages);
+ + if (RB_WARN_ON(buffer, nr_pages >= buffer->pages)) {
+ + mutex_unlock(&buffer->mutex);
+ + return -1;
+ + }
rm_pages = buffer->pages - nr_pages;
@@@@ -572,8 -538,11 -569,7 +567,11 @@@@
* add these pages to the cpu_buffers. Otherwise we just free
* them all and return -ENOMEM;
*/
- RB_WARN_ON_UNLOCK(buffer, nr_pages <= buffer->pages);
- BUG_ON(nr_pages <= buffer->pages);
+ + if (RB_WARN_ON(buffer, nr_pages <= buffer->pages)) {
+ + mutex_unlock(&buffer->mutex);
+ + return -1;
+ + }
+
new_pages = nr_pages - buffer->pages;
for_each_buffer_cpu(buffer, cpu) {
@@@@ -596,7 -565,10 -592,7 +594,10 @@@@
rb_insert_pages(cpu_buffer, &pages, new_pages);
}
- RB_WARN_ON_UNLOCK(buffer, !list_empty(&pages));
- BUG_ON(!list_empty(&pages));
+ + if (RB_WARN_ON(buffer, !list_empty(&pages))) {
+ + mutex_unlock(&buffer->mutex);
+ + return -1;
+ + }
out:
buffer->pages = nr_pages;
@@@@ -684,7 -656,8 -680,7 +685,8 @@@@ static void rb_update_overflow(struct r
head += rb_event_length(event)) {
event = __rb_page_index(cpu_buffer->head_page, head);
- RB_WARN_ON_RET(cpu_buffer, rb_null_event(event));
- BUG_ON(rb_null_event(event));
+ + if (RB_WARN_ON(cpu_buffer, rb_null_event(event)))
+ + return;
/* Only count data entries */
if (event->type != RINGBUF_TYPE_DATA)
continue;
@@@@ -971,7 -946,8 -965,7 +975,8 @@@@ __rb_reserve_next(struct ring_buffer_pe
/* We reserved something on the buffer */
- RB_WARN_ON_RET_NULL(cpu_buffer, write > BUF_PAGE_SIZE);
- BUG_ON(write > BUF_PAGE_SIZE);
+ + if (RB_WARN_ON(cpu_buffer, write > BUF_PAGE_SIZE))
+ + return NULL;
event = __rb_page_index(tail_page, tail);
rb_update_event(event, type, length);
@@@@ -1652,7 -1631,8 -1660,7 +1666,8 @@@@ static void rb_advance_reader(struct ri
reader = rb_get_reader_page(cpu_buffer);
/* This function should not be called when buffer is empty */
- RB_WARN_ON_RET(cpu_buffer, !reader);
- BUG_ON(!reader);
+ + if (RB_WARN_ON(cpu_buffer, !reader))
+ + return;
event = rb_reader_event(cpu_buffer);
@@@@ -1679,8 -1659,9 -1687,7 +1694,9 @@@@ static void rb_advance_iter(struct ring
* Check if we are at the end of the buffer.
*/
if (iter->head >= rb_page_size(iter->head_page)) {
- RB_WARN_ON_RET(buffer,
- iter->head_page == cpu_buffer->commit_page);
- BUG_ON(iter->head_page == cpu_buffer->commit_page);
+ + if (RB_WARN_ON(buffer,
+ + iter->head_page == cpu_buffer->commit_page))
+ + return;
rb_inc_iter(iter);
return;
}
@@@@ -1693,9 -1674,10 -1700,8 +1709,10 @@@@
* This should not be called to advance the header if we are
* at the tail of the buffer.
*/
- RB_WARN_ON_RET(cpu_buffer,
- BUG_ON((iter->head_page == cpu_buffer->commit_page) &&
- (iter->head + length > rb_commit_index(cpu_buffer)));
+ + if (RB_WARN_ON(cpu_buffer,
+ (iter->head_page == cpu_buffer->commit_page) &&
- (iter->head + length > rb_commit_index(cpu_buffer)));
+ + (iter->head + length > rb_commit_index(cpu_buffer))))
+ + return;
rb_update_iter_read_stamp(iter, event);
@@@@ -1909,11 -1920,11 -1915,9 +1955,11 @@@@ ring_buffer_read_start(struct ring_buff
atomic_inc(&cpu_buffer->record_disabled);
synchronize_sched();
- local_irq_save(flags);
- spin_lock_irqsave(&cpu_buffer->lock, flags);
+ + spin_lock_irqsave(&cpu_buffer->reader_lock, flags);
+ __raw_spin_lock(&cpu_buffer->lock);
ring_buffer_iter_reset(iter);
- spin_unlock_irqrestore(&cpu_buffer->lock, flags);
+ __raw_spin_unlock(&cpu_buffer->lock);
- local_irq_restore(flags);
+ + spin_unlock_irqrestore(&cpu_buffer->reader_lock, flags);
return iter;
}
@@@@ -1999,13 -2015,15 -2003,11 +2050,15 @@@@ void ring_buffer_reset_cpu(struct ring_
if (!cpu_isset(cpu, buffer->cpumask))
return;
- local_irq_save(flags);
- spin_lock_irqsave(&cpu_buffer->lock, flags);
+ + spin_lock_irqsave(&cpu_buffer->reader_lock, flags);
+ +
+ __raw_spin_lock(&cpu_buffer->lock);
rb_reset_cpu(cpu_buffer);
- spin_unlock_irqrestore(&cpu_buffer->lock, flags);
+ __raw_spin_unlock(&cpu_buffer->lock);
- local_irq_restore(flags);
+ +
+ + spin_unlock_irqrestore(&cpu_buffer->reader_lock, flags);
}
/**
commit c1e7abbc7afc97367cd77c8f2895c2169a8f9c87
Merge: f21f237cf554 a358324466b1
Author: Ingo Molnar <mingo@elte.hu>
Date: Tue Nov 11 21:34:07 2008 +0100
Merge branch 'devel' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-2.6-trace into tracing/urgent
commit c280ea5e4c6ba0b38ed6b005150fe16a660e903b
Author: Ingo Molnar <mingo@elte.hu>
Date: Sat Nov 8 13:29:45 2008 +0100
x86: fix documentation typo in arch/x86/Kconfig
Impact: documentation update
Chris Snook pointed out that it's Core i7, not Core 7i.
Reported-by: Chris Snook <csnook@redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 38ae04bf6514..bacac556b189 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -963,7 +963,7 @@ config NUMA
local memory controller of the CPU and add some more
NUMA awareness to the kernel.
- For 64-bit this is recommended if the system is Intel Core 7i
+ For 64-bit this is recommended if the system is Intel Core i7
(or later), AMD Opteron, or EM64T NUMA.
For 32-bit this is only needed on (rare) 32-bit-only platforms
commit 19b3e9671c5a219b8c34da2cc66e0ce7c3a501ae
Author: Ingo Molnar <mingo@elte.hu>
Date: Tue Nov 11 11:57:02 2008 +0100
tracing: function return tracer, build fix
fix:
arch/x86/kernel/ftrace.c: In function 'ftrace_return_to_handler':
arch/x86/kernel/ftrace.c:112: error: implicit declaration of function 'cpu_clock'
cpu_clock() is implicitly included via a number of ways, but its real
location is sched.h. (Build failure is triggerable if enough other
kernel components are turned off.)
Signed-off-by: Ingo Molnar <mingo@elte.hu>
diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
index 9b2325a4d53c..16a571dea2ef 100644
--- a/arch/x86/kernel/ftrace.c
+++ b/arch/x86/kernel/ftrace.c
@@ -14,6 +14,7 @@
#include <linux/uaccess.h>
#include <linux/ftrace.h>
#include <linux/percpu.h>
+#include <linux/sched.h>
#include <linux/init.h>
#include <linux/list.h>