linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Balbir Singh <bsingharora@gmail.com>
To: Arun Sharma <asharma@fb.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:40:20 +0530	[thread overview]
Message-ID: <CAKTCnz=Fg8DiTYUzmTiVm_bd-P9Ww9N5+T+LRGjoG2=ONL_MGA@mail.gmail.com> (raw)
In-Reply-To: <20120111185009.GA26693@dev3310.snc6.facebook.com>

> commit 37b83f3fb77a177a2f81ebb8aeaec28c2a46e503
> Author: Arun Sharma <asharma@fb.com>
> Date:   Tue Jan 10 17:02:46 2012 -0800
>
>    mm: Enable MAP_UNINITIALIZED for archs with mmu
>
>    This enables malloc optimizations where we might
>    madvise(..,MADV_DONTNEED) a page only to fault it
>    back at a different virtual address.
>
>    Signed-off-by: Arun Sharma <asharma@fb.com>
>
> diff --git a/include/asm-generic/mman-common.h b/include/asm-generic/mman-common.h
> index 787abbb..71e079f 100644
> --- a/include/asm-generic/mman-common.h
> +++ b/include/asm-generic/mman-common.h
> @@ -19,11 +19,7 @@
>  #define MAP_TYPE       0x0f            /* Mask for type of mapping */
>  #define MAP_FIXED      0x10            /* Interpret addr exactly */
>  #define MAP_ANONYMOUS  0x20            /* don't use a file */
> -#ifdef CONFIG_MMAP_ALLOW_UNINITIALIZED
> -# define MAP_UNINITIALIZED 0x4000000   /* For anonymous mmap, memory could be uninitialized */
> -#else
> -# define MAP_UNINITIALIZED 0x0         /* Don't support this flag */
> -#endif
> +#define MAP_UNINITIALIZED 0x4000000    /* For anonymous mmap, memory could be uninitialized */
>

Define MAP_UNINITIALIZED - are you referring to not zeroing out pages
before handing them down? Is this safe even between threads.

>  #define MS_ASYNC       1               /* sync memory asynchronously */
>  #define MS_INVALIDATE  2               /* invalidate the caches */
> diff --git a/include/linux/highmem.h b/include/linux/highmem.h
> index 3a93f73..04d838e 100644
> --- a/include/linux/highmem.h
> +++ b/include/linux/highmem.h
> @@ -156,6 +156,11 @@ __alloc_zeroed_user_highpage(gfp_t movableflags,
>        struct page *page = alloc_page_vma(GFP_HIGHUSER | movableflags,
>                        vma, vaddr);
>
> +#ifdef CONFIG_MMAP_ALLOW_UNINITIALIZED
> +       if (!vma->vm_file && vma->vm_flags & VM_UNINITIALIZED)
> +               return page;
> +#endif
> +
>        if (page)
>                clear_user_highpage(page, vaddr);
>
> diff --git a/include/linux/mm.h b/include/linux/mm.h
> index 4baadd1..6345c57 100644
> --- a/include/linux/mm.h
> +++ b/include/linux/mm.h
> @@ -118,6 +118,8 @@ extern unsigned int kobjsize(const void *objp);
>  #define VM_SAO         0x20000000      /* Strong Access Ordering (powerpc) */
>  #define VM_PFN_AT_MMAP 0x40000000      /* PFNMAP vma that is fully mapped at mmap time */
>  #define VM_MERGEABLE   0x80000000      /* KSM may merge identical pages */
> +#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?

>
>  /* Bits set in the VMA until the stack is in its final location */
>  #define VM_STACK_INCOMPLETE_SETUP      (VM_RAND_READ | VM_SEQ_READ)
> diff --git a/include/linux/mman.h b/include/linux/mman.h
> index 51647b4..f7d4f60 100644
> --- a/include/linux/mman.h
> +++ b/include/linux/mman.h
> @@ -88,6 +88,7 @@ calc_vm_flag_bits(unsigned long flags)
>        return _calc_vm_trans(flags, MAP_GROWSDOWN,  VM_GROWSDOWN ) |
>               _calc_vm_trans(flags, MAP_DENYWRITE,  VM_DENYWRITE ) |
>               _calc_vm_trans(flags, MAP_EXECUTABLE, VM_EXECUTABLE) |
> +              _calc_vm_trans(flags, MAP_UNINITIALIZED, VM_UNINITIALIZED) |
>               _calc_vm_trans(flags, MAP_LOCKED,     VM_LOCKED    );
>  }
>  #endif /* __KERNEL__ */
> diff --git a/init/Kconfig b/init/Kconfig
> index 43298f9..428e047 100644
> --- a/init/Kconfig
> +++ b/init/Kconfig
> @@ -1259,7 +1259,7 @@ endchoice
>
>  config MMAP_ALLOW_UNINITIALIZED
>        bool "Allow mmapped anonymous memory to be uninitialized"
> -       depends on EXPERT && !MMU
> +       depends on EXPERT
>        default n
>        help
>          Normally, and according to the Linux spec, anonymous memory obtained
> diff --git a/mm/mempolicy.c b/mm/mempolicy.c
> index c3fdbcb..e6dd642 100644
> --- a/mm/mempolicy.c
> +++ b/mm/mempolicy.c
> @@ -1868,6 +1868,12 @@ alloc_pages_vma(gfp_t gfp, int order, struct vm_area_struct *vma,
>                put_mems_allowed();
>                return page;
>        }
> +
> +#ifdef CONFIG_MMAP_ALLOW_UNINITIALIZED
> +       if (!vma->vm_file && vma->vm_flags & VM_UNINITIALIZED)
> +               gfp &= ~__GFP_ZERO;
> +#endif
> +
>        /*
>         * fast path:  default or task policy
>         */

Balbir

--
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>

  reply	other threads:[~2012-01-12  5:10 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 [this message]
2012-01-12 18:16       ` Arun Sharma

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='CAKTCnz=Fg8DiTYUzmTiVm_bd-P9Ww9N5+T+LRGjoG2=ONL_MGA@mail.gmail.com' \
    --to=bsingharora@gmail.com \
    --cc=asharma@fb.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox