public inbox for libc-help@sourceware.org
 help / color / mirror / Atom feed
* Where could I find the definition of __vm_deallocate() called by __munmap()?
@ 2021-07-31 17:37 ur bridge
  2021-07-31 17:51 ` Florian Weimer
  0 siblings, 1 reply; 3+ messages in thread
From: ur bridge @ 2021-07-31 17:37 UTC (permalink / raw)
  To: libc-help

Hello,
I’m reading the malloc.c code, and find that when __munmap() is called to free a mmapped chunk, the control flow will fall into sysdeps/mach/munmap.c, where __vm_deallocate() will be called. However, I cannot find its definition. Where could it be?

(Actually, I expected that syscall munmap() would be called in Linux kernel. But there is no such a declaration in sysdeps/unix/sysv/linux/.)

Thanks





^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Where could I find the definition of __vm_deallocate() called by __munmap()?
  2021-07-31 17:37 Where could I find the definition of __vm_deallocate() called by __munmap()? ur bridge
@ 2021-07-31 17:51 ` Florian Weimer
  2021-08-01 13:05   ` ur bridge
  0 siblings, 1 reply; 3+ messages in thread
From: Florian Weimer @ 2021-07-31 17:51 UTC (permalink / raw)
  To: ur bridge via Libc-help

* ur bridge via Libc-help:

> I’m reading the malloc.c code, and find that when __munmap() is called
> to free a mmapped chunk, the control flow will fall into
> sysdeps/mach/munmap.c, where __vm_deallocate() will be
> called. However, I cannot find its definition. Where could it be?

This is Hurd code.  For Linux, __munmap is indeed a thin system call
wrapper.

Thanks,
Florian


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Where could I find the definition of __vm_deallocate() called by __munmap()?
  2021-07-31 17:51 ` Florian Weimer
@ 2021-08-01 13:05   ` ur bridge
  0 siblings, 0 replies; 3+ messages in thread
From: ur bridge @ 2021-08-01 13:05 UTC (permalink / raw)
  To: Florian Weimer,  libc-help@sourceware.org

Thank you, Florian,

I tried to locate __vm_deallocate()’s definition in glibc by grep, and found only a hidden_proto in sysdeps/mach/include/mach-shortcuts-hidden, with no actual implementation.

Is its code included in glibc? If not, how could glibc be built from the source?

Given that __mmap() will call the syscall mmap(), I can understand only if __munmap() is a thin wrapper for syscall munmap(), but it calls __vm_deallocate(). How does this mismatch work? How could Hurd’s code touch the necessary structures (e.g. vma, managed by Linux kernel) to handle the unmapping?


Re: Where could I find the definition of __vm_deallocate() called by __munmap()?

* ur bridge via Libc-help:

> I’m reading the malloc.c code, and find that when __munmap() is called
> to free a mmapped chunk, the control flow will fall into
> sysdeps/mach/munmap.c, where __vm_deallocate() will be
> called. However, I cannot find its definition. Where could it be?

This is Hurd code.  For Linux, __munmap is indeed a thin system call
wrapper.

Thanks,
Florian


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-08-01 13:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-31 17:37 Where could I find the definition of __vm_deallocate() called by __munmap()? ur bridge
2021-07-31 17:51 ` Florian Weimer
2021-08-01 13:05   ` ur bridge

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).