Re: [PATCH] kernel/sched/core.c: Avoid unused variable on non-SMP configs

2018-09-10 Thread Vincent Guittot
On Mon, 10 Sep 2018 at 12:32, Miguel Ojeda
 wrote:
>
> Hi Vincent,
>
> On Mon, Sep 10, 2018 at 9:00 AM, Vincent Guittot
>  wrote:
> > On Sun, 9 Sep 2018 at 19:00, Miguel Ojeda
> >  wrote:
> >>
> >> On Sun, Sep 9, 2018 at 6:45 PM, Borislav Petkov  wrote:
> >> > On Sun, Sep 09, 2018 at 06:36:01PM +0200, Miguel Ojeda wrote:
> >> >> No, you get a different warning depending on whether you have enabled
> >> >> CONFIG_PARAVIRT_TIME_ACCOUNTING or CONFIG_IRQ_TIME_ACCOUNTING.
> >> >
> >> > Ok.
> >> >
> >> > Still, adding __maybe_unused to both (or writing it before the name,
> >> > whatever works!) and dropping the ifdeffery is still better for
> >> > readability's sake than having more ifdeffery, IMO.
> >>
> >> Agreed, it is quite confusing already. I tried to keep the style of
> >> the code, but Ingo/Peter might prefer the cleanup. Let's see...
> >
> > FYI, another patch has already been sent for this warning
> > https://lkml.org/lkml/2018/8/10/22
>
> Indeed -- sorry, I didn't notice. The patches are different in
> behavior, though; is the block there supposed to be there in non-SMP
> cases? (I guess so, since originally it was there, but asking just in
> case).

Yes, i think it's worth keeping it for !SMP
That being said, the original goal of the code is to compute the
amount of capacity stolen to a guest or by interrupt in order to
reflect that int the CPU capacity. But on !SMP, the cpu_capacity is
not used as there is no load balance decision between CPU to do.
Now, the code has being recently updated and the irq time is now also
used in schedutil when selecting frequency which can also benefit to
!SMP
But the enable of irq tracking for !SMP hasn't been sent yet

Regards,
Vincent

>
> Cheers,
> Miguel


Re: [PATCH] kernel/sched/core.c: Avoid unused variable on non-SMP configs

2018-09-10 Thread Miguel Ojeda
Hi Vincent,

On Mon, Sep 10, 2018 at 9:00 AM, Vincent Guittot
 wrote:
> On Sun, 9 Sep 2018 at 19:00, Miguel Ojeda
>  wrote:
>>
>> On Sun, Sep 9, 2018 at 6:45 PM, Borislav Petkov  wrote:
>> > On Sun, Sep 09, 2018 at 06:36:01PM +0200, Miguel Ojeda wrote:
>> >> No, you get a different warning depending on whether you have enabled
>> >> CONFIG_PARAVIRT_TIME_ACCOUNTING or CONFIG_IRQ_TIME_ACCOUNTING.
>> >
>> > Ok.
>> >
>> > Still, adding __maybe_unused to both (or writing it before the name,
>> > whatever works!) and dropping the ifdeffery is still better for
>> > readability's sake than having more ifdeffery, IMO.
>>
>> Agreed, it is quite confusing already. I tried to keep the style of
>> the code, but Ingo/Peter might prefer the cleanup. Let's see...
>
> FYI, another patch has already been sent for this warning
> https://lkml.org/lkml/2018/8/10/22

Indeed -- sorry, I didn't notice. The patches are different in
behavior, though; is the block there supposed to be there in non-SMP
cases? (I guess so, since originally it was there, but asking just in
case).

Cheers,
Miguel


Re: [PATCH] kernel/sched/core.c: Avoid unused variable on non-SMP configs

2018-09-10 Thread Vincent Guittot
On Sun, 9 Sep 2018 at 19:00, Miguel Ojeda
 wrote:
>
> On Sun, Sep 9, 2018 at 6:45 PM, Borislav Petkov  wrote:
> > On Sun, Sep 09, 2018 at 06:36:01PM +0200, Miguel Ojeda wrote:
> >> No, you get a different warning depending on whether you have enabled
> >> CONFIG_PARAVIRT_TIME_ACCOUNTING or CONFIG_IRQ_TIME_ACCOUNTING.
> >
> > Ok.
> >
> > Still, adding __maybe_unused to both (or writing it before the name,
> > whatever works!) and dropping the ifdeffery is still better for
> > readability's sake than having more ifdeffery, IMO.
>
> Agreed, it is quite confusing already. I tried to keep the style of
> the code, but Ingo/Peter might prefer the cleanup. Let's see...

FYI, another patch has already been sent for this warning
https://lkml.org/lkml/2018/8/10/22


>
> Cheers,
> Miguel


Re: [PATCH] kernel/sched/core.c: Avoid unused variable on non-SMP configs

2018-09-09 Thread Miguel Ojeda
On Sun, Sep 9, 2018 at 6:45 PM, Borislav Petkov  wrote:
> On Sun, Sep 09, 2018 at 06:36:01PM +0200, Miguel Ojeda wrote:
>> No, you get a different warning depending on whether you have enabled
>> CONFIG_PARAVIRT_TIME_ACCOUNTING or CONFIG_IRQ_TIME_ACCOUNTING.
>
> Ok.
>
> Still, adding __maybe_unused to both (or writing it before the name,
> whatever works!) and dropping the ifdeffery is still better for
> readability's sake than having more ifdeffery, IMO.

Agreed, it is quite confusing already. I tried to keep the style of
the code, but Ingo/Peter might prefer the cleanup. Let's see...

Cheers,
Miguel


Re: [PATCH] kernel/sched/core.c: Avoid unused variable on non-SMP configs

2018-09-09 Thread Borislav Petkov
On Sun, Sep 09, 2018 at 06:36:01PM +0200, Miguel Ojeda wrote:
> No, you get a different warning depending on whether you have enabled
> CONFIG_PARAVIRT_TIME_ACCOUNTING or CONFIG_IRQ_TIME_ACCOUNTING.

Ok.

Still, adding __maybe_unused to both (or writing it before the name,
whatever works!) and dropping the ifdeffery is still better for
readability's sake than having more ifdeffery, IMO.

-- 
Regards/Gruss,
Boris.

Good mailing practices for 400: avoid top-posting and trim the reply.


Re: [PATCH] kernel/sched/core.c: Avoid unused variable on non-SMP configs

2018-09-09 Thread Miguel Ojeda
Hi Borislav,

On Sun, Sep 9, 2018 at 6:06 PM, Borislav Petkov  wrote:
> On Sun, Sep 09, 2018 at 04:48:19PM +0200, Miguel Ojeda wrote:
>> Indeed. But note that the attribute needs to be written before the
>> variable name so that it applies to both variables (or write it twice)
>
> It warns only about 'steal' - not the other one.

No, you get a different warning depending on whether you have enabled
CONFIG_PARAVIRT_TIME_ACCOUNTING or CONFIG_IRQ_TIME_ACCOUNTING.

In other words, !SMP && IRQ warns about "steal", while !SMP &&
PARAVIRT warns about "irq_delta" (the example warning I posted is for
this last case).

Cheers,
Miguel


Re: [PATCH] kernel/sched/core.c: Avoid unused variable on non-SMP configs

2018-09-09 Thread Borislav Petkov
On Sun, Sep 09, 2018 at 04:48:19PM +0200, Miguel Ojeda wrote:
> Indeed. But note that the attribute needs to be written before the
> variable name so that it applies to both variables (or write it twice)

It warns only about 'steal' - not the other one.

> Also, if we go that route, I would simply remove the #ifdef entirely.

Even better. The less ifdeffery the better.

-- 
Regards/Gruss,
Boris.

Good mailing practices for 400: avoid top-posting and trim the reply.


Re: [PATCH] kernel/sched/core.c: Avoid unused variable on non-SMP configs

2018-09-09 Thread Miguel Ojeda
On Sun, Sep 9, 2018 at 11:36 AM, Borislav Petkov  wrote:
>
> Alternatively, if you don't want to let the crazy ifdeffery in that
> function grow even more, you can simply do:
>
> ---
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index 625bc9897f62..1728743360d4 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -136,7 +136,7 @@ static void update_rq_clock_task(struct rq *rq, s64 delta)
>   * to sched_rt_avg_update. But I don't trust it...
>   */
>  #if defined(CONFIG_IRQ_TIME_ACCOUNTING) || 
> defined(CONFIG_PARAVIRT_TIME_ACCOUNTING)
> -   s64 steal = 0, irq_delta = 0;
> +   s64 steal __maybe_unused = 0, irq_delta = 0;
>  #endif

Indeed. But note that the attribute needs to be written before the
variable name so that it applies to both variables (or write it twice)
--- see https://godbolt.org/z/cwOeXZ

Also, if we go that route, I would simply remove the #ifdef entirely.

Cheers,
Miguel


Re: [PATCH] kernel/sched/core.c: Avoid unused variable on non-SMP configs

2018-09-09 Thread Borislav Petkov
On Sat, Sep 08, 2018 at 09:05:53PM +0200, Miguel Ojeda wrote:
> On non-SMP configs, when only one of CONFIG_{PARAVIRT,IRQ_TIME}_ACCOUNTING
> is defined, we are declaring a variable (irq_delta or steal) which
> is not used:
> 
> kernel/sched/core.c: In function ‘update_rq_clock_task’:
> kernel/sched/core.c:139:17: warning: unused variable ‘irq_delta’ 
> [-Wunused-variable]
>   s64 steal = 0, irq_delta = 0;
> 
> The reason is that CONFIG_SMP guards HAVE_SCHED_AVG_IRQ, which in turn
> disables the code guarded by HAVE_SCHED_AVG_IRQ.
> 
> Cc: Ingo Molnar 
> Cc: Peter Zijlstra 
> Signed-off-by: Miguel Ojeda 
> ---
>  kernel/sched/core.c | 7 +--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index 625bc9897f62..d662d1e11843 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -135,8 +135,11 @@ static void update_rq_clock_task(struct rq *rq, s64 
> delta)
>   * In theory, the compile should just see 0 here, and optimize out the call
>   * to sched_rt_avg_update. But I don't trust it...
>   */
> -#if defined(CONFIG_IRQ_TIME_ACCOUNTING) || 
> defined(CONFIG_PARAVIRT_TIME_ACCOUNTING)
> - s64 steal = 0, irq_delta = 0;
> +#if defined(HAVE_SCHED_AVG_IRQ) || defined(CONFIG_IRQ_TIME_ACCOUNTING)
> + s64 irq_delta = 0;
> +#endif
> +#if defined(HAVE_SCHED_AVG_IRQ) || defined(CONFIG_PARAVIRT_TIME_ACCOUNTING)
> + s64 steal = 0;
>  #endif
>  #ifdef CONFIG_IRQ_TIME_ACCOUNTING
>   irq_delta = irq_time_read(cpu_of(rq)) - rq->prev_irq_time;
> -- 

Alternatively, if you don't want to let the crazy ifdeffery in that
function grow even more, you can simply do:

---
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 625bc9897f62..1728743360d4 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -136,7 +136,7 @@ static void update_rq_clock_task(struct rq *rq, s64 delta)
  * to sched_rt_avg_update. But I don't trust it...
  */
 #if defined(CONFIG_IRQ_TIME_ACCOUNTING) || 
defined(CONFIG_PARAVIRT_TIME_ACCOUNTING)
-   s64 steal = 0, irq_delta = 0;
+   s64 steal __maybe_unused = 0, irq_delta = 0;
 #endif
 #ifdef CONFIG_IRQ_TIME_ACCOUNTING
irq_delta = irq_time_read(cpu_of(rq)) - rq->prev_irq_time;

-- 
Regards/Gruss,
Boris.

Good mailing practices for 400: avoid top-posting and trim the reply.