Le 24/09/2018 Ã 17:52, Christophe Leroy a ÃcritÂ:
When switching powerpc to CONFIG_THREAD_INFO_IN_TASK, include/sched.h
has to be included in asm/smp.h for the following change, in order
to avoid uncomplete definition of task_struct:
-#define raw_smp_processor_id() (current_thread_info()->cpu)
+#define raw_smp_processor_id() (current->cpu)
But this generates the following compilation error, due to circular
header dependency.
ÂÂ CCÂÂÂÂÂ kernel/time/alarmtimer.o
In file included from ./arch/powerpc/include/asm/smp.h:31,
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ from ./include/linux/smp.h:64,
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ from ./include/linux/percpu.h:7,
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ from ./include/linux/hrtimer.h:22,
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ from kernel/time/alarmtimer.c:19:
./include/linux/sched.h:558:19: error: field 'dl_timer' has incomplete type
ÂÂ struct hrtimerÂÂ dl_timer;
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ ^~~~~~~~
./include/linux/sched.h:567:17: error: field 'inactive_timer' has incomplete type
ÂÂ struct hrtimer inactive_timer;
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ ^~~~~~~~~~~~~~
make[1]: *** [kernel/time/alarmtimer.o] Error 1
make: *** [kernel/time/alarmtimer.o] Error 2
ÂÂ CCÂÂÂÂÂ fs/timerfd.o
In file included from ./arch/powerpc/include/asm/smp.h:31,
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ from ./include/linux/smp.h:64,
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ from ./include/linux/percpu.h:7,
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ from ./include/linux/hrtimer.h:22,
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ from ./include/linux/alarmtimer.h:6,
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ from fs/timerfd.c:12:
./include/linux/sched.h:558:19: error: field 'dl_timer' has incomplete type
ÂÂ struct hrtimerÂÂ dl_timer;
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ ^~~~~~~~
./include/linux/sched.h:567:17: error: field 'inactive_timer' has incomplete type
ÂÂ struct hrtimer inactive_timer;
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ ^~~~~~~~~~~~~~
make[1]: *** [fs/timerfd.o] Error 1
make: *** [fs/timerfd.o] Error 2
This patch fixes it by including linux/hrtimer.h after linux/sched.h
Signed-off-by: Christophe Leroy <christophe.leroy@xxxxxx>
---
 Should it be fixed in powerpc instead ? In that case, how ? Any idea ?
Looks like there are several other places where the problem occurs, so it has to be fixed in the powerpc headers instead.
Seems like RISC arch faced the same issue, and fixed it the following way:
/*
Â* This is particularly ugly: it appears we can't actually get the definition
Â* of task_struct here, but we need access to the CPU this task is running on.
Â* Instead of using C we're using asm-offsets.h to get the current processor
Â* ID.
Â*/
#define raw_smp_processor_id() (*((int*)((char*)get_current() + TASK_TI_CPU)))
Unless someone has a better idea, I'll fixed it that way.
Christophe
 fs/timerfd.c | 2 +-
 kernel/time/alarmtimer.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/timerfd.c b/fs/timerfd.c
index d69ad801eb80..0fc01b241382 100644
--- a/fs/timerfd.c
+++ b/fs/timerfd.c
@@ -9,12 +9,12 @@
ÂÂ *
ÂÂ */
-#include <linux/alarmtimer.h>
 #include <linux/file.h>
 #include <linux/poll.h>
 #include <linux/init.h>
 #include <linux/fs.h>
 #include <linux/sched.h>
+#include <linux/alarmtimer.h>
 #include <linux/kernel.h>
 #include <linux/slab.h>
 #include <linux/list.h>
diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
index fa5de5e8de61..5fb75c9b3f06 100644
--- a/kernel/time/alarmtimer.c
+++ b/kernel/time/alarmtimer.c
@@ -16,11 +16,11 @@
ÂÂ * published by the Free Software Foundation.
ÂÂ */
 #include <linux/time.h>
-#include <linux/hrtimer.h>
 #include <linux/timerqueue.h>
 #include <linux/rtc.h>
 #include <linux/sched/signal.h>
 #include <linux/sched/debug.h>
+#include <linux/hrtimer.h>
 #include <linux/alarmtimer.h>
 #include <linux/mutex.h>
 #include <linux/platform_device.h>