Skip to contentSkip to conversation

do_brk() trace mystery

DISCUSSION sting sting 2 participants 2 messages Mar 12, 2004

lore
Share & tools
lore
#0 lore raw

Hello,
for debugging purpoese I had used the strace utilitty. The command I had traced with starce was
"cat /proc/interrupts".

Well , I saw that there were not a few calls to the brk() system calls.

What I know is the brk() is a system call that is intended to enlarge procees memory and is supposed to be called by the memory manager when sensing that a process needs more memory.

But I did a search on the kernel tree fo do_brk() and I found only 5 entries (in 2.6 kernel and also in 2.4.24). One of the was the declaration in mm.h; the other was implementation in mmap.c

Now the 2 others were in binfmt_out.c and in binfmt_elf.c

(in 2.4.20 it is also in ksyms.c ; in 2.6 it is not but it is in mm/nommu.c)

So the mystery is : who calls the brk() system call when I type "cat /proc/interrupts"

It does not seem to me that it is binfmt_out.c and in binfmt_elf.c (Or am I wrong)?

(BTW,searching for sys_mmap gives 2 results:
\linux-2.4.24\arch\i386\kernel\sys_i386.c
and the entry.s file)

regards,
Sting

_________________________________________________________________
Add photos to your messages with MSN 8. Get 2 months FREE*. http://join.msn.com/?page=features/featuredemail

#1 lore raw
Quoted 4 lines · sting sting

But I did a search on the kernel tree fo do_brk() and I found only 5 entries (in 2.6 kernel and also in 2.4.24). One of the was the declaration in mm.h; the other was implementation in mmap.c

You probably want sys_brk().

Quoted 2 lines

So the mystery is : who calls the brk() system call when I type "cat /proc/interrupts"

cat calls malloc(), glibc calls brk(), kernel does sys_brk()

Chris

Signature · 4 lines
Chris Friesen                    | MailStop: 043/33/F10
Nortel Networks                  | work: (613) 765-0557
3500 Carling Avenue              | fax:  (613) 765-2986
Nepean, ON K2H 8E9 Canada        | email: [email protected]