LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: "Török Edwin" <edwintorok@gmail.com>
To: Hugh Dickins <hugh@veritas.com>
Cc: Linux Kernel <linux-kernel@vger.kernel.org>
Subject: Re: /proc/pid/maps containg anonymous maps that have PROT_NONE
Date: Wed, 05 Nov 2008 20:47:44 +0200 [thread overview]
Message-ID: <4911EA50.30905@gmail.com> (raw)
In-Reply-To: <4911DE36.6050706@gmail.com>
On 2008-11-05 19:56, Török Edwin wrote:
> On 2008-11-05 18:12, Hugh Dickins wrote:
>
>>>
>>>
>> mmap PROT_NONE to reserve an arena, munmap to trim off top and bottom,
>> mprotect to make areas read+writable, madvise 0x4 to say MADV_DONTNEED
>> on some parts. gcc? Or the application itself (clamd) and its libs?
>>
>>
>>
>
>> Why does it mmap too much then trim it down? Perhaps it's trying to
>> minimize pagetable usage, perhaps it's internally convenient to base
>> on rounded addresses, I don't know.
>>
>> But the mmap is there: just easily overlooked because of the way it
>> munmaps too (with strace showing hex addresses but decimal sizes).
>>
>
> I will get some stacktraces and figure out, know that I know which mmap
> to look for (the one with MAP_NORESERVE).
>
I found it, glibc: arena.c:669 does it, there's a comment explaining why:
/* If consecutive mmap (0, HEAP_MAX_SIZE << 1, ...) calls return decreasing
addresses as opposed to increasing, new_heap would badly fragment the
address space. In that case remember the second HEAP_MAX_SIZE part
aligned to HEAP_MAX_SIZE from last mmap (0, HEAP_MAX_SIZE << 1, ...)
call (if it is already aligned) and try to reuse it next time. We need
no locking for it, as kernel ensures the atomicity for us - worst case
we'll call mmap (addr, HEAP_MAX_SIZE, ...) for some value of addr in
multiple threads, but only one will succeed. */
Anyway it is MAP_NORESERVE, and PROT_NONE so it doesn't waste physical
or swap memory.
Best regards,
--Edwin
next prev parent reply other threads:[~2008-11-05 18:48 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-05 11:14 Török Edwin
2008-11-05 16:12 ` Hugh Dickins
2008-11-05 17:56 ` Török Edwin
2008-11-05 18:47 ` Török Edwin [this message]
2008-11-06 1:15 ` KOSAKI Motohiro
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4911EA50.30905@gmail.com \
--to=edwintorok@gmail.com \
--cc=hugh@veritas.com \
--cc=linux-kernel@vger.kernel.org \
--subject='Re: /proc/pid/maps containg anonymous maps that have PROT_NONE' \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
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 NNTP newsgroup(s).