From: Peter Zijlstra <peterz@infradead.org>
To: Juri Lelli <juri.lelli@gmail.com>
Cc: "Michael Kerrisk (man-pages)" <mtk.manpages@gmail.com>,
Dario Faggioli <raistlin@linux.it>, Ingo Molnar <mingo@elte.hu>,
lkml <linux-kernel@vger.kernel.org>,
Dave Jones <davej@redhat.com>
Subject: Re: [BUG] sched_setattr() SCHED_DEADLINE hangs system
Date: Tue, 13 May 2014 12:43:07 +0200 [thread overview]
Message-ID: <20140513104307.GZ30445@twins.programming.kicks-ass.net> (raw)
In-Reply-To: <20140513115749.ebf3eebc64e44aac6f183410@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1435 bytes --]
On Tue, May 13, 2014 at 11:57:49AM +0200, Juri Lelli wrote:
> static bool
> __checkparam_dl(const struct sched_attr *attr)
> {
> return attr && attr->sched_deadline != 0 &&
> (attr->sched_period == 0 ||
> - (s64)(attr->sched_period - attr->sched_deadline) >= 0) &&
> - (s64)(attr->sched_deadline - attr->sched_runtime ) >= 0 &&
> - attr->sched_runtime >= (2 << (DL_SCALE - 1));
> + (attr->sched_period >= attr->sched_deadline)) &&
> + (attr->sched_deadline >= attr->sched_runtime) &&
> + attr->sched_runtime >= (1ULL << DL_SCALE) &&
> + (attr->sched_deadline < (1ULL << 63) &&
> + attr->sched_period < (1ULL << 63));
> }
Could we maybe rewrite that function to look less like a ioccc.org
submission?
static bool
__checkparam_dl(const struct sched_attr *attr)
{
if (!attr) /* possible at all? */
return false;
/* runtime <= deadline <= period */
if (attr->sched_period < attr->sched_deadline ||
attr->sched_deadline < attr->sched_runtime)
return false;
/*
* Since we truncate DL_SCALE bits make sure we're at least that big,
* if runtime > (1 << DL_SCALE), so must the others be per the above
*/
if (attr->sched_runtime <= (1ULL << DL_SCALE))
return false;
/*
* Since we use the MSB for wrap-around and sign issues, make
* sure its not set, if period < 2^63, so must the others be.
*/
if (attr->sched_period & (1ULL << 63))
return false;
return true;
}
Did I miss anything?
[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]
next prev parent reply other threads:[~2014-05-13 10:43 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-11 14:54 Michael Kerrisk (man-pages)
2014-05-11 17:47 ` Michael Kerrisk (man-pages)
2014-05-12 6:53 ` Michael Kerrisk (man-pages)
2014-05-12 8:47 ` Peter Zijlstra
2014-05-12 9:19 ` Michael Kerrisk (man-pages)
2014-05-12 12:30 ` Peter Zijlstra
2014-05-13 9:57 ` Juri Lelli
2014-05-13 10:43 ` Peter Zijlstra [this message]
2014-05-13 12:11 ` Juri Lelli
2014-05-13 12:46 ` Michael Kerrisk (man-pages)
2014-05-19 13:07 ` [tip:sched/core] sched/deadline: Restrict user params max value to 2^63 ns tip-bot for Juri Lelli
2014-05-22 12:25 ` tip-bot for Juri Lelli
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=20140513104307.GZ30445@twins.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=davej@redhat.com \
--cc=juri.lelli@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=mtk.manpages@gmail.com \
--cc=raistlin@linux.it \
/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
Powered by JetHome