From: Bill Speirs <bill.speirs@gmail.com>
To: linux-kernel@vger.kernel.org
Subject: vma_merge issue
Date: Mon, 10 Aug 2009 16:47:02 -0400 [thread overview]
Message-ID: <a1b36c3a0908101347t796dedbat2ecb0535c32f325b@mail.gmail.com> (raw)
Hello-
I came across an issue where adjacent pages are not properly coalesced
together when changing protections on them. This can be shown by doing
the following:
1) Map 3 pages with PROT_NONE and MAP_PRIVATE | MAP_ANONYMOUS
2) Set the middle page's protection to PROT_READ | PROT_WRITE
3) Set the middle page's protection back to PROT_NONE
You are left with 3 entries in /proc/self/map where you should only
have 1. If you only change the protection to PROT_READ in step 2, then
it is properly merged together. I noticed in mprotect.c the following
comment in the function mprotect_fixup; I'm not sure if it applies or
not:
/*
* If we make a private mapping writable we increase our commit;
* but (without finer accounting) cannot reduce our commit if we
* make it unwritable again.
*
* FIXME? We haven't defined a VM_NORESERVE flag, so mprotecting
* a MAP_NORESERVE private mapping to writable will now reserve.
*/
I think this only applies to setting charged = nrpages; however,
VM_ACCOUNT is also added to newflags. Could it be that the adjacent
blocks don't have VM_ACCOUNT and so the call to vma_merge cannot merge
because the flags for the adjacent vma are not the same?
Can anyone shed some light on this? While it isn't an issue for 3
pages, I'm mmaping 200K+ pages and changing the perms on random pages
throughout and then back but I quickly run into the max_map_count when
I don't actually need that many mappings.
Thanks...
Bill-
next reply other threads:[~2009-08-10 20:47 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-10 20:47 Bill Speirs [this message]
2009-08-12 18:26 ` Hugh Dickins
2009-08-12 19:04 ` Bill Speirs
2009-08-12 20:23 ` Hugh Dickins
2009-08-12 20:53 ` Hugh Dickins
2009-08-13 1:15 ` William R Speirs
2009-08-13 17:33 ` Hugh Dickins
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=a1b36c3a0908101347t796dedbat2ecb0535c32f325b@mail.gmail.com \
--to=bill.speirs@gmail.com \
--cc=linux-kernel@vger.kernel.org \
/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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®