mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Christophe LEROY <christophe.leroy@c-s.fr>
To: Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Paul Mackerras <paulus@samba.org>,
	Michael Ellerman <mpe@ellerman.id.au>,
	aneesh.kumar@linux.vnet.ibm.com, npiggin@gmail.com,
	Thomas Gleixner <tglx@linutronix.de>,
	Alexander Viro <viro@zeniv.linux.org.uk>,
	John Stultz <john.stultz@linaro.org>,
	Stephen Boyd <sboyd@kernel.org>
Cc: linux-fsdevel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org,
	linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH v1 1/9] timer: fix circular header dependency
Date: Tue, 25 Sep 2018 08:33:35 +0200	[thread overview]
Message-ID: <9bff645b-4e00-ab0f-288a-a17f1e45ecdd@c-s.fr> (raw)
In-Reply-To: <5c9530da-f5c8-e0b2-61ab-294a0da7f3fc@c-s.fr>



Le 25/09/2018 à 07:34, Christophe LEROY a écrit :
> 
> 
> 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@c-s.fr>
>> ---
>>   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.


Not easy. I'm stuck at the moment, because asm-offsets.h redefines a lot 
of things with the same name as in C, so when including asm-offsets.h in 
C it conflicts. Argh !. Need to fix all those duplicates ?

Christophe

> 
> 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>
>>

  reply	other threads:[~2018-09-25  6:33 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-24 15:52 [RFC PATCH v1 0/9] powerpc: Switch to CONFIG_THREAD_INFO_IN_TASK Christophe Leroy
2018-09-24 15:52 ` [RFC PATCH v1 1/9] timer: fix circular header dependency Christophe Leroy
2018-09-25  5:34   ` Christophe LEROY
2018-09-25  6:33     ` Christophe LEROY [this message]
2018-09-25 12:11     ` Mark Rutland
2018-09-25 12:15       ` Christophe LEROY
2018-09-25 17:48         ` Christophe Leroy
2018-09-24 15:52 ` [RFC PATCH v1 2/9] book3s/64: avoid circular header inclusion in mmu-hash.h Christophe Leroy
2018-09-24 15:52 ` [RFC PATCH v1 3/9] powerpc: change name THREAD_INFO to TASK_STACK Christophe Leroy
2018-09-24 15:52 ` [RFC PATCH v1 4/9] powerpc: Prepare for moving thread_info into task_struct Christophe Leroy
2018-09-24 15:52 ` [RFC PATCH v1 5/9] powerpc: Activate CONFIG_THREAD_INFO_IN_TASK Christophe Leroy
2018-09-24 15:52 ` [RFC PATCH v1 6/9] powerpc: regain entire stack space Christophe Leroy
2018-09-24 15:52 ` [RFC PATCH v1 7/9] powerpc: 'current_set' is now a table of task_struct pointers Christophe Leroy
2018-09-24 15:52 ` [RFC PATCH v1 8/9] powerpc/32: Remove CURRENT_THREAD_INFO and rename TI_CPU Christophe Leroy
2018-09-24 15:52 ` [RFC PATCH v1 9/9] powerpc/64: Modify CURRENT_THREAD_INFO() Christophe Leroy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9bff645b-4e00-ab0f-288a-a17f1e45ecdd@c-s.fr \
    --to=christophe.leroy@c-s.fr \
    --cc=aneesh.kumar@linux.vnet.ibm.com \
    --cc=benh@kernel.crashing.org \
    --cc=john.stultz@linaro.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mpe@ellerman.id.au \
    --cc=npiggin@gmail.com \
    --cc=paulus@samba.org \
    --cc=sboyd@kernel.org \
    --cc=tglx@linutronix.de \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®