All of lore.kernel.org
 help / color / mirror / Atom feed
* SCHED_BATCH and SCHED_BATCH numbering
@ 2004-08-04 16:50 Albert Cahalan
  2004-08-05  1:17 ` Peter Williams
  2004-08-05  6:57 ` Ingo Molnar
  0 siblings, 2 replies; 13+ messages in thread
From: Albert Cahalan @ 2004-08-04 16:50 UTC (permalink / raw)
  To: linux-kernel mailing list; +Cc: kernel, Andrew Morton OSDL

Are these going to be numbered consecutively, or might
they better be done like the task state? SCHED_FIFO is
in fact already treated this way in one place. One might
want to test values this way:

if(foo & (SCHED_ISO|SCHED_RR|SCHED_FIFO))  ...

(leaving aside SCHED_OTHER==0, or just translate
that single value for the ABI)

I'd like to see these get permenant allocations
soon, even if the code doesn't go into the kernel.
This is because user-space needs to know the values.



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: SCHED_BATCH and SCHED_BATCH numbering
  2004-08-04 16:50 SCHED_BATCH and SCHED_BATCH numbering Albert Cahalan
@ 2004-08-05  1:17 ` Peter Williams
  2004-08-05  1:27   ` Nick Piggin
  2004-08-05  6:57 ` Ingo Molnar
  1 sibling, 1 reply; 13+ messages in thread
From: Peter Williams @ 2004-08-05  1:17 UTC (permalink / raw)
  To: Albert Cahalan; +Cc: linux-kernel mailing list, kernel, Andrew Morton OSDL

Albert Cahalan wrote:
> Are these going to be numbered consecutively, or might
> they better be done like the task state? SCHED_FIFO is
> in fact already treated this way in one place. One might
> want to test values this way:
> 
> if(foo & (SCHED_ISO|SCHED_RR|SCHED_FIFO))  ...
> 
> (leaving aside SCHED_OTHER==0, or just translate
> that single value for the ABI)
> 
> I'd like to see these get permenant allocations
> soon, even if the code doesn't go into the kernel.
> This is because user-space needs to know the values.

Excellent idea.  The definition of rt_task() could become:

#define rt_task(p) ((p)->policy & (SCHED_RR|SCHED_FIFO))

instead of the highly dodgy:

#define rt_task(p) ((p)->prio < MAX_RT_PRIO)

Peter
-- 
Peter Williams                                   pwil3058@bigpond.net.au

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


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: SCHED_BATCH and SCHED_BATCH numbering
  2004-08-05  1:17 ` Peter Williams
@ 2004-08-05  1:27   ` Nick Piggin
  2004-08-05  2:09     ` Peter Williams
  0 siblings, 1 reply; 13+ messages in thread
From: Nick Piggin @ 2004-08-05  1:27 UTC (permalink / raw)
  To: Peter Williams
  Cc: Albert Cahalan, linux-kernel mailing list, kernel, Andrew Morton OSDL

Peter Williams wrote:

> Albert Cahalan wrote:
>
>> Are these going to be numbered consecutively, or might
>> they better be done like the task state? SCHED_FIFO is
>> in fact already treated this way in one place. One might
>> want to test values this way:
>>
>> if(foo & (SCHED_ISO|SCHED_RR|SCHED_FIFO))  ...
>>
>> (leaving aside SCHED_OTHER==0, or just translate
>> that single value for the ABI)
>>
>> I'd like to see these get permenant allocations
>> soon, even if the code doesn't go into the kernel.
>> This is because user-space needs to know the values.
>
>
> Excellent idea.  The definition of rt_task() could become:
>
> #define rt_task(p) ((p)->policy & (SCHED_RR|SCHED_FIFO))
>
> instead of the highly dodgy:
>
> #define rt_task(p) ((p)->prio < MAX_RT_PRIO)
>

Nothing wrong with that, is there?


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: SCHED_BATCH and SCHED_BATCH numbering
  2004-08-05  1:27   ` Nick Piggin
@ 2004-08-05  2:09     ` Peter Williams
  2004-08-05  2:23       ` Nick Piggin
  0 siblings, 1 reply; 13+ messages in thread
From: Peter Williams @ 2004-08-05  2:09 UTC (permalink / raw)
  To: Nick Piggin
  Cc: Albert Cahalan, linux-kernel mailing list, kernel, Andrew Morton OSDL

Nick Piggin wrote:
> Peter Williams wrote:
> 
>> Albert Cahalan wrote:
>>
>>> Are these going to be numbered consecutively, or might
>>> they better be done like the task state? SCHED_FIFO is
>>> in fact already treated this way in one place. One might
>>> want to test values this way:
>>>
>>> if(foo & (SCHED_ISO|SCHED_RR|SCHED_FIFO))  ...
>>>
>>> (leaving aside SCHED_OTHER==0, or just translate
>>> that single value for the ABI)
>>>
>>> I'd like to see these get permenant allocations
>>> soon, even if the code doesn't go into the kernel.
>>> This is because user-space needs to know the values.
>>
>>
>>
>> Excellent idea.  The definition of rt_task() could become:
>>
>> #define rt_task(p) ((p)->policy & (SCHED_RR|SCHED_FIFO))
>>
>> instead of the highly dodgy:

I probably should have said "slightly" instead of "highly" here but I 
got carried away. :-)

>>
>> #define rt_task(p) ((p)->prio < MAX_RT_PRIO)
>>
> 
> Nothing wrong with that, is there?

It's sloppy logic in that "prio" being less than MAX_RT_PRIO is a 
consequence of the task being real time not the definition of it.  At 
the moment it is a sufficient condition for identifying a task as real 
time but that may not always be the case.  But, the real issue is, 
what's the point of having a field, "policy", that IS the definitive 
indicator of the task's scheduling policy if you don't use it?  An 
rt_task() function/macro defined in terms of the policy field with this 
suggested numbering scheme should always be correct.

At the moment rt_task(p) could be defined as ((p)->policy != 
SCHED_OTHER) but the addition of SCHED_ISO and SCHED_BATCH would break 
that.  Another option would be (((p)->policy == SCHED_FIFO) || 
((p)->policy == SCHED_RR)) but that's a little long winded and (avoiding 
it) is probably the reason for the current definition.  So I stand by my 
comment that Albert's numbering scheme is an excellent idea.

Peter
-- 
Peter Williams                                   pwil3058@bigpond.net.au

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


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: SCHED_BATCH and SCHED_BATCH numbering
  2004-08-05  2:09     ` Peter Williams
@ 2004-08-05  2:23       ` Nick Piggin
  2004-08-05  3:03         ` Peter Williams
  0 siblings, 1 reply; 13+ messages in thread
From: Nick Piggin @ 2004-08-05  2:23 UTC (permalink / raw)
  To: Peter Williams
  Cc: Albert Cahalan, linux-kernel mailing list, kernel, Andrew Morton OSDL

Peter Williams wrote:

> Nick Piggin wrote:
>
>> Peter Williams wrote:
>>
>>> Albert Cahalan wrote:
>>>
>>>> Are these going to be numbered consecutively, or might
>>>> they better be done like the task state? SCHED_FIFO is
>>>> in fact already treated this way in one place. One might
>>>> want to test values this way:
>>>>
>>>> if(foo & (SCHED_ISO|SCHED_RR|SCHED_FIFO))  ...
>>>>
>>>> (leaving aside SCHED_OTHER==0, or just translate
>>>> that single value for the ABI)
>>>>
>>>> I'd like to see these get permenant allocations
>>>> soon, even if the code doesn't go into the kernel.
>>>> This is because user-space needs to know the values.
>>>
>>>
>>>
>>>
>>> Excellent idea.  The definition of rt_task() could become:
>>>
>>> #define rt_task(p) ((p)->policy & (SCHED_RR|SCHED_FIFO))
>>>
>>> instead of the highly dodgy:
>>
>
> I probably should have said "slightly" instead of "highly" here but I 
> got carried away. :-)
>
>>>
>>> #define rt_task(p) ((p)->prio < MAX_RT_PRIO)
>>>
>>
>> Nothing wrong with that, is there?
>
>
> It's sloppy logic in that "prio" being less than MAX_RT_PRIO is a 
> consequence of the task being real time not the definition of it.  At 
> the moment it is a sufficient condition for identifying a task as real 
> time but that may not always be the case.

Actually, p->prio < MAX_RT_PRIO iff rt_task(p). This can't change 
without horribly breaking
stuff.

> But, the real issue is, what's the point of having a field, "policy", 
> that IS the definitive indicator of the task's scheduling policy if 
> you don't use it?  An rt_task() function/macro defined in terms of the 
> policy field with this suggested numbering scheme should always be 
> correct.
>
> At the moment rt_task(p) could be defined as ((p)->policy != 
> SCHED_OTHER) but the addition of SCHED_ISO and SCHED_BATCH would break 
> that.  Another option would be (((p)->policy == SCHED_FIFO) || 
> ((p)->policy == SCHED_RR)) but that's a little long winded and 
> (avoiding it) is probably the reason for the current definition. 


Conversely, p->prio < MAX_RT_PRIO neatly defines a task as being 
realtime without worrying
about what exact policy it is using. However if you add or remove 
scheduling policies, your
p->policy method breaks.


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: SCHED_BATCH and SCHED_BATCH numbering
  2004-08-05  3:06           ` Nick Piggin
@ 2004-08-05  2:28             ` Albert Cahalan
  2004-08-05  7:06               ` Nick Piggin
  2004-08-05  3:36             ` Peter Williams
  1 sibling, 1 reply; 13+ messages in thread
From: Albert Cahalan @ 2004-08-05  2:28 UTC (permalink / raw)
  To: Nick Piggin
  Cc: Peter Williams, linux-kernel mailing list, kernel, Andrew Morton OSDL

On Wed, 2004-08-04 at 23:06, Nick Piggin wrote:
> Peter Williams wrote:
> 
> > Nick Piggin wrote:
> >
> >> However if you add or remove scheduling policies, your
> >> p->policy method breaks.
> >
> >
> > Not if Albert's numbering system is used.
> >
> 
> What if another realtime policy is added? Or one is removed?

What if, what if...

You're going to have to change the code anyway.
One might toss this into <linux/sched.h> to make
as a nice reminder:

#define SCHEDS_RT (SCHED_RR|SCHED_FIFO)

As it is now, SCHED_FIFO is already used as a
bit flag in one place.



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: SCHED_BATCH and SCHED_BATCH numbering
  2004-08-05  2:23       ` Nick Piggin
@ 2004-08-05  3:03         ` Peter Williams
  2004-08-05  3:06           ` Nick Piggin
  0 siblings, 1 reply; 13+ messages in thread
From: Peter Williams @ 2004-08-05  3:03 UTC (permalink / raw)
  To: Nick Piggin
  Cc: Albert Cahalan, linux-kernel mailing list, kernel, Andrew Morton OSDL

Nick Piggin wrote:
> Peter Williams wrote:
> 
>> Nick Piggin wrote:
>>
>>> Peter Williams wrote:
>>>
>>>> Albert Cahalan wrote:
>>>>
>>>>> Are these going to be numbered consecutively, or might
>>>>> they better be done like the task state? SCHED_FIFO is
>>>>> in fact already treated this way in one place. One might
>>>>> want to test values this way:
>>>>>
>>>>> if(foo & (SCHED_ISO|SCHED_RR|SCHED_FIFO))  ...
>>>>>
>>>>> (leaving aside SCHED_OTHER==0, or just translate
>>>>> that single value for the ABI)
>>>>>
>>>>> I'd like to see these get permenant allocations
>>>>> soon, even if the code doesn't go into the kernel.
>>>>> This is because user-space needs to know the values.
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> Excellent idea.  The definition of rt_task() could become:
>>>>
>>>> #define rt_task(p) ((p)->policy & (SCHED_RR|SCHED_FIFO))
>>>>
>>>> instead of the highly dodgy:
>>>
>>>
>>
>> I probably should have said "slightly" instead of "highly" here but I 
>> got carried away. :-)
>>
>>>>
>>>> #define rt_task(p) ((p)->prio < MAX_RT_PRIO)
>>>>
>>>
>>> Nothing wrong with that, is there?
>>
>>
>>
>> It's sloppy logic in that "prio" being less than MAX_RT_PRIO is a 
>> consequence of the task being real time not the definition of it.  At 
>> the moment it is a sufficient condition for identifying a task as real 
>> time but that may not always be the case.
> 
> 
> Actually, p->prio < MAX_RT_PRIO iff rt_task(p). This can't change 
> without horribly breaking
> stuff.
> 
>> But, the real issue is, what's the point of having a field, "policy", 
>> that IS the definitive indicator of the task's scheduling policy if 
>> you don't use it?  An rt_task() function/macro defined in terms of the 
>> policy field with this suggested numbering scheme should always be 
>> correct.
>>
>> At the moment rt_task(p) could be defined as ((p)->policy != 
>> SCHED_OTHER) but the addition of SCHED_ISO and SCHED_BATCH would break 
>> that.  Another option would be (((p)->policy == SCHED_FIFO) || 
>> ((p)->policy == SCHED_RR)) but that's a little long winded and 
>> (avoiding it) is probably the reason for the current definition. 
> 
> 
> 
> Conversely, p->prio < MAX_RT_PRIO neatly defines a task as being 
> realtime without worrying
> about what exact policy it is using. However if you add or remove 
> scheduling policies, your
> p->policy method breaks.

Not if Albert's numbering system is used.

Peter
-- 
Peter Williams                                   pwil3058@bigpond.net.au

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


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: SCHED_BATCH and SCHED_BATCH numbering
  2004-08-05  3:03         ` Peter Williams
@ 2004-08-05  3:06           ` Nick Piggin
  2004-08-05  2:28             ` Albert Cahalan
  2004-08-05  3:36             ` Peter Williams
  0 siblings, 2 replies; 13+ messages in thread
From: Nick Piggin @ 2004-08-05  3:06 UTC (permalink / raw)
  To: Peter Williams
  Cc: Albert Cahalan, linux-kernel mailing list, kernel, Andrew Morton OSDL

Peter Williams wrote:

> Nick Piggin wrote:
>
>> However if you add or remove scheduling policies, your
>> p->policy method breaks.
>
>
> Not if Albert's numbering system is used.
>

What if another realtime policy is added? Or one is removed?


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: SCHED_BATCH and SCHED_BATCH numbering
  2004-08-05  3:06           ` Nick Piggin
  2004-08-05  2:28             ` Albert Cahalan
@ 2004-08-05  3:36             ` Peter Williams
  2004-08-05  4:15               ` Nick Piggin
  1 sibling, 1 reply; 13+ messages in thread
From: Peter Williams @ 2004-08-05  3:36 UTC (permalink / raw)
  To: Nick Piggin
  Cc: Albert Cahalan, linux-kernel mailing list, kernel, Andrew Morton OSDL

Nick Piggin wrote:
> Peter Williams wrote:
> 
>> Nick Piggin wrote:
>>
>>> However if you add or remove scheduling policies, your
>>> p->policy method breaks.
>>
>>
>>
>> Not if Albert's numbering system is used.
>>
> 
> What if another realtime policy is added? Or one is removed?

What if the "prio" field is removed?

Peter
-- 
Peter Williams                                   pwil3058@bigpond.net.au

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


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: SCHED_BATCH and SCHED_BATCH numbering
  2004-08-05  3:36             ` Peter Williams
@ 2004-08-05  4:15               ` Nick Piggin
  0 siblings, 0 replies; 13+ messages in thread
From: Nick Piggin @ 2004-08-05  4:15 UTC (permalink / raw)
  To: Peter Williams
  Cc: Albert Cahalan, linux-kernel mailing list, kernel, Andrew Morton OSDL

Peter Williams wrote:
> Nick Piggin wrote:
> 
>> Peter Williams wrote:
>>
>>> Nick Piggin wrote:
>>>
>>>> However if you add or remove scheduling policies, your
>>>> p->policy method breaks.
>>>
>>>
>>>
>>>
>>> Not if Albert's numbering system is used.
>>>
>>
>> What if another realtime policy is added? Or one is removed?
> 
> 
> What if the "prio" field is removed?
> 

Dunno; the scheduler stops working?

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: SCHED_BATCH and SCHED_BATCH numbering
  2004-08-04 16:50 SCHED_BATCH and SCHED_BATCH numbering Albert Cahalan
  2004-08-05  1:17 ` Peter Williams
@ 2004-08-05  6:57 ` Ingo Molnar
  2004-08-05  9:48   ` Albert Cahalan
  1 sibling, 1 reply; 13+ messages in thread
From: Ingo Molnar @ 2004-08-05  6:57 UTC (permalink / raw)
  To: Albert Cahalan; +Cc: linux-kernel mailing list, kernel, Andrew Morton OSDL


* Albert Cahalan <albert@users.sf.net> wrote:

> Are these going to be numbered consecutively, or might they better be
> done like the task state? [...]

this is quite unnecessary at the moment since p->prio < MAX_RT_PRIO is a
good enough check - but whenever the way p->prio works is changed it
will be easy to introduce a PF_REALTIME flag that is set/cleared in
setscheduler(). (instead of playing around with p->policy.)

	Ingo

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: SCHED_BATCH and SCHED_BATCH numbering
  2004-08-05  2:28             ` Albert Cahalan
@ 2004-08-05  7:06               ` Nick Piggin
  0 siblings, 0 replies; 13+ messages in thread
From: Nick Piggin @ 2004-08-05  7:06 UTC (permalink / raw)
  To: Albert Cahalan
  Cc: Peter Williams, linux-kernel mailing list, kernel, Andrew Morton OSDL

Albert Cahalan wrote:
> On Wed, 2004-08-04 at 23:06, Nick Piggin wrote:
> 
>>Peter Williams wrote:
>>
>>
>>>Nick Piggin wrote:
>>>
>>>
>>>>However if you add or remove scheduling policies, your
>>>>p->policy method breaks.
>>>
>>>
>>>Not if Albert's numbering system is used.
>>>
>>
>>What if another realtime policy is added? Or one is removed?
> 
> 
> What if, what if...
> 
> You're going to have to change the code anyway.
> One might toss this into <linux/sched.h> to make
> as a nice reminder:
> 
> #define SCHEDS_RT (SCHED_RR|SCHED_FIFO)
> 

I'm not saying your renumbering is a bad idea, but making the
argument that it would simplify rt_task is bogus.

> As it is now, SCHED_FIFO is already used as a
> bit flag in one place.
> 

But it isn't a bit flag, we're just lucky it works. Submit a
patch?

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: SCHED_BATCH and SCHED_BATCH numbering
  2004-08-05  6:57 ` Ingo Molnar
@ 2004-08-05  9:48   ` Albert Cahalan
  0 siblings, 0 replies; 13+ messages in thread
From: Albert Cahalan @ 2004-08-05  9:48 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel mailing list, kernel, Andrew Morton OSDL, nickpiggin

On Thu, 2004-08-05 at 02:57, Ingo Molnar wrote:
> * Albert Cahalan <albert@users.sf.net> wrote:
> 
> > Are these going to be numbered consecutively, or might they better be
> > done like the task state? [...]
> 
> this is quite unnecessary at the moment since p->prio < MAX_RT_PRIO is a
> good enough check - but whenever the way p->prio works is changed it
> will be easy to introduce a PF_REALTIME flag that is set/cleared in
> setscheduler(). (instead of playing around with p->policy.)

That was one example. I'm guessing that one might want to
test for other policy groupings, like these:

SCHED_RR | SCHED_ISO
SCHED_BATCH | SCHED_NORMAL
SCHED_SPORADIC | SCHED_NORMAL
SCHED_EDF | SCHED_FIFO

If that's certainly not going to be useful, even in the future,
then of course there's no reason to allocate the values as bits.

In any case, it's a user ABI issue, and I'd like to see what
the allocations are going to be. Perhaps I should send in a
patch that just allocates a few of these...?



^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2004-08-05 12:19 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-08-04 16:50 SCHED_BATCH and SCHED_BATCH numbering Albert Cahalan
2004-08-05  1:17 ` Peter Williams
2004-08-05  1:27   ` Nick Piggin
2004-08-05  2:09     ` Peter Williams
2004-08-05  2:23       ` Nick Piggin
2004-08-05  3:03         ` Peter Williams
2004-08-05  3:06           ` Nick Piggin
2004-08-05  2:28             ` Albert Cahalan
2004-08-05  7:06               ` Nick Piggin
2004-08-05  3:36             ` Peter Williams
2004-08-05  4:15               ` Nick Piggin
2004-08-05  6:57 ` Ingo Molnar
2004-08-05  9:48   ` Albert Cahalan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.