From: Minchan Kim <minchan.kim@lge.com>
To: Paul Turner <pjt@google.com>
Cc: "linux-mm@kvack.org" <linux-mm@kvack.org>,
LKML <linux-kernel@vger.kernel.org>,
Michael Kerrisk <mtk.manpages@gmail.com>,
Arun Sharma <asharma@fb.com>,
John Stultz <john.stultz@linaro.org>, Mel Gorman <mel@csn.ul.ie>,
Hugh Dickins <hughd@google.com>,
Dave Hansen <dave@linux.vnet.ibm.com>,
Rik van Riel <riel@redhat.com>, Neil Brown <neilb@suse.de>,
Mike Hommey <mh@glandium.org>, Taras Glek <tglek@mozilla.com>,
KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>,
KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>,
Jason Evans <je@fb.com>, Sanjay Ghemawat <sanjay@google.com>,
Johannes Weiner <hannes@cmpxchg.org>,
Michel Lespinasse <walken@google.com>,
Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [RFC v7 00/11] Support vrange for anonymous page
Date: Wed, 13 Mar 2013 15:44:59 +0900 [thread overview]
Message-ID: <20130313064459.GC13815@blaptop> (raw)
In-Reply-To: <CAPM31RJ1tzd7yWQEgL0u-PjK7mV=wY57OPDJ76ijJAC2YnDuHw@mail.gmail.com>
On Tue, Mar 12, 2013 at 04:16:57PM -0700, Paul Turner wrote:
> On Tue, Mar 12, 2013 at 12:38 AM, Minchan Kim <minchan@kernel.org> wrote:
> > First of all, let's define the term.
> > From now on, I'd like to call it as vrange(a.k.a volatile range)
> > for anonymous page. If you have a better name in mind, please suggest.
> >
> > This version is still *RFC* because it's just quick prototype so
> > it doesn't support THP/HugeTLB/KSM and even couldn't build on !x86.
> > Before further sorting out issues, I'd like to post current direction
> > and discuss it. Of course, I'd like to extend this discussion in
> > comming LSF/MM.
> >
> > In this version, I changed lots of thing, expecially removed vma-based
> > approach because it needs write-side lock for mmap_sem, which will drop
> > performance in mutli-threaded big SMP system, KOSAKI pointed out.
> > And vma-based approach is hard to meet requirement of new system call by
> > John Stultz's suggested semantic for consistent purged handling.
> > (http://linux-kernel.2935.n7.nabble.com/RFC-v5-0-8-Support-volatile-for-anonymous-range-tt575773.html#none)
> >
> > I tested this patchset with modified jemalloc allocator which was
> > leaded by Jason Evans(jemalloc author) who was interest in this feature
> > and was happy to port his allocator to use new system call.
> > Super Thanks Jason!
> >
> > The benchmark for test is ebizzy. It have been used for testing the
> > allocator performance so it's good for me. Again, thanks for recommending
> > the benchmark, Jason.
> > (http://people.freebsd.org/~kris/scaling/ebizzy.html)
> >
> > The result is good on my machine (12 CPU, 1.2GHz, DRAM 2G)
> >
> > ebizzy -S 20
> >
> > jemalloc-vanilla: 52389 records/sec
> > jemalloc-vrange: 203414 records/sec
> >
> > ebizzy -S 20 with background memory pressure
> >
> > jemalloc-vanilla: 40746 records/sec
> > jemalloc-vrange: 174910 records/sec
> >
> > And it's much improved on KVM virtual machine.
> >
> > This patchset is based on v3.9-rc2
> >
> > - What's the sys_vrange(addr, length, mode, behavior)?
> >
> > It's a hint that user deliver to kernel so kernel can *discard*
> > pages in a range anytime. mode is one of VRANGE_VOLATILE and
> > VRANGE_NOVOLATILE. VRANGE_NOVOLATILE is memory pin operation so
> > kernel coudn't discard any pages any more while VRANGE_VOLATILE
> > is memory unpin opeartion so kernel can discard pages in vrange
> > anytime. At a moment, behavior is one of VRANGE_FULL and VRANGE
> > PARTIAL. VRANGE_FULL tell kernel that once kernel decide to
> > discard page in a vrange, please, discard all of pages in a
> > vrange selected by victim vrange. VRANGE_PARTIAL tell kernel
> > that please discard of some pages in a vrange. But now I didn't
> > implemented VRANGE_PARTIAL handling yet.
> >
> > - What happens if user access page(ie, virtual address) discarded
> > by kernel?
> >
> > The user can encounter SIGBUS.
> >
> > - What should user do for avoding SIGBUS?
> > He should call vrange(addr, length, VRANGE_NOVOLATILE, mode) before
> > accessing the range which was called
> > vrange(addr, length, VRANGE_VOLATILE, mode)
> >
> > - What happens if user access page(ie, virtual address) doesn't
> > discarded by kernel?
> >
> > The user can see vaild data which was there before calling
> > vrange(., VRANGE_VOLATILE) without page fault.
> >
> > - What's different with madvise(DONTNEED)?
> >
> > System call semantic
> >
> > DONTNEED makes sure user always can see zero-fill pages after
> > he calls madvise while vrange can see data or encounter SIGBUS.
> >
> > Internal implementation
> >
> > The madvise(DONTNEED) should zap all mapped pages in range so
> > overhead is increased linearly with the number of mapped pages.
> > Even, if user access zapped pages as write mode, page fault +
> > page allocation + memset should be happened.
> >
> > The vrange just register a address range instead of zapping all of pte
> > n the vma so it doesn't touch ptes any more.
> >
> > - What's the benefit compared to DONTNEED?
> >
> > 1. The system call overhead is smaller because vrange just registers
> > a range using interval tree instead of zapping all the page in a range
> > so overhead should be really cheap.
> >
> > 2. It has a chance to eliminate overheads (ex, zapping pte + page fault
> > + page allocation + memset(PAGE_SIZE)) if memory pressure isn't
> > severe.
> >
> > 3. It has a potential to zap all ptes and free the pages if memory
> > pressure is severe so discard scanning overhead could be smaller - TODO
> >
> > - What's for targetting?
> >
> > Firstly, user-space allocator like ptmalloc, jemalloc or heap management
> > of virtual machine like Dalvik. Also, it comes in handy for embedded
> > which doesn't have swap device so they can't reclaim anonymous pages.
> > By discarding instead of swapout, it could be used in the non-swap system.
>
> I think that another potentially useful use-case would be using this
> -- or a similar API -- to opportunistically return deep user stack
> frames.
>
> This is another place where we strongly care about the time-to-free as
> well as the time-to-reallocate in the case of relatively immediate
> re-use.
Indeed. Great idea!
Thanks, Paul.
--
Kind regards,
Minchan Kim
--
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/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2013-03-13 6:45 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-12 7:38 [RFC v7 00/11] Support vrange for anonymous page Minchan Kim
2013-03-12 7:38 ` [RFC v7 01/11] vrange: enable generic interval tree Minchan Kim
2013-03-12 7:38 ` [RFC v7 02/11] add vrange basic data structure and functions Minchan Kim
2013-03-12 7:38 ` [RFC v7 03/11] add new system call vrange(2) Minchan Kim
2013-03-12 7:38 ` [RFC v7 04/11] add proc/pid/vrange information Minchan Kim
2013-03-12 7:38 ` [RFC v7 05/11] Add purge operation Minchan Kim
2013-03-12 7:38 ` [RFC v7 06/11] send SIGBUS when user try to access purged page Minchan Kim
2013-03-12 7:38 ` [RFC v7 07/11] keep mm_struct to vrange when system call context Minchan Kim
2013-03-12 7:38 ` [RFC v7 08/11] add LRU handling for victim vrange Minchan Kim
2013-03-12 7:38 ` [RFC v7 09/11] Get rid of depenceny that all pages is from a zone in shrink_page_list Minchan Kim
2013-03-12 7:38 ` [RFC v7 10/11] Purging vrange pages without swap Minchan Kim
2013-03-12 7:38 ` [RFC v7 11/11] add purged page information in vmstat Minchan Kim
2013-03-12 23:16 ` [RFC v7 00/11] Support vrange for anonymous page Paul Turner
2013-03-13 6:44 ` Minchan Kim [this message]
2013-03-21 1:29 ` John Stultz
2013-03-22 6:01 ` Minchan Kim
2013-03-22 17:06 ` John Stultz
2013-03-25 8:42 ` Minchan Kim
2013-03-27 0:26 ` John Stultz
2013-03-27 8:03 ` Minchan Kim
2013-03-30 0:05 ` John Stultz
2013-04-01 7:57 ` Minchan Kim
2013-03-25 17:16 ` Bartlomiej Zolnierkiewicz
2013-03-27 7:18 ` Minchan Kim
2013-04-10 20:22 ` KOSAKI Motohiro
2013-04-11 6:55 ` Minchan Kim
2013-04-11 7:20 ` KOSAKI Motohiro
2013-04-11 8:02 ` Minchan Kim
2013-04-11 8:15 ` KOSAKI Motohiro
2013-04-11 8:31 ` Minchan Kim
2013-04-11 15:01 ` KOSAKI Motohiro
2013-04-14 7:42 ` Minchan Kim
2013-04-16 3:33 ` John Stultz
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=20130313064459.GC13815@blaptop \
--to=minchan.kim@lge.com \
--cc=akpm@linux-foundation.org \
--cc=asharma@fb.com \
--cc=dave@linux.vnet.ibm.com \
--cc=hannes@cmpxchg.org \
--cc=hughd@google.com \
--cc=je@fb.com \
--cc=john.stultz@linaro.org \
--cc=kamezawa.hiroyu@jp.fujitsu.com \
--cc=kosaki.motohiro@jp.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mel@csn.ul.ie \
--cc=mh@glandium.org \
--cc=mtk.manpages@gmail.com \
--cc=neilb@suse.de \
--cc=pjt@google.com \
--cc=riel@redhat.com \
--cc=sanjay@google.com \
--cc=tglek@mozilla.com \
--cc=walken@google.com \
/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;
as well as URLs for NNTP newsgroup(s).