2007-10-11 06:54:30

by Peter Williams

[permalink] [raw]
Subject: [PATCH] sched: Rationalize sys_sched_rr_get_interval()

At the moment, static_prio_timeslice() is only used in
sys_sched_rr_get_interval() and only gives the correct result for
SCHED_FIFO and SCHED_RR tasks as the time slice for normal tasks is
unrelated to the values returned by static_prio_timeslice().

This patch addresses this problem and in the process moves all the code
associated with static_prio_timeslice() to sched_rt.c which is the only
place where it now has relevance.

Signed-off-by: Peter Williams <[email protected]>

Peter
--
Peter Williams [email protected]

"Learning, n. The kind of ignorance distinguishing the studious."
-- Ambrose Bierce





Attachments:
rationalize-sys_sched_rr_get_interval.patch (5.00 kB)

2007-10-11 07:00:15

by Ingo Molnar

[permalink] [raw]
Subject: Re: [PATCH] sched: Rationalize sys_sched_rr_get_interval()


* Peter Williams <[email protected]> wrote:

> -#define MIN_TIMESLICE max(5 * HZ / 1000, 1)
> -#define DEF_TIMESLICE (100 * HZ / 1000)

hm, this got removed by Dmitry quite some time ago. Could you please do
this patch against the sched-devel git tree:

git://git.kernel.org/pub/scm/linux/kernel/git/mingo/linux-2.6-sched-devel.git

thanks,

Ingo

2007-10-11 07:44:38

by Dmitry Adamushko

[permalink] [raw]
Subject: Re: [PATCH] sched: Rationalize sys_sched_rr_get_interval()

On 11/10/2007, Ingo Molnar <[email protected]> wrote:
>
> * Peter Williams <[email protected]> wrote:
>
> > -#define MIN_TIMESLICE max(5 * HZ / 1000, 1)
> > -#define DEF_TIMESLICE (100 * HZ / 1000)
>
> hm, this got removed by Dmitry quite some time ago. Could you please do
> this patch against the sched-devel git tree:

here is the commit:
http://git.kernel.org/?p=linux/kernel/git/mingo/linux-2.6-sched-devel.git;a=commit;h=dd3fec36addd1bf76b05225b7e483378b80c3f9e

I had also considered introducing smth like
sched_class::task_timeslice() but decided it was not worth it.


--
Best regards,
Dmitry Adamushko

2007-10-11 22:24:25

by Peter Williams

[permalink] [raw]
Subject: Re: [PATCH] sched: Rationalize sys_sched_rr_get_interval()

Dmitry Adamushko wrote:
> On 11/10/2007, Ingo Molnar <[email protected]> wrote:
>> * Peter Williams <[email protected]> wrote:
>>
>>> -#define MIN_TIMESLICE max(5 * HZ / 1000, 1)
>>> -#define DEF_TIMESLICE (100 * HZ / 1000)
>> hm, this got removed by Dmitry quite some time ago. Could you please do
>> this patch against the sched-devel git tree:
>
> here is the commit:
> http://git.kernel.org/?p=linux/kernel/git/mingo/linux-2.6-sched-devel.git;a=commit;h=dd3fec36addd1bf76b05225b7e483378b80c3f9e
>
> I had also considered introducing smth like
> sched_class::task_timeslice() but decided it was not worth it.

The reason I was going that route was for modularity (which helps when
adding plugsched patches). I'll submit a revised patch for consideration.

Peter
--
Peter Williams [email protected]

"Learning, n. The kind of ignorance distinguishing the studious."
-- Ambrose Bierce

2007-10-12 06:47:21

by Jarek Poplawski

[permalink] [raw]
Subject: Re: [PATCH] sched: Rationalize sys_sched_rr_get_interval()

On 12-10-2007 00:23, Peter Williams wrote:
...
> The reason I was going that route was for modularity (which helps when
> adding plugsched patches). I'll submit a revised patch for consideration.
...

IMHO, it looks like modularity could suck here:

> +static unsigned int default_timeslice_fair(struct task_struct *p)
> +{
> + return NS_TO_JIFFIES(sysctl_sched_min_granularity);
> +}

If it's needed for outside and sched_fair will use something else
(to avoid double conversion) this could be misleading. Shouldn't
this be kind of private and return something usable for the class
mainly? Why anything else than sched_fair should care about this?

Regards,
Jarek P.

2007-10-12 06:59:50

by Ingo Molnar

[permalink] [raw]
Subject: Re: [PATCH] sched: Rationalize sys_sched_rr_get_interval()


* Peter Williams <[email protected]> wrote:

> > I had also considered introducing smth like
> > sched_class::task_timeslice() but decided it was not worth it.
>
> The reason I was going that route was for modularity (which helps when
> adding plugsched patches). I'll submit a revised patch for
> consideration.

no strong feelings - since this isnt a performance-sensitive codepath we
could certainly abstract it a bit more if it's convenient for
hackability. Depends on how the patch looks like and how much code
increase there is - but i'd not expect it to be anything controversial.

Ingo

2007-10-13 05:00:35

by Peter Williams

[permalink] [raw]
Subject: Re: [PATCH] sched: Rationalize sys_sched_rr_get_interval()

Jarek Poplawski wrote:
> On 12-10-2007 00:23, Peter Williams wrote:
> ...
>> The reason I was going that route was for modularity (which helps when
>> adding plugsched patches). I'll submit a revised patch for consideration.
> ...
>
> IMHO, it looks like modularity could suck here:
>
>> +static unsigned int default_timeslice_fair(struct task_struct *p)
>> +{
>> + return NS_TO_JIFFIES(sysctl_sched_min_granularity);
>> +}
>
> If it's needed for outside and sched_fair will use something else
> (to avoid double conversion) this could be misleading. Shouldn't
> this be kind of private and return something usable for the class
> mainly?

This is supplying data for a system call not something for internal use
by the class. As far as the sched_fair class is concerned this is just
a (necessary - because it's need by a system call) diversion.

> Why anything else than sched_fair should care about this?

sched_fair doesn't care so if nothing else does why do we even have
sys_sched_rr_get_interval()? Is this whole function an anachronism that
can be expunged? I'm assuming that the reason it exists is that there
are user space programs that use this system call. Am I correct in this
assumption? Personally, I can't think of anything it would be useful
for other than satisfying curiosity.

Peter
--
Peter Williams [email protected]

"Learning, n. The kind of ignorance distinguishing the studious."
-- Ambrose Bierce

2007-10-15 11:08:44

by Jarek Poplawski

[permalink] [raw]
Subject: Re: [PATCH] sched: Rationalize sys_sched_rr_get_interval()

On 13-10-2007 03:29, Peter Williams wrote:
> Jarek Poplawski wrote:
>> On 12-10-2007 00:23, Peter Williams wrote:
>> ...
>>> The reason I was going that route was for modularity (which helps
>>> when adding plugsched patches). I'll submit a revised patch for
>>> consideration.
>> ...
>>
>> IMHO, it looks like modularity could suck here:
>>
>>> +static unsigned int default_timeslice_fair(struct task_struct *p)
>>> +{
>>> + return NS_TO_JIFFIES(sysctl_sched_min_granularity);
>>> +}
>>
>> If it's needed for outside and sched_fair will use something else
>> (to avoid double conversion) this could be misleading. Shouldn't
>> this be kind of private and return something usable for the class
>> mainly?
>
> This is supplying data for a system call not something for internal use
> by the class. As far as the sched_fair class is concerned this is just
> a (necessary - because it's need by a system call) diversion.

So, now all is clear: this is the misleading case!

>
>> Why anything else than sched_fair should care about this?
>
> sched_fair doesn't care so if nothing else does why do we even have
> sys_sched_rr_get_interval()? Is this whole function an anachronism that
> can be expunged? I'm assuming that the reason it exists is that there
> are user space programs that use this system call. Am I correct in this
> assumption? Personally, I can't think of anything it would be useful
> for other than satisfying curiosity.

Since this is for some special aim (not default for most classes, at
least not for sched_fair) I'd suggest to change names:
default_timeslice_fair() and .default_timeslice to something like eg.:
rr_timeslice_fair() and .rr_timeslice or rr_interval_fair() and
.rr_interval (maybe with this "default" before_"rr_" if necessary).

On the other hand man (2) sched_rr_get_interval mentions that:
"The identified process should be running under the SCHED_RR
scheduling policy".

Also this place seems to say about something simpler:
http://www.gnu.org/software/libc/manual/html_node/Basic-Scheduling-Functions.html

So, I still doubt sched_fair's "notion" of timeslices should be
necessary here.

Sorry for too harsh words.

Thanks,
Jarek P.

2007-10-16 05:11:34

by Peter Williams

[permalink] [raw]
Subject: Re: [PATCH] sched: Rationalize sys_sched_rr_get_interval()

Jarek Poplawski wrote:
> On 13-10-2007 03:29, Peter Williams wrote:
>> Jarek Poplawski wrote:
>>> On 12-10-2007 00:23, Peter Williams wrote:
>>> ...
>>>> The reason I was going that route was for modularity (which helps
>>>> when adding plugsched patches). I'll submit a revised patch for
>>>> consideration.
>>> ...
>>>
>>> IMHO, it looks like modularity could suck here:
>>>
>>>> +static unsigned int default_timeslice_fair(struct task_struct *p)
>>>> +{
>>>> + return NS_TO_JIFFIES(sysctl_sched_min_granularity);
>>>> +}
>>> If it's needed for outside and sched_fair will use something else
>>> (to avoid double conversion) this could be misleading. Shouldn't
>>> this be kind of private and return something usable for the class
>>> mainly?
>> This is supplying data for a system call not something for internal use
>> by the class. As far as the sched_fair class is concerned this is just
>> a (necessary - because it's need by a system call) diversion.
>
> So, now all is clear: this is the misleading case!
>
>>> Why anything else than sched_fair should care about this?
>> sched_fair doesn't care so if nothing else does why do we even have
>> sys_sched_rr_get_interval()? Is this whole function an anachronism that
>> can be expunged? I'm assuming that the reason it exists is that there
>> are user space programs that use this system call. Am I correct in this
>> assumption? Personally, I can't think of anything it would be useful
>> for other than satisfying curiosity.
>
> Since this is for some special aim (not default for most classes, at
> least not for sched_fair) I'd suggest to change names:
> default_timeslice_fair() and .default_timeslice to something like eg.:
> rr_timeslice_fair() and .rr_timeslice or rr_interval_fair() and
> .rr_interval (maybe with this "default" before_"rr_" if necessary).
>
> On the other hand man (2) sched_rr_get_interval mentions that:
> "The identified process should be running under the SCHED_RR
> scheduling policy".
>
> Also this place seems to say about something simpler:
> http://www.gnu.org/software/libc/manual/html_node/Basic-Scheduling-Functions.html
>
> So, I still doubt sched_fair's "notion" of timeslices should be
> necessary here.

As do I. Even more so now that you've shown me the man page for
sched_rr_get_interval().

I'd suggest that we modify sched_rr_get_interval() to return -EINVAL
(with *interval set to zero) if the target task is not SCHED_RR. That
way we can save a lot of unnecessary code. I'll work on a patch.
Unless you want to do it?

>
> Sorry for too harsh words.

I didn't consider them harsh.

Peter
--
Peter Williams [email protected]

"Learning, n. The kind of ignorance distinguishing the studious."
-- Ambrose Bierce

2007-10-16 09:40:00

by Jarek Poplawski

[permalink] [raw]
Subject: Re: [PATCH] sched: Rationalize sys_sched_rr_get_interval()

On 16-10-2007 03:16, Peter Williams wrote:
...
>
> I'd suggest that we modify sched_rr_get_interval() to return -EINVAL
> (with *interval set to zero) if the target task is not SCHED_RR. That
> way we can save a lot of unnecessary code. I'll work on a patch.
...

I like this idea! But, since this a system call maybe at least
something like RFC would be nicer...

>>
>> Sorry for too harsh words.
>
> I didn't consider them harsh.

So, I can't be mistaken for a rapper yet? I'll work on it...

Cheers,
Jarek P.

PS: Peter, for some unknown reason I don't receive your messages.
If you get back some errors from my side I'd be interested to see
it (alternative: jarkao2 at gmail.com).

2007-10-17 00:23:26

by Peter Williams

[permalink] [raw]
Subject: Re: [PATCH] sched: Rationalize sys_sched_rr_get_interval()

Jarek Poplawski wrote:
> On 16-10-2007 03:16, Peter Williams wrote:
> ...
>> I'd suggest that we modify sched_rr_get_interval() to return -EINVAL
>> (with *interval set to zero) if the target task is not SCHED_RR. That
>> way we can save a lot of unnecessary code. I'll work on a patch.
> ...
>
> I like this idea! But, since this a system call maybe at least
> something like RFC would be nicer...

We would be just modifying the code to meet that specification so a
patch would be OK. Anyone who wants to comment will do so anyway :-).

>
>>> Sorry for too harsh words.
>> I didn't consider them harsh.
>
> So, I can't be mistaken for a rapper yet? I'll work on it...
>
> Cheers,
> Jarek P.
>
> PS: Peter, for some unknown reason I don't receive your messages.
> If you get back some errors from my side I'd be interested to see
> it (alternative: jarkao2 at gmail.com).

I haven't seen any bounce notifications. I've added the qmail address
as a CC.

Peter
--
Peter Williams [email protected]

"Learning, n. The kind of ignorance distinguishing the studious."
-- Ambrose Bierce