* question about ramdisk
@ 2004-07-12 16:57 lya755
2004-07-12 17:13 ` H. Peter Anvin
0 siblings, 1 reply; 9+ messages in thread
From: lya755 @ 2004-07-12 16:57 UTC (permalink / raw)
To: linux-kernel
Hi all,
I am learning linux kernel and have a question about ramdisk. When loading an
executable in ramdisk, is the kernel loading the code all at a time to memory
and then execute, or is it loading only a page at one time and generating a
page fault to fetch another page?
Thanks for any comments! Waiting desprately for your help.
Lei
_________________________________________________________
This message was sent through the NU ECE webmail gateway.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: question about ramdisk
2004-07-12 16:57 question about ramdisk lya755
@ 2004-07-12 17:13 ` H. Peter Anvin
2004-07-13 14:01 ` lya755
0 siblings, 1 reply; 9+ messages in thread
From: H. Peter Anvin @ 2004-07-12 17:13 UTC (permalink / raw)
To: linux-kernel
Followup to: <1089651469.40f2c30d44364@core.ece.northwestern.edu>
By author: lya755@ece.northwestern.edu
In newsgroup: linux.dev.kernel
>
> Hi all,
>
> I am learning linux kernel and have a question about ramdisk. When loading an
> executable in ramdisk, is the kernel loading the code all at a time to memory
> and then execute, or is it loading only a page at one time and generating a
> page fault to fetch another page?
>
> Thanks for any comments! Waiting desprately for your help.
>
Neither. The code is already in RAM. It's mapped into the process
address space and run in place.
-hpa
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: question about ramdisk
2004-07-12 17:13 ` H. Peter Anvin
@ 2004-07-13 14:01 ` lya755
2004-07-13 20:06 ` Lee Revell
0 siblings, 1 reply; 9+ messages in thread
From: lya755 @ 2004-07-13 14:01 UTC (permalink / raw)
To: H. Peter Anvin; +Cc: linux-kernel
Thank you! Can you pls tell me where I can find related references? I've been
looking into several books about kernel and part of the kernel code, but no
luck so far..
Thanks for any comments!
Quoting "H. Peter Anvin" <hpa@zytor.com>:
> Followup to: <1089651469.40f2c30d44364@core.ece.northwestern.edu>
> By author: lya755@ece.northwestern.edu
> In newsgroup: linux.dev.kernel
> >
> > Hi all,
> >
> > I am learning linux kernel and have a question about ramdisk. When loading
> an
> > executable in ramdisk, is the kernel loading the code all at a time to
> memory
> > and then execute, or is it loading only a page at one time and generating a
>
> > page fault to fetch another page?
> >
> > Thanks for any comments! Waiting desprately for your help.
> >
>
> Neither. The code is already in RAM. It's mapped into the process
> address space and run in place.
>
> -hpa
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>
_________________________________________________________
This message was sent through the NU ECE webmail gateway.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: question about ramdisk
2004-07-13 14:01 ` lya755
@ 2004-07-13 20:06 ` Lee Revell
2004-07-13 21:27 ` Lee Revell
[not found] ` <1089753034.40f44fca074c2@core.ece.northwestern.edu>
0 siblings, 2 replies; 9+ messages in thread
From: Lee Revell @ 2004-07-13 20:06 UTC (permalink / raw)
To: lya755; +Cc: H. Peter Anvin, linux-kernel
"Unix Internals", by Uresh Vahalia (sp?). This book went everywhere I
did for a year. I cannot praise it highly enough. Read that, then get
Robert Love's 'Linux Kernel Programming'.
Lee
On Tue, 2004-07-13 at 10:01, lya755@ece.northwestern.edu wrote:
> Thank you! Can you pls tell me where I can find related references? I've been
> looking into several books about kernel and part of the kernel code, but no
> luck so far..
>
> Thanks for any comments!
>
> Quoting "H. Peter Anvin" <hpa@zytor.com>:
>
> > Followup to: <1089651469.40f2c30d44364@core.ece.northwestern.edu>
> > By author: lya755@ece.northwestern.edu
> > In newsgroup: linux.dev.kernel
> > >
> > > Hi all,
> > >
> > > I am learning linux kernel and have a question about ramdisk. When loading
> > an
> > > executable in ramdisk, is the kernel loading the code all at a time to
> > memory
> > > and then execute, or is it loading only a page at one time and generating a
> >
> > > page fault to fetch another page?
> > >
> > > Thanks for any comments! Waiting desprately for your help.
> > >
> >
> > Neither. The code is already in RAM. It's mapped into the process
> > address space and run in place.
> >
> > -hpa
> > -
> > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at http://vger.kernel.org/majordomo-info.html
> > Please read the FAQ at http://www.tux.org/lkml/
> >
>
>
>
> _________________________________________________________
> This message was sent through the NU ECE webmail gateway.
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: question about ramdisk
2004-07-13 20:06 ` Lee Revell
@ 2004-07-13 21:27 ` Lee Revell
[not found] ` <1089753034.40f44fca074c2@core.ece.northwestern.edu>
1 sibling, 0 replies; 9+ messages in thread
From: Lee Revell @ 2004-07-13 21:27 UTC (permalink / raw)
To: lya755; +Cc: H. Peter Anvin, linux-kernel
Sorry, Robert Love's book is 'Linux Kernel Development'.
http://www.amazon.com/exec/obidos/tg/detail/-/0672325128/ref=pd_sim_books_2/002-8634838-0327232?v=glance&s=books
Lee
On Tue, 2004-07-13 at 16:06, Lee Revell wrote:
> "Unix Internals", by Uresh Vahalia (sp?). This book went everywhere I
> did for a year. I cannot praise it highly enough. Read that, then get
> Robert Love's 'Linux Kernel Programming'.
>
> Lee
>
> On Tue, 2004-07-13 at 10:01, lya755@ece.northwestern.edu wrote:
> > Thank you! Can you pls tell me where I can find related references? I've been
> > looking into several books about kernel and part of the kernel code, but no
> > luck so far..
> >
> > Thanks for any comments!
> >
> > Quoting "H. Peter Anvin" <hpa@zytor.com>:
> >
> > > Followup to: <1089651469.40f2c30d44364@core.ece.northwestern.edu>
> > > By author: lya755@ece.northwestern.edu
> > > In newsgroup: linux.dev.kernel
> > > >
> > > > Hi all,
> > > >
> > > > I am learning linux kernel and have a question about ramdisk. When loading
> > > an
> > > > executable in ramdisk, is the kernel loading the code all at a time to
> > > memory
> > > > and then execute, or is it loading only a page at one time and generating a
> > >
> > > > page fault to fetch another page?
> > > >
> > > > Thanks for any comments! Waiting desprately for your help.
> > > >
> > >
> > > Neither. The code is already in RAM. It's mapped into the process
> > > address space and run in place.
> > >
> > > -hpa
> > > -
> > > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> > > the body of a message to majordomo@vger.kernel.org
> > > More majordomo info at http://vger.kernel.org/majordomo-info.html
> > > Please read the FAQ at http://www.tux.org/lkml/
> > >
> >
> >
> >
> > _________________________________________________________
> > This message was sent through the NU ECE webmail gateway.
> > -
> > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at http://vger.kernel.org/majordomo-info.html
> > Please read the FAQ at http://www.tux.org/lkml/
> >
>
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: question about ramdisk
[not found] ` <1089753955.22175.8.camel@mindpipe>
@ 2004-07-14 14:59 ` lya755
2004-07-14 16:07 ` Richard B. Johnson
0 siblings, 1 reply; 9+ messages in thread
From: lya755 @ 2004-07-14 14:59 UTC (permalink / raw)
To: Lee Revell; +Cc: linux-kernel
Hello,
I am now thinking of a way to verify what H. Peter Anvin says about the
ramdisk, so that I can watch what is going on when the executable is running.
Is there any way to achieve that besides kernel debugging? I don't really want
to debug the kernel for now.
Can I get the physical address of the text section with it's virtual address?
If I can know the physical address of the code in ramdisk and can know the
physical address of the text section of process address space, maybe this can
be done.
Any suggestions?
Lei
Quoting Lee Revell <rlrevell@joe-job.com>:
> Sorry, wrong book, s/Programming/Development/.
>
> http://www.amazon.com/exec/obidos/tg/detail/-
/0672325128/ref=pd_sim_books_2/002-8634838-0327232?v=glance&s=books
>
> Lee
>
> On Tue, 2004-07-13 at 17:10, lya755@ece.northwestern.edu wrote:
> > BTW, is the second book you mentioned this one?
> >
> >
> http://www.amazon.com/exec/obidos/tg/detail/-/0201719754/102-1381649-9278501?
> > v=glance
> >
> >
> > Quoting Lee Revell <rlrevell@joe-job.com>:
> >
> > > "Unix Internals", by Uresh Vahalia (sp?). This book went everywhere I
> > > did for a year. I cannot praise it highly enough. Read that, then get
> > > Robert Love's 'Linux Kernel Programming'.
> > >
> > > Lee
> > >
> > > On Tue, 2004-07-13 at 10:01, lya755@ece.northwestern.edu wrote:
> > > > Thank you! Can you pls tell me where I can find related references?
> I've
> > > been
> > > > looking into several books about kernel and part of the kernel code,
> but no
> > >
> > > > luck so far..
> > > >
> > > > Thanks for any comments!
> > > >
> > > > Quoting "H. Peter Anvin" <hpa@zytor.com>:
> > > >
> > > > > Followup to: <1089651469.40f2c30d44364@core.ece.northwestern.edu>
> > > > > By author: lya755@ece.northwestern.edu
> > > > > In newsgroup: linux.dev.kernel
> > > > > >
> > > > > > Hi all,
> > > > > >
> > > > > > I am learning linux kernel and have a question about ramdisk. When
> > > loading
> > > > > an
> > > > > > executable in ramdisk, is the kernel loading the code all at a time
> to
> > > > > memory
> > > > > > and then execute, or is it loading only a page at one time and
> > > generating a
> > > > >
> > > > > > page fault to fetch another page?
> > > > > >
> > > > > > Thanks for any comments! Waiting desprately for your help.
> > > > > >
> > > > >
> > > > > Neither. The code is already in RAM. It's mapped into the process
> > > > > address space and run in place.
> > > > >
> > > > > -hpa
> > > > > -
> > > > > To unsubscribe from this list: send the line "unsubscribe
> linux-kernel"
> > > in
> > > > > the body of a message to majordomo@vger.kernel.org
> > > > > More majordomo info at http://vger.kernel.org/majordomo-info.html
> > > > > Please read the FAQ at http://www.tux.org/lkml/
> > > > >
> > > >
> > > >
> > > >
> > > > _________________________________________________________
> > > > This message was sent through the NU ECE webmail gateway.
> > > > -
> > > > To unsubscribe from this list: send the line "unsubscribe linux-kernel"
> in
> > > > the body of a message to majordomo@vger.kernel.org
> > > > More majordomo info at http://vger.kernel.org/majordomo-info.html
> > > > Please read the FAQ at http://www.tux.org/lkml/
> > > >
> > >
> >
> >
> >
> > _________________________________________________________
> > This message was sent through the NU ECE webmail gateway.
> >
>
_________________________________________________________
This message was sent through the NU ECE webmail gateway.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: question about ramdisk
2004-07-14 14:59 ` lya755
@ 2004-07-14 16:07 ` Richard B. Johnson
2004-07-14 16:30 ` lya755
0 siblings, 1 reply; 9+ messages in thread
From: Richard B. Johnson @ 2004-07-14 16:07 UTC (permalink / raw)
To: lya755; +Cc: Lee Revell, linux-kernel
On Wed, 14 Jul 2004 lya755@ece.northwestern.edu wrote:
> Hello,
>
> I am now thinking of a way to verify what H. Peter Anvin says about the
> ramdisk, so that I can watch what is going on when the executable is running.
> Is there any way to achieve that besides kernel debugging? I don't really want
> to debug the kernel for now.
>
> Can I get the physical address of the text section with it's virtual address?
> If I can know the physical address of the code in ramdisk and can know the
> physical address of the text section of process address space, maybe this can
> be done.
>
> Any suggestions?
>
> Lei
>
The physical address will do you no good because your process
uses the virtual address to access everything.
Do `cat /proc/PID/maps` where PID is a process ID number. You
will see the virtual address of the executable and runtime
shared libraries that the task is using. These are memory-mapped
into the tasks address-space.
If your code is ANYWHERE, including on a RAM-Disk, it will
be memory-mapped into your address-space just like what you
see. This allows everybody to share all the executables and
all the run-time libraries so they don't need separate copies.
For instance, here's somebody running the `bash` shell:
08048000-0808c000 r-xp 00000000 08:11 1440929 /usr/bin/bash
0808c000-08092000 rw-p 00043000 08:11 1440929 /usr/bin/bash
08092000-080a2000 rwxp 00000000 00:00 0
40000000-4000a000 r-xp 00000000 08:11 475506 /usr/lib/ld-2.0.5.so
4000a000-4000b000 rw-p 00009000 08:11 475506 /usr/lib/ld-2.0.5.so
4000b000-4000c000 rwxp 00000000 00:00 0
4000c000-40010000 r--p 00000000 08:11 163651 /etc/ld.so.cache
40010000-40012000 rwxp 00000000 08:11 1030227 /lib/libtermcap.so.2.0.8
40012000-40014000 rw-p 00001000 08:11 1030227 /lib/libtermcap.so.2.0.8
40014000-4009f000 r-xp 00000000 08:11 475508 /usr/lib/libc-2.0.6.so
4009f000-400a5000 rw-p 0008b000 08:11 475508 /usr/lib/libc-2.0.6.so
[SNIPPED...]
You can see the virtual address of your own stuff by compiling
and executing this:
#include <stdio.h>
extern char _start;
extern char _end;
char dat;
const char x[]="x";
int main()
{
char foo;
printf("start = %p\n", &_start);
printf(" main = %p\n", main);
printf(" data = %p\n", &dat);
printf("const = %p\n", x);
printf("stack = %p\n", &foo);
printf(" end = %p\n", &_end);
return 0;
}
The physical address in RAM could be anywhere. The kernel takes
pages of RAM from anywhere and makes them look contiguous for
each task. So what looks like linear address-space is made up
of (on ix86 0x1000 byte) pages of RAM.
Cheers,
Dick Johnson
Penguin : Linux version 2.4.26 on an i686 machine (5570.56 BogoMips).
Note 96.31% of all statistics are fiction.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: question about ramdisk
2004-07-14 16:07 ` Richard B. Johnson
@ 2004-07-14 16:30 ` lya755
2004-07-14 16:57 ` Richard B. Johnson
0 siblings, 1 reply; 9+ messages in thread
From: lya755 @ 2004-07-14 16:30 UTC (permalink / raw)
To: root; +Cc: linux-kernel
Thanks so much for the hint! Really appreciate it. I'll try out your
suggestions.
I am still a bit confused, though. If the code is in ramdisk, then it will be
mapped to the process address space, which as I understand, does not involve
any actual data copy and transfer. This sounds very reasonable. But what if
the code is in hard disk? Would the kernel copy it to memory (somewhere
allocated) then map this region as the text section for the address space, and
then run the instructions from ram? That's the way I understand it, but I
don't know whether that is correct.
Thanks!
Lei
Quoting "Richard B. Johnson" <root@chaos.analogic.com>:
> On Wed, 14 Jul 2004 lya755@ece.northwestern.edu wrote:
>
> > Hello,
> >
> > I am now thinking of a way to verify what H. Peter Anvin says about the
> > ramdisk, so that I can watch what is going on when the executable is
> running.
> > Is there any way to achieve that besides kernel debugging? I don't really
> want
> > to debug the kernel for now.
> >
> > Can I get the physical address of the text section with it's virtual
> address?
> > If I can know the physical address of the code in ramdisk and can know the
> > physical address of the text section of process address space, maybe this
> can
> > be done.
> >
> > Any suggestions?
> >
> > Lei
> >
>
> The physical address will do you no good because your process
> uses the virtual address to access everything.
>
> Do `cat /proc/PID/maps` where PID is a process ID number. You
> will see the virtual address of the executable and runtime
> shared libraries that the task is using. These are memory-mapped
> into the tasks address-space.
>
> If your code is ANYWHERE, including on a RAM-Disk, it will
> be memory-mapped into your address-space just like what you
> see. This allows everybody to share all the executables and
> all the run-time libraries so they don't need separate copies.
>
> For instance, here's somebody running the `bash` shell:
>
> 08048000-0808c000 r-xp 00000000 08:11 1440929 /usr/bin/bash
> 0808c000-08092000 rw-p 00043000 08:11 1440929 /usr/bin/bash
> 08092000-080a2000 rwxp 00000000 00:00 0
> 40000000-4000a000 r-xp 00000000 08:11 475506 /usr/lib/ld-2.0.5.so
> 4000a000-4000b000 rw-p 00009000 08:11 475506 /usr/lib/ld-2.0.5.so
> 4000b000-4000c000 rwxp 00000000 00:00 0
> 4000c000-40010000 r--p 00000000 08:11 163651 /etc/ld.so.cache
> 40010000-40012000 rwxp 00000000 08:11 1030227 /lib/libtermcap.so.2.0.8
> 40012000-40014000 rw-p 00001000 08:11 1030227 /lib/libtermcap.so.2.0.8
> 40014000-4009f000 r-xp 00000000 08:11 475508 /usr/lib/libc-2.0.6.so
> 4009f000-400a5000 rw-p 0008b000 08:11 475508 /usr/lib/libc-2.0.6.so
> [SNIPPED...]
>
> You can see the virtual address of your own stuff by compiling
> and executing this:
>
> #include <stdio.h>
> extern char _start;
> extern char _end;
> char dat;
> const char x[]="x";
>
> int main()
> {
> char foo;
> printf("start = %p\n", &_start);
> printf(" main = %p\n", main);
> printf(" data = %p\n", &dat);
> printf("const = %p\n", x);
> printf("stack = %p\n", &foo);
> printf(" end = %p\n", &_end);
> return 0;
> }
>
> The physical address in RAM could be anywhere. The kernel takes
> pages of RAM from anywhere and makes them look contiguous for
> each task. So what looks like linear address-space is made up
> of (on ix86 0x1000 byte) pages of RAM.
>
> Cheers,
> Dick Johnson
> Penguin : Linux version 2.4.26 on an i686 machine (5570.56 BogoMips).
> Note 96.31% of all statistics are fiction.
>
>
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>
_________________________________________________________
This message was sent through the NU ECE webmail gateway.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: question about ramdisk
2004-07-14 16:30 ` lya755
@ 2004-07-14 16:57 ` Richard B. Johnson
0 siblings, 0 replies; 9+ messages in thread
From: Richard B. Johnson @ 2004-07-14 16:57 UTC (permalink / raw)
To: lya755; +Cc: linux-kernel
On Wed, 14 Jul 2004 lya755@ece.northwestern.edu wrote:
> Thanks so much for the hint! Really appreciate it. I'll try out your
> suggestions.
>
> I am still a bit confused, though. If the code is in ramdisk, then it will be
> mapped to the process address space, which as I understand, does not involve
> any actual data copy and transfer. This sounds very reasonable. But what if
> the code is in hard disk? Would the kernel copy it to memory (somewhere
> allocated) then map this region as the text section for the address space, and
> then run the instructions from ram? That's the way I understand it, but I
> don't know whether that is correct.
>
> Thanks!
> Lei
The instructions are always executed from RAM even if the executable
file is on a physical disk. The file is memory-mapped. Execute
`man mmap`. One of the parameters is MAP_FILE. The whole file
is mapped, however, only that which is necessary at a particular
time is actually read from the disk, one page at a time.
Cheers,
Dick Johnson
Penguin : Linux version 2.4.26 on an i686 machine (5570.56 BogoMips).
Note 96.31% of all statistics are fiction.
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2004-07-14 16:57 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-07-12 16:57 question about ramdisk lya755
2004-07-12 17:13 ` H. Peter Anvin
2004-07-13 14:01 ` lya755
2004-07-13 20:06 ` Lee Revell
2004-07-13 21:27 ` Lee Revell
[not found] ` <1089753034.40f44fca074c2@core.ece.northwestern.edu>
[not found] ` <1089753955.22175.8.camel@mindpipe>
2004-07-14 14:59 ` lya755
2004-07-14 16:07 ` Richard B. Johnson
2004-07-14 16:30 ` lya755
2004-07-14 16:57 ` Richard B. Johnson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox