 |
|
 |
|
Next: [Samba] Memory usage
|
| Author |
Message |
External

Since: Aug 21, 2007 Posts: 7
|
(Msg. 1) Posted: Mon Aug 20, 2007 8:02 pm
Post subject: where 's the location of the implementation of mlock method under linux & glibc? Archived from groups: comp>os>linux>development>apps (more info?)
|
|
|
Hi ,
I'm using the mlock() to lock pages,
and search the glibc-2.3.6 source code for its implementation.
but i get nothing expect a general dummy definition and a hurd
implementation.
Where is the linux i386 version of mlock implementation ?
is it in kernel? which file, doesn't glibc wrap the mlock if it is
in kernel ?
Thanks
sods |
|
| Back to top |
|
 |  |
External

Since: Nov 19, 2003 Posts: 37
|
(Msg. 2) Posted: Tue Aug 21, 2007 2:40 pm
Post subject: Re: where 's the location of the implementation of mlock method [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
sods <skyofdreams RemoveThis @gmail.com> writes:
> I'm using the mlock() to lock pages,
> and search the glibc-2.3.6 source code for its implementation.
> but i get nothing expect a general dummy definition and a hurd
> implementation.
>
> Where is the linux i386 version of mlock implementation ?
From ChangeLog.5 in glibc-2.5 sources:
Thu Jan 18 00:32:43 1996 Roland McGrath <roland RemoveThis @churchy.gnu.ai.mit.edu>
....
Replaced all simple system call files *.S throughout sysdeps/unix
with syscalls.list files to be processed by make-syscalls.sh.
....
* sysdeps/unix/sysv/linux/mlock.S: File removed.
> is it in kernel?
There is sys_mlock() in the kernel, but that has nothing whatsoever to do
with glibc mlock syscall wrapper.
Cheers,
--
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email. |
|
| Back to top |
|
 |  |
External

Since: Aug 21, 2007 Posts: 7
|
(Msg. 3) Posted: Tue Aug 21, 2007 7:08 pm
Post subject: Re: where 's the location of the implementation of mlock method under linux & glibc? [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
On Aug 22, 10:40 am, Paul Pluzhnikov <ppluzhnikov-....TakeThisOut@charter.net>
wrote:
> sods <skyofdre....TakeThisOut@gmail.com> writes:
> > I'm using the mlock() to lock pages,
> > and search the glibc-2.3.6 source code for its implementation.
> > but i get nothing expect a general dummy definition and a hurd
> > implementation.
>
> > Where is the linux i386 version of mlock implementation ?
>
> From ChangeLog.5 in glibc-2.5 sources:
>
> Thu Jan 18 00:32:43 1996 Roland McGrath <rol....TakeThisOut@churchy.gnu.ai.mit.edu>
> ...
> Replaced all simple system call files *.S throughout sysdeps/unix
> with syscalls.list files to be processed by make-syscalls.sh.
> ...
> * sysdeps/unix/sysv/linux/mlock.S: File removed.
>
Thanks.
it's a good point.
and
this implementation is really a little magic.
> > is it in kernel?
>
> There is sys_mlock() in the kernel, but that has nothing whatsoever to do
> with glibc mlock syscall wrapper.
I do some findings.
all method in syscalls.list are "compiled" into object file in
glibc-build/misc/
--
glibc-build/misc/mlock.o
glibc-build/misc/mlockall.o
--
and finally link into libc.os.6, so
libc.so.6 have mlock in .text section.
--
00bc0d0 T mlock
000bc150 T mlockall
--
so , the mlock in libc.so.6 is a wrapper? should be,
but the mechanism of this wrapper is still unclear.
-sods |
|
| Back to top |
|
 |  |
External

Since: Nov 19, 2003 Posts: 37
|
(Msg. 4) Posted: Wed Aug 22, 2007 2:30 pm
Post subject: Re: where 's the location of the implementation of mlock method [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
sods <skyofdreams.TakeThisOut@gmail.com> writes:
> so , the mlock in libc.so.6 is a wrapper?
Yes, it's a wrapper for the syscall:
0x000ba000 <mlock+0>: mov %ebx,%edx # %ebx must be preserved
0x000ba002 <mlock+2>: mov 0x8(%esp),%ecx # load second arg into %ecx
0x000ba006 <mlock+6>: mov 0x4(%esp),%ebx # load first arg into %ebx
0x000ba00a <mlock+10>: mov $0x96,%eax # 0x96 == 150 == __NR_mlock /usr/include/asm/unistd.h
0x000ba00f <mlock+15>: int $0x80 # syscall
> but the mechanism of this wrapper is still unclear.
It's unclear to me what's unclear to you.
Did you read make-syscalls.sh? Did you understand what it does?
Cheers,
--
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email. |
|
| Back to top |
|
 |  |
External

Since: Aug 21, 2007 Posts: 7
|
(Msg. 5) Posted: Wed Aug 22, 2007 6:21 pm
Post subject: Re: where 's the location of the implementation of mlock method under linux & glibc? [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
On Aug 23, 10:30 am, Paul Pluzhnikov <ppluzhnikov-....TakeThisOut@charter.net>
wrote:
> sods <skyofdre....TakeThisOut@gmail.com> writes:
> > so , the mlock in libc.so.6 is a wrapper?
>
> Yes, it's a wrapper for the syscall:
>
> 0x000ba000 <mlock+0>: mov %ebx,%edx # %ebx must be preserved
> 0x000ba002 <mlock+2>: mov 0x8(%esp),%ecx # load second arg into %ecx
> 0x000ba006 <mlock+6>: mov 0x4(%esp),%ebx # load first arg into %ebx
> 0x000ba00a <mlock+10>: mov $0x96,%eax # 0x96 == 150 == __NR_mlock /usr/include/asm/unistd.h
> 0x000ba00f <mlock+15>: int $0x80 # syscall
>
yes, it's more clear from asm code.
just a simple wrapper.
> > but the mechanism of this wrapper is still unclear.
>
> It's unclear to me what's unclear to you.
>
> Did you read make-syscalls.sh? Did you understand what it does?
>
I have readed it now.
it's the make-syscalls.sh where the magic is in.
Makefile use it to create another script call sysd-syscallT, which
then do the actual operations.
sysd-syscallT seems generate the c source wrapper code, and pass them
to gcc through pipe. (.. pipe so no mlock.c file.)
but it all doesn't matter ,
I want to know what logic is processed when i call mlock.
If the glibc just a simple wrapper, all actual case should happen in
kernel.
now, i know it's in kernel, i 'll dip into kernel a little , e.g.
learn how trap works
to contnue.
thanks, for the help.
-sods
> Cheers,
> --
> In order to understand recursion you must first understand recursion.
> Remove /-nsp/ for email. |
|
| Back to top |
|
 |  |
External

Since: Nov 19, 2003 Posts: 37
|
(Msg. 6) Posted: Thu Aug 23, 2007 2:19 am
Post subject: Re: where 's the location of the implementation of mlock method [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
sods <skyofdreams RemoveThis @gmail.com> writes:
> I want to know what logic is processed when i call mlock.
If you want to understand the logic for *any* system call, you have
to look in the kernel -- that's where the code for them resides
(and that's what makes them 'system call', as opposed to libc calls).
> now, i know it's in kernel, i 'll dip into kernel a little , e.g.
> learn how trap works to contnue.
If you want to understand what mlock does, start with sys_mlock
in /usr/src/linux-X.Y/mm/mlock.c (it's somewhat long way from how
trap works, you can just assume that int80 with %eax==150 eventually
gets to sys_mlock in the kernel).
Cheers,
--
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email. |
|
| Back to top |
|
 |  |
External

Since: Aug 21, 2007 Posts: 7
|
(Msg. 7) Posted: Thu Aug 23, 2007 12:59 pm
Post subject: Re: where 's the location of the implementation of mlock method under linux & glibc? [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
On Aug 23, 10:19 pm, Paul Pluzhnikov <ppluzhnikov-....TakeThisOut@charter.net>
wrote:
> sods <skyofdre....TakeThisOut@gmail.com> writes:
> > I want to know what logic is processed when i call mlock.
>
> If you want to understand the logic for *any* system call, you have
> to look in the kernel -- that's where the code for them resides
> (and that's what makes them 'system call', as opposed to libc calls).
Yeah, you're right,
Several day ago, i thought libc calls have some 'real' logic to
wrap the system call.
but seems this doesn't happen to mlock.
>
> > now, i know it's in kernel, i 'll dip into kernel a little , e.g.
> > learn how trap works to contnue.
>
> If you want to understand what mlock does, start with sys_mlock
> in /usr/src/linux-X.Y/mm/mlock.c (it's somewhat long way from how
> trap works, you can just assume that int80 with %eax==150 eventually
> gets to sys_mlock in the kernel).
Thanks, i'll try to read the mm/mlock.c@sys_mlock
i guess if i meet more problems, the help topic should appear on
comp.os.linux.system.
Thank for your help, again.
-sods
>
> Cheers,
> --
> In order to understand recursion you must first understand recursion.
> Remove /-nsp/ for email. |
|
| Back to top |
|
 |  |
|
You can post new topics in this forum You can reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|
 |
|
|