Matthew Percival | 1 Dec 2005 06:02
Favicon

Scheduler mod: dropping to low power...

G'Day,

	I am looking to make a modification to the scheduler (2.6.14) for an
embedded system.  The basic idea is to drop into a lower power mode,
rather than scheduling an idle task, when there is no real work to be
done.  The plan is then to trigger a wake up on a counter interrupt, so
that it wakes just before the next timeslice is due.

	My first question is: `is this feasible?'  Would it be reasonable for
someone who is not the god of kernel hackers to make something like this
work, and work (reasonably) efficiently.  I think I have some idea about
how to do this, but am concerned I could be missing some points, and
only end up making a real mess of things.  To give some idea of my
relative skill, I have written a couple of drivers, and made a variety
of miscellaneous mods to the kernel before: lots of extensions and
alterations, but very little new ground.

	Secondly, I am thinking of doing this by replacing rq->idle with a task
which calls the sleep function (which will be added to the power
management file).  Is this a good idea, or should I instead call the
routine from a specific part of sched.c (eg somewhere in schedule())?
Replacing the idle function with my routine seems a logical way to do
things, but I have this nasty feeling that it would be the Wrong Thing.

	I am just a little concerned about touching the scheduler, and was
hoping for a little reassurance that I have the right idea before I jump
headlong into things.

	Thanks,

(Continue reading)

梅 翔 | 1 Dec 2005 08:21
Picon
Favicon

RE: Scheduler mod: dropping to low power...

I have a small question that if it really happens frequently that your 
system falls into
idle process?
Just a little oppinion, can you just create another process to do the 
"lowpower" work? I think the scheduler should try to run your "lowpower" 
process before entering idle process, because it actually means a busy 
process comparing to idle process.

>From: Matthew Percival <matthew <at> capgo.com>
>To: kernelnewbies <at> nl.linux.org
>Subject: Scheduler mod: dropping to low power...
>Date: Thu, 01 Dec 2005 16:02:56 +1100
>
>G'Day,
>
>	I am looking to make a modification to the scheduler (2.6.14) for an
>embedded system.  The basic idea is to drop into a lower power mode,
>rather than scheduling an idle task, when there is no real work to be
>done.  The plan is then to trigger a wake up on a counter interrupt, so
>that it wakes just before the next timeslice is due.
>
>	My first question is: `is this feasible?'  Would it be reasonable for
>someone who is not the god of kernel hackers to make something like this
>work, and work (reasonably) efficiently.  I think I have some idea about
>how to do this, but am concerned I could be missing some points, and
>only end up making a real mess of things.  To give some idea of my
>relative skill, I have written a couple of drivers, and made a variety
>of miscellaneous mods to the kernel before: lots of extensions and
>alterations, but very little new ground.
>
(Continue reading)

Arjan van de Ven | 1 Dec 2005 09:19
Favicon

Re: Scheduler mod: dropping to low power...

On Thu, 2005-12-01 at 16:02 +1100, Matthew Percival wrote:
> G'Day,
> 
> 	I am looking to make a modification to the scheduler (2.6.14) for an
> embedded system.  The basic idea is to drop into a lower power mode,
> rather than scheduling an idle task, when there is no real work to be
> done.  The plan is then to trigger a wake up on a counter interrupt, so
> that it wakes just before the next timeslice is due.

actually, this doesn't need touching the scheduler, it's even simpler!
For example, on x86 this is exactly done, via the "hlt" instruction.
But it's done from the idle loop itself, not from the scheduler. I
suspect your case can be exactly the same, do it from inside the idle
handler, and that is a lot simpler than having to much with the
scheduler. See the default_idle() function on i386 for how it's done
there...

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/

Libin Varghese | 1 Dec 2005 10:53
Picon

help with RAMDISK: image to big! (35512/8192 blocks)

Hi,
    This is what i get when I boot into my newly complied
RAMDISK: cramfs filesystem found at block 0
RAMDISK: image to big! (35512/8192 blocks)
RAMDISK: Coundn't find valid RAM disk image starting at 0.
VFS: Cannot open root-device "hda4" or unknown-block (0,0)
Please append a correct "root= " boot option
Kernel panic: VFS: Unable to mount root fs on unknown-block (0,0)

libin <at> debian:~$ ls -l /boot/
total 42644
lrwxrwxrwx 1 root root       12 2005-12-01 14:04 config -> config-2.6.8
-rw-r--r--  1 root root    44853 2005-05-16 13:16 config-2.4.27-2-386
-rw-r--r--  1 root root    44888 2005-12-01 14:04 config-2.6.8
drwxr-xr-x  2 root root     4096 2005-12-01 14:37 grub
-rw-r--r--  1 root root  3780608 2005-11-29 19:46 initrd.img-2.4.27-2-386
-rw-r--r--  1 root root 36364288 2005-12-01 14:06 initrd.img-2.6.8
lrwxrwxrwx  1 root root       16 2005-12-01 14:04 System.map -> 
System.map-2.6.8-rw-r--r--  1 root root   542191 2005-05-16 14:08 
System.map-2.4.27-2-386
-rw-r--r--  1 root root   827171 2005-12-01 14:04 System.map-2.6.8
lrwxrwxrwx  1 root root       13 2005-12-01 14:04 vmlinuz -> vmlinuz-2.6.8
-rw-r--r--  1 root root   816590 2005-05-16 14:08 vmlinuz-2.4.27-2-386
-rw-r--r--  1 root root  1173395 2005-12-01 14:04 vmlinuz-2.6.8

These are the entries in /boot/grub/boot

    title           Debian GNU/Linux, kernel 2.6.8 (*new*)
    root            (hd0,3)
    kernel          /boot/vmlinuz-2.6.8 root=/dev/hda4 ro
(Continue reading)

Adrian May | 1 Dec 2005 12:42

Re: Timing

I dunno how accurate it is. Maybe it's just the number of slices 
multiplied by something.

Ad.

Hayim Shaul wrote:

>
> man clock(3) read:
>
> "
> DESCRIPTION
> The clock() function returns an approximation of processor time used by
> the program.
>
> RETURN VALUE
> The value returned is the CPU time used so far as a clock_t; to get the
> number  of  seconds  used,  divide by CLOCKS_PER_SEC.  If the processor
> time used is not available or its  value  cannot  be  represented, the
> function returns the value (clock_t)-1.
> "
>
> It seems to me that this is what you are looking for.
> CLOCKS_PER_SEC is set to 1,000,000 on all machines I worked with.
>
> Is this not acurate enough?
> Or are you bothered by the word "approximation" in the description?
>
> Hayim.
>
(Continue reading)

William J Beksi | 1 Dec 2005 11:41

Re: help with RAMDISK: image to big! (35512/8192 blocks)


Libin Varghese wrote:
> Hi,
>    This is what i get when I boot into my newly complied
> RAMDISK: cramfs filesystem found at block 0
> RAMDISK: image to big! (35512/8192 blocks)
> RAMDISK: Coundn't find valid RAM disk image starting at 0.
> VFS: Cannot open root-device "hda4" or unknown-block (0,0)
> Please append a correct "root= " boot option
> Kernel panic: VFS: Unable to mount root fs on unknown-block (0,0)
> 
> libin <at> debian:~$ ls -l /boot/
> total 42644
> lrwxrwxrwx 1 root root       12 2005-12-01 14:04 config -> config-2.6.8
> -rw-r--r--  1 root root    44853 2005-05-16 13:16 config-2.4.27-2-386
> -rw-r--r--  1 root root    44888 2005-12-01 14:04 config-2.6.8
> drwxr-xr-x  2 root root     4096 2005-12-01 14:37 grub
> -rw-r--r--  1 root root  3780608 2005-11-29 19:46 initrd.img-2.4.27-2-386
> -rw-r--r--  1 root root 36364288 2005-12-01 14:06 initrd.img-2.6.8
> lrwxrwxrwx  1 root root       16 2005-12-01 14:04 System.map ->
> System.map-2.6.8-rw-r--r--  1 root root   542191 2005-05-16 14:08
> System.map-2.4.27-2-386
> -rw-r--r--  1 root root   827171 2005-12-01 14:04 System.map-2.6.8
> lrwxrwxrwx  1 root root       13 2005-12-01 14:04 vmlinuz -> vmlinuz-2.6.8
> -rw-r--r--  1 root root   816590 2005-05-16 14:08 vmlinuz-2.4.27-2-386
> -rw-r--r--  1 root root  1173395 2005-12-01 14:04 vmlinuz-2.6.8
> 
> These are the entries in /boot/grub/boot
> 
>    title           Debian GNU/Linux, kernel 2.6.8 (*new*)
(Continue reading)

Libin Varghese | 1 Dec 2005 17:17
Picon

Re: Doubt in linux/list.h

Jim Bauer wrote:

>Libin Varghese wrote:
>  
>
>>Hi,
>>   In linux/list.h, there is the following lines. Why use a do-while
>>loop when the statements inside is run only once.
>>
>>#define INIT_LIST_HEAD(ptr) do { \
>>       (ptr)->next = (ptr); (ptr)->prev = (ptr); \
>>} while (0)
>>    
>>
>
>See http://www.kernelnewbies.org/faq/
>  
>
I understand that it is neccessary for a block of statments, but we are 
they using it for a single statement

Libin Varghese
Email:        libinv <at> gmail.com

*******************************************************************
Experts arose from their own urgent need to exist. - Murphy's laws

When the software itches you, scratch the Code. - Libin Varghese :D
*******************************************************************

(Continue reading)

Thomas Petazzoni | 1 Dec 2005 17:50
Gravatar

Re: Doubt in linux/list.h

Hi,

Libin Varghese wrote:

>>> #define INIT_LIST_HEAD(ptr) do { \
>>>       (ptr)->next = (ptr); (ptr)->prev = (ptr); \
>>> } while (0)

> I understand that it is neccessary for a block of statments, but we are
> they using it for a single statement

(ptr)->next = (ptr); <= First statement.
(ptr)->prev = (ptr); <= Second one.

So, here, there are two statements.

Of course, if there's a single statement, no need to use the do {}
while(0) trick:

#define foo(a) bar(42,a+42)

Sincerly,

Thomas
--

-- 
Thomas Petazzoni
thomas.petazzoni <at> enix.org

--
Kernelnewbies: Help each other learn about the Linux kernel.
(Continue reading)

Libin Varghese | 1 Dec 2005 18:12
Picon

Re: Doubt in linux/list.h

Jim Bauer wrote:

>Did you miss the ';' in the middle of the line?
>  
>

    OOPs, I didnt notice that.

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/

Jim Bauer | 1 Dec 2005 17:27

Re: Doubt in linux/list.h

Libin Varghese wrote:
> Jim Bauer wrote:
> 
>> Libin Varghese wrote:
>>  
>>
>>> Hi,
>>>   In linux/list.h, there is the following lines. Why use a do-while
>>> loop when the statements inside is run only once.
>>>
>>> #define INIT_LIST_HEAD(ptr) do { \
>>>       (ptr)->next = (ptr); (ptr)->prev = (ptr); \
>>> } while (0)
>>>   
>>
>>
>> See http://www.kernelnewbies.org/faq/
>>  
>>
> I understand that it is neccessary for a block of statments, but we are
> they using it for a single statement

Did you miss the ';' in the middle of the line?

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/

(Continue reading)


Gmane