From: Arun Sharma <asharma@fb.com>
To: Balbir Singh <bsingharora@gmail.com>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>,
linux-mm@kvack.org, Davide Libenzi <davidel@xmailserver.org>,
Johannes Weiner <hannes@cmpxchg.org>
Subject: Re: MAP_UNINITIALIZED (Was Re: MAP_NOZERO revisited)
Date: Thu, 12 Jan 2012 10:16:21 -0800 [thread overview]
Message-ID: <4F0F2375.3060602@fb.com> (raw)
In-Reply-To: <CAKTCnz=Fg8DiTYUzmTiVm_bd-P9Ww9N5+T+LRGjoG2=ONL_MGA@mail.gmail.com>
On 1/11/12 9:10 PM, Balbir Singh wrote:
>
> Define MAP_UNINITIALIZED - are you referring to not zeroing out pages
> before handing them down? Is this safe even between threads.
>
If it doesn't work for an app, it shouldn't be asking for this behavior
via an mmap flag?
Only calloc() specifies that the returned memory will be zero'ed. There
is no such guarantee for malloc().
>> +#define VM_UNINITIALIZED VM_SAO /* Steal a powerpc bit for now, since we're out
>> + bits for 32 bit archs */
>
> Without proper checks if it can be re-used?
Yeah - this is a complete hack. I'm trying to convince people that this
is a viable idea, before asking for a vm_flags bit.
Microbenchmark data:
# time -p ./test2
real 7.60
user 0.78
sys 6.81
# time -p ./test2 xx
real 4.40
user 0.78
sys 3.62
# cat test2.c
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <sys/mman.h>
#include <stdint.h>
#define MMAP_SIZE (20 * 1024 * 1024)
#define PAGE_SIZE 4096
#define MAP_UNINITIALIZED 0x4000000
main(int argc, char *argv[])
{
void *addr, *naddr;
char *p, *end, val;
int flag = 0;
int i;
if (argc > 1) {
flag = MAP_UNINITIALIZED;
}
addr = mmap(NULL, MMAP_SIZE, PROT_READ|PROT_WRITE,
flag | MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
if (addr == MAP_FAILED) {
perror("mmap");
exit(-1);
}
end = (char *) addr + MMAP_SIZE;
for (i = 0; i < 1000; i++) {
int ret;
ret = madvise(addr, MMAP_SIZE, MADV_DONTNEED);
if (ret == -1)
perror("madvise");
for (p = (char *) addr; p < end; p += PAGE_SIZE) {
*p = 0xAB;
}
}
}
-Arun
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
prev parent reply other threads:[~2012-01-12 18:16 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-05 0:37 MAP_NOZERO revisited Arun Sharma
2012-01-05 7:23 ` KAMEZAWA Hiroyuki
2012-01-11 18:50 ` MAP_UNINITIALIZED (Was Re: MAP_NOZERO revisited) Arun Sharma
2012-01-12 5:10 ` Balbir Singh
2012-01-12 18:16 ` Arun Sharma [this message]
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=4F0F2375.3060602@fb.com \
--to=asharma@fb.com \
--cc=bsingharora@gmail.com \
--cc=davidel@xmailserver.org \
--cc=hannes@cmpxchg.org \
--cc=kamezawa.hiroyu@jp.fujitsu.com \
--cc=linux-mm@kvack.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.