Re: Changing the default scheduler

2016-05-26 Thread Armand Zangue
> What would I have to do if I instead wanted to change the scheduler class
> that is used when a process specifies the SCHED_NORMAL policy? Is there a
> way to do that without replacing the CFS source at fair.c?

I'm not sure if it is the safer way to do this, but I think you can
achieve this by changing the __setcheduler() method in core.c to
ignore
priority and always set scheduler to whatever scheduler you would want
to default.

This also prevent you from changing the tasks to have the same
priority and reverting would be a matter of reconsidering priority.

Regards

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Changing the default scheduler

2016-05-25 Thread Renato Utsch
Changing the policy of the init process at include/linux/init_task.h
worked! Although a lot of tasks asked to change the scheduler policy to
SCHED_NORMAL (and thus the scheduler class to CFS) through
sched_setscheduler(), so I had to add some code there to force the SCHED_RR
policy.

I made the priority of the tasks to be the same of the init process, so the
RT scheduler turned (I think) into a simple Round-Robin scheduler, as the
priority of almost all processes is the same. The only processes that had
higher priority were the ones that already runned using the RT scheduler
even when the CFS was being used.

The linux booted up okay, although I am not using a desktop environment, so
I don't know if it would boot up if it had XOrg.

What would I have to do if I instead wanted to change the scheduler class
that is used when a process specifies the SCHED_NORMAL policy? Is there a
way to do that without replacing the CFS source at fair.c?

Thanks.

Em ter, 24 de mai de 2016 às 12:22, Frederic Weisbecker 
escreveu:

> (Sorry I forgot to Cc kernelnewbies, I fixed the Cc line).
>
> On Tue, May 24, 2016 at 11:47:37AM +, Renato Utsch wrote:
> > Hi Frederic,
> >
> > Thanks, this was exactly what I was looking for! I was suspecting that
> all
> > the processes would inherit the policy of the init process, but I didn't
> > know where to look at. I'll take a look at this and see what happens.
> >
> > By the way, how are the scheduler policies and the schedulers related?
> > Because the RT scheduler can be used with either SCHED_FIFO or SCHED_RR.
> > Are some policies linked to particular schedulers? If so, can I introduce
> > new SCHED_* constants? How should I do that if I want to call
> > sched_setscheduler() to change the policy to, say, SCHED_MY in an
> userspace
> > program?
>
> What you refer as "scheduler" is in fact a scheduler class.
> So we have two different notions here: scheduler policy and scheduler
> class.
>
> _ The scheduler policy is set by the user or the system to tell how to
> schedule a task.
>   That's in the user interface level.
>
> _ The scheduler classes handle the tasks scheduling differently on top of
> their scheduler policy (driven
>   by the user) or on top of kernel internal needs (idle_sched_class and
> stop_sched_class).
>
>   We have 4 of them, from lowest prio to highest:
>
>  _ idle_sched_class = implement idle tasks. The idle tasks (one per
> CPU)
>   are set with SCHED_NORMAL but the policy of idle
> tasks are
>   not even checked.
>
>  _ fair_sched_class = implement SCHED_NORMAL/SCHED_FAIR and SCHED_IDLE
> (not to be confused
>   with idle tasks. In fact SCHED_IDLE tasks are
> normal tasks that execute
>   when there is no SCHED_NORMAL tasks to run)
>
>  _ rt_sched_class   = implement SCHED_RR and SCHED_FIFO
>
>  _ dl_sched_class   = deadline realtime tasks (SCHED_DEADLINE)
>
>  _ stop_sched_class = stop machine tasks. They don't refer to any
> policy, the stop machine
>   tasks call sched_set_stop_task() to switch to
> this class. Their policy
>   are SCHED_NORMAL but it's ignored.
>
>That's in the implementation level.
>
> When the scheduler needs to choose the next task to run on the CPU, it
> iterates each class
> from highest prio to lower: (stop, dl, rt, fair, idle) and calls the
> ->pick_next_task()
> callback for each of these classes. The first one that has a task to run
> will have it on
> the CPU. This is how class priorities are implemented.
>
> So if you want to implement a new policy, the easiest is to create a new
> scheduler class
> but you'll need to decide where it fits between the classes prio.
>
> Now when people talk about re-implementing the scheduler, they usually
> mean the way to schedule
> the SCHED_NORMAL tasks. If that's what you're interested in, I think you
> rather want to rewrite
> kernel/sched/fair.c and do your own fair_sched_class implementation.
>
> Now kernel/sched/fair.c does a lot more than just implement
> fair_sched_class so rewriting it the
> way you like to experiment will be painful due to the links it has all
> around in the core kernel.
> Perhaps it's easier to create your own policy, define its prio between
> idle_sched_class and
> fair_sched_class then run your task under that policy on a CPU that
> doesn't have any SCHED_NORMAL
> tasks.
>
> You can also set the init/0 task to your policy but there is no guarantee
> it will propagate all
> along recursively to the whole process tree as anything can override a
> parent back to SCHED_NORMAL
> at some point.
>
> Thanks.
>
> >
> > Em ter, 24 de mai de 2016 às 08:39, Frederic Weisbecker <
> fweis...@gmail.com>
> > escreveu:
> >
> > > Hi Renato,
> > >
> > > What you're talking about is not exactly the scheduler but the
> scheduler
> > > policy. Basically the scheduler policy is inherited on fork(). The very
> > > firs

Re: Changing the default scheduler

2016-05-24 Thread Frederic Weisbecker
(Sorry I forgot to Cc kernelnewbies, I fixed the Cc line).

On Tue, May 24, 2016 at 11:47:37AM +, Renato Utsch wrote:
> Hi Frederic,
> 
> Thanks, this was exactly what I was looking for! I was suspecting that all
> the processes would inherit the policy of the init process, but I didn't
> know where to look at. I'll take a look at this and see what happens.
> 
> By the way, how are the scheduler policies and the schedulers related?
> Because the RT scheduler can be used with either SCHED_FIFO or SCHED_RR.
> Are some policies linked to particular schedulers? If so, can I introduce
> new SCHED_* constants? How should I do that if I want to call
> sched_setscheduler() to change the policy to, say, SCHED_MY in an userspace
> program?

What you refer as "scheduler" is in fact a scheduler class.
So we have two different notions here: scheduler policy and scheduler class.

_ The scheduler policy is set by the user or the system to tell how to schedule 
a task.
  That's in the user interface level.

_ The scheduler classes handle the tasks scheduling differently on top of their 
scheduler policy (driven
  by the user) or on top of kernel internal needs (idle_sched_class and 
stop_sched_class).

  We have 4 of them, from lowest prio to highest:

 _ idle_sched_class = implement idle tasks. The idle tasks (one per CPU)
  are set with SCHED_NORMAL but the policy of idle 
tasks are
  not even checked.

 _ fair_sched_class = implement SCHED_NORMAL/SCHED_FAIR and SCHED_IDLE (not 
to be confused
  with idle tasks. In fact SCHED_IDLE tasks are normal 
tasks that execute
  when there is no SCHED_NORMAL tasks to run)

 _ rt_sched_class   = implement SCHED_RR and SCHED_FIFO

 _ dl_sched_class   = deadline realtime tasks (SCHED_DEADLINE)

 _ stop_sched_class = stop machine tasks. They don't refer to any policy, 
the stop machine
  tasks call sched_set_stop_task() to switch to this 
class. Their policy
  are SCHED_NORMAL but it's ignored.

   That's in the implementation level.

When the scheduler needs to choose the next task to run on the CPU, it iterates 
each class
from highest prio to lower: (stop, dl, rt, fair, idle) and calls the 
->pick_next_task()
callback for each of these classes. The first one that has a task to run will 
have it on
the CPU. This is how class priorities are implemented.

So if you want to implement a new policy, the easiest is to create a new 
scheduler class
but you'll need to decide where it fits between the classes prio.

Now when people talk about re-implementing the scheduler, they usually mean the 
way to schedule
the SCHED_NORMAL tasks. If that's what you're interested in, I think you rather 
want to rewrite
kernel/sched/fair.c and do your own fair_sched_class implementation.

Now kernel/sched/fair.c does a lot more than just implement fair_sched_class so 
rewriting it the
way you like to experiment will be painful due to the links it has all around 
in the core kernel.
Perhaps it's easier to create your own policy, define its prio between 
idle_sched_class and
fair_sched_class then run your task under that policy on a CPU that doesn't 
have any SCHED_NORMAL
tasks.

You can also set the init/0 task to your policy but there is no guarantee it 
will propagate all
along recursively to the whole process tree as anything can override a parent 
back to SCHED_NORMAL
at some point.

Thanks.

> 
> Em ter, 24 de mai de 2016 às 08:39, Frederic Weisbecker 
> escreveu:
> 
> > Hi Renato,
> >
> > What you're talking about is not exactly the scheduler but the scheduler
> > policy. Basically the scheduler policy is inherited on fork(). The very
> > first task (init/0) is initialized with SCHED_NORMAL and this policy is
> > inherited recursively through all subsequent fork() calls as it is the root
> > parent task. If you want all tasks in the system to inherit a SCHED_FIFO
> > policy, you need to change the policy of init/0. This is probably feasible
> > in include/linux/init_task.h (I can't check that right now). Now since
> > every task will have a real time policy, some of them may starve others.
> > You may observe surprising behaviour,  your system could even fail to boot.
> >
> > Have fun.
> > Le 20 mai 2016 01:51, "Renato Utsch"  a écrit :
> >
> >> Hello,
> >>
> >> I am a new developer trying to learn how to tinker with the kernel. I
> >> searched on the internet but couldn't find much info about this (and
> >> couldn't find any info up to date).
> >>
> >> My question is, how does the kernel decide which is the default scheduler
> >> that all processes start with? I can change the scheduler of a process by
> >> sched_setscheduler(), but how do I change *all* processes from using the
> >> CFS scheduler to, for example, the RR scheduler?
> >>
> >> Sorry if this is too basic, but I don't know where to search for this. If
> >> you guys could

Re: Changing the default scheduler

2016-05-24 Thread Renato Utsch
Yes, I've managed to go this far.  My problem is discovering where to
change on the code to change the default scheduler. It is my first time
trying to understand the linux sources, and I couldn't find much updated
info online.

Em Ter, 24 de mai de 2016 3:04 AM, Mulyadi Santosa <
mulyadi.sant...@gmail.com> escreveu:

>
>
> On Tue, May 24, 2016 at 7:59 AM, Renato Utsch 
> wrote:
>
>> The idea is to patch the kernel. I am trying to discover how I can set
>> the default scheduler for new processes, so that I can test the behavior of
>> any schedulers that I may write. Do you have any ideas?
>>
>> Em Seg, 23 de mai de 2016 10:05 AM, Mulyadi Santosa <
>> mulyadi.sant...@gmail.com> escreveu:
>>
>>> On Fri, May 20, 2016 at 6:51 AM, Renato Utsch 
>>> wrote:
>>>
 Hello,

 I am a new developer trying to learn how to tinker with the kernel. I
 searched on the internet but couldn't find much info about this (and
 couldn't find any info up to date).

 My question is, how does the kernel decide which is the default
 scheduler that all processes start with? I can change the scheduler of a
 process by sched_setscheduler(), but how do I change *all* processes from
 using the CFS scheduler to, for example, the RR scheduler?

 Sorry if this is too basic, but I don't know where to search for this.
 If you guys could point me places where I can learn more about this, I
 would be grateful.

 ___
 Kernelnewbies mailing list
 Kernelnewbies@kernelnewbies.org
 http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


>>> Hi..
>>>
>>> putting aside scheduler plugins module that once exist and maintained
>>> (not sure now), I guess the only way to switch to new scheduler is to patch
>>> your kernel first (if you haven't do that) with scheduler patch such as Con
>>> Kolivas BFS and reboot to that new kernel.
>>>
>>>
>>> --
>>> regards,
>>>
>>> Mulyadi Santosa
>>> Freelance Linux trainer and consultant
>>>
>>> blog: the-hydra.blogspot.com
>>> training: mulyaditraining.blogspot.com
>>>
>>
>
> Hi...
>
> Probably you need to provide several kernel image, each contains different
> scheduler algorithm you want to test.
>
> So in other word, IMHO, the only way to test different scheduler algorithm
> is to boot to different kernel each time.
>
> CMIIW
>
>
> --
> regards,
>
> Mulyadi Santosa
> Freelance Linux trainer and consultant
>
> blog: the-hydra.blogspot.com
> training: mulyaditraining.blogspot.com
>
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Changing the default scheduler

2016-05-23 Thread Mulyadi Santosa
On Tue, May 24, 2016 at 7:59 AM, Renato Utsch  wrote:

> The idea is to patch the kernel. I am trying to discover how I can set the
> default scheduler for new processes, so that I can test the behavior of any
> schedulers that I may write. Do you have any ideas?
>
> Em Seg, 23 de mai de 2016 10:05 AM, Mulyadi Santosa <
> mulyadi.sant...@gmail.com> escreveu:
>
>> On Fri, May 20, 2016 at 6:51 AM, Renato Utsch 
>> wrote:
>>
>>> Hello,
>>>
>>> I am a new developer trying to learn how to tinker with the kernel. I
>>> searched on the internet but couldn't find much info about this (and
>>> couldn't find any info up to date).
>>>
>>> My question is, how does the kernel decide which is the default
>>> scheduler that all processes start with? I can change the scheduler of a
>>> process by sched_setscheduler(), but how do I change *all* processes from
>>> using the CFS scheduler to, for example, the RR scheduler?
>>>
>>> Sorry if this is too basic, but I don't know where to search for this.
>>> If you guys could point me places where I can learn more about this, I
>>> would be grateful.
>>>
>>> ___
>>> Kernelnewbies mailing list
>>> Kernelnewbies@kernelnewbies.org
>>> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>>>
>>>
>> Hi..
>>
>> putting aside scheduler plugins module that once exist and maintained
>> (not sure now), I guess the only way to switch to new scheduler is to patch
>> your kernel first (if you haven't do that) with scheduler patch such as Con
>> Kolivas BFS and reboot to that new kernel.
>>
>>
>> --
>> regards,
>>
>> Mulyadi Santosa
>> Freelance Linux trainer and consultant
>>
>> blog: the-hydra.blogspot.com
>> training: mulyaditraining.blogspot.com
>>
>

Hi...

Probably you need to provide several kernel image, each contains different
scheduler algorithm you want to test.

So in other word, IMHO, the only way to test different scheduler algorithm
is to boot to different kernel each time.

CMIIW


-- 
regards,

Mulyadi Santosa
Freelance Linux trainer and consultant

blog: the-hydra.blogspot.com
training: mulyaditraining.blogspot.com
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Changing the default scheduler

2016-05-23 Thread Renato Utsch
The idea is to patch the kernel. I am trying to discover how I can set the
default scheduler for new processes, so that I can test the behavior of any
schedulers that I may write. Do you have any ideas?

Em Seg, 23 de mai de 2016 10:05 AM, Mulyadi Santosa <
mulyadi.sant...@gmail.com> escreveu:

> On Fri, May 20, 2016 at 6:51 AM, Renato Utsch 
> wrote:
>
>> Hello,
>>
>> I am a new developer trying to learn how to tinker with the kernel. I
>> searched on the internet but couldn't find much info about this (and
>> couldn't find any info up to date).
>>
>> My question is, how does the kernel decide which is the default scheduler
>> that all processes start with? I can change the scheduler of a process by
>> sched_setscheduler(), but how do I change *all* processes from using the
>> CFS scheduler to, for example, the RR scheduler?
>>
>> Sorry if this is too basic, but I don't know where to search for this. If
>> you guys could point me places where I can learn more about this, I would
>> be grateful.
>>
>> ___
>> Kernelnewbies mailing list
>> Kernelnewbies@kernelnewbies.org
>> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>>
>>
> Hi..
>
> putting aside scheduler plugins module that once exist and maintained (not
> sure now), I guess the only way to switch to new scheduler is to patch your
> kernel first (if you haven't do that) with scheduler patch such as Con
> Kolivas BFS and reboot to that new kernel.
>
>
> --
> regards,
>
> Mulyadi Santosa
> Freelance Linux trainer and consultant
>
> blog: the-hydra.blogspot.com
> training: mulyaditraining.blogspot.com
>
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Changing the default scheduler

2016-05-23 Thread Mulyadi Santosa
On Fri, May 20, 2016 at 6:51 AM, Renato Utsch  wrote:

> Hello,
>
> I am a new developer trying to learn how to tinker with the kernel. I
> searched on the internet but couldn't find much info about this (and
> couldn't find any info up to date).
>
> My question is, how does the kernel decide which is the default scheduler
> that all processes start with? I can change the scheduler of a process by
> sched_setscheduler(), but how do I change *all* processes from using the
> CFS scheduler to, for example, the RR scheduler?
>
> Sorry if this is too basic, but I don't know where to search for this. If
> you guys could point me places where I can learn more about this, I would
> be grateful.
>
> ___
> Kernelnewbies mailing list
> Kernelnewbies@kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>
>
Hi..

putting aside scheduler plugins module that once exist and maintained (not
sure now), I guess the only way to switch to new scheduler is to patch your
kernel first (if you haven't do that) with scheduler patch such as Con
Kolivas BFS and reboot to that new kernel.


-- 
regards,

Mulyadi Santosa
Freelance Linux trainer and consultant

blog: the-hydra.blogspot.com
training: mulyaditraining.blogspot.com
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies