linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dietmar Eggemann <dietmar.eggemann@arm.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: luca abeni <luca.abeni@santannapisa.it>,
	Ingo Molnar <mingo@kernel.org>,
	Juri Lelli <juri.lelli@redhat.com>,
	Daniel Bristot de Oliveira <bristot@redhat.com>,
	Valentin Schneider <Valentin.Schneider@arm.com>,
	Qais Yousef <Qais.Yousef@arm.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 5/5] sched/deadline: Use return value of SCHED_WARN_ON() in bw accounting
Date: Tue, 30 Jul 2019 17:08:35 +0100	[thread overview]
Message-ID: <7da6555c-baff-39df-b562-2510566ba4bf@arm.com> (raw)
In-Reply-To: <20190730082316.GK31381@hirez.programming.kicks-ass.net>

On 7/30/19 9:23 AM, Peter Zijlstra wrote:
> On Mon, Jul 29, 2019 at 05:59:04PM +0100, Dietmar Eggemann wrote:
>> On 7/29/19 5:54 PM, Peter Zijlstra wrote:
>>> On Fri, Jul 26, 2019 at 12:18:19PM +0200, luca abeni wrote:
>>>> Hi Dietmar,
>>>>
>>>> On Fri, 26 Jul 2019 09:27:56 +0100
>>>> Dietmar Eggemann <dietmar.eggemann@arm.com> wrote:
>>>>
>>>>> To make the decision whether to set rq or running bw to 0 in underflow
>>>>> case use the return value of SCHED_WARN_ON() rather than an extra if
>>>>> condition.
>>>>
>>>> I think I tried this at some point, but if I remember well this
>>>> solution does not work correctly when SCHED_DEBUG is not enabled.
>>>
>>> Well, it 'works' in so far that it compiles. But it might not be what
>>> one expects. That is, for !SCHED_DEBUG the return value is an
>>> unconditional false.
>>>
>>> In this case I think that's fine, the WARN _should_ not be happending.
>>
>> But there is commit 6d3aed3d ("sched/debug: Fix SCHED_WARN_ON() to
>> return a value on !CONFIG_SCHED_DEBUG as well")?
>>
>> But it doesn't work with !CONFIG_SCHED_DEBUG
>>
>> What compiles and work is (at least on Arm64).
>>
>> diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
>> index 4012f98b9d26..494a767a4091 100644
>> --- a/kernel/sched/sched.h
>> +++ b/kernel/sched/sched.h
>> @@ -78,7 +78,7 @@
>>  #ifdef CONFIG_SCHED_DEBUG
>>  # define SCHED_WARN_ON(x)      WARN_ONCE(x, #x)
>>  #else
>> -# define SCHED_WARN_ON(x)      ({ (void)(x), 0; })
>> +# define SCHED_WARN_ON(x)      ({ (void)(x), x; })
> 
> Why doesn't the ,0 compile? That should work just fine. The thing is,
> the two existing users:
> 
> kernel/sched/fair.c:            if (SCHED_WARN_ON(!se->on_rq))
> kernel/sched/fair.c:            if (SCHED_WARN_ON(!se->on_rq))
> 
> seem to compile just fine with it.

You're right, compiling is not an issue. But it looks like the code does
different things depending on CONFIG_SCHED_DEBUG.

E.g. in set_last_buddy() we would return if '!se->on_rq' with
CONFIG_SCHED_DEBUG and continue the for_each_sched_entity() with
!CONFIG_SCHED_DEBUG.

IMHO, this forced Luca e.g. in __sub_running_bw() to code:

SCHED_WARN_ON(dl_rq->running_bw > old);
if (dl_rq->running_bw > old)
    dl_rq->running_bw = 0;

and not:

if (SCHED_WARN_ON(dl_rq->running_bw > old))
    dl_rq->running_bw = 0;

I experimented with '# define SCHED_WARN_ON(x) ({ (void)(x), x; })' and
in this case code inside an 'if (SCHED_WARN_ON(cond))' is also executed
with !CONFIG_SCHED_DEBUG.

      reply	other threads:[~2019-07-30 16:08 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-26  8:27 [PATCH 0/5] sched/deadline: Fix double accounting in push_dl_task() & some cleanups Dietmar Eggemann
2019-07-26  8:27 ` [PATCH 1/5] sched/deadline: Fix double accounting of rq/running bw in push_dl_task() Dietmar Eggemann
2019-07-26 10:11   ` luca abeni
2019-07-29  8:59     ` Dietmar Eggemann
2019-07-29 16:10       ` Peter Zijlstra
2019-07-26 13:30   ` luca abeni
2019-07-29  9:00     ` Dietmar Eggemann
2019-07-31 10:32       ` Dietmar Eggemann
2019-07-26  8:27 ` [PATCH 2/5] sched/deadline: Remove unused int flags from __dequeue_task_dl() Dietmar Eggemann
2019-07-29 16:35   ` Peter Zijlstra
2019-07-29 17:12     ` Dietmar Eggemann
2019-07-26  8:27 ` [PATCH 3/5] sched/deadline: Use __sub_running_bw() throughout dl_change_utilization() Dietmar Eggemann
2019-07-29 16:47   ` Peter Zijlstra
2019-07-29 17:21     ` Dietmar Eggemann
2019-07-26  8:27 ` [PATCH 4/5] sched/deadline: Cleanup on_dl_rq() handling Dietmar Eggemann
2019-07-26  8:37   ` Valentin Schneider
2019-07-26  8:58     ` Qais Yousef
2019-07-26  9:20     ` Juri Lelli
2019-07-26  9:32       ` Valentin Schneider
2019-07-29 16:49   ` Peter Zijlstra
2019-07-30  6:41     ` Juri Lelli
2019-07-30  8:21       ` Peter Zijlstra
2019-07-31 17:32         ` Dietmar Eggemann
2019-07-31 20:20           ` luca abeni
2019-08-01 16:01             ` Dietmar Eggemann
2019-07-26  8:27 ` [PATCH 5/5] sched/deadline: Use return value of SCHED_WARN_ON() in bw accounting Dietmar Eggemann
2019-07-26 10:18   ` luca abeni
2019-07-29 16:54     ` Peter Zijlstra
2019-07-29 16:59       ` Dietmar Eggemann
2019-07-30  8:23         ` Peter Zijlstra
2019-07-30 16:08           ` Dietmar Eggemann [this message]

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=7da6555c-baff-39df-b562-2510566ba4bf@arm.com \
    --to=dietmar.eggemann@arm.com \
    --cc=Qais.Yousef@arm.com \
    --cc=Valentin.Schneider@arm.com \
    --cc=bristot@redhat.com \
    --cc=juri.lelli@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luca.abeni@santannapisa.it \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    /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;
as well as URLs for NNTP newsgroup(s).