Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 7 Oct 2011 12:13:31 -0500
From:      Alan Cox <alan.l.cox@gmail.com>
To:        Kostik Belousov <kostikbel@gmail.com>
Cc:        Wojciech Puchar <wojtek@wojtek.tensor.gdynia.pl>, hackers@freebsd.org, Grzegorz Kulewski <grzegorz@kulewski.pl>
Subject:   Re: mmap performance and memory use
Message-ID:  <CAJUyCcMKZ1E5LoJ0BFZju_OH_jjDeqgvBMf8WZ%2BwDvJRFsbH6Q@mail.gmail.com>
In-Reply-To: <20111006160159.GQ1511@deviant.kiev.zoral.com.ua>
References:  <alpine.BSF.2.00.1110061637270.15552@wojtek.tensor.gdynia.pl> <20111006160159.GQ1511@deviant.kiev.zoral.com.ua>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, Oct 6, 2011 at 11:01 AM, Kostik Belousov <kostikbel@gmail.com>wrote:

> On Thu, Oct 06, 2011 at 04:41:45PM +0200, Wojciech Puchar wrote:
> > i have few questions.
> >
> > 1) suppose i map 1TB of address space as anonymous and touch just one
> > page. how much memory is used to manage this?
> I am not sure how deep the enumeration you want to know, but the first
> approximation will be:
> one struct vm_map_entry
> one struct vm_object
> one pv_entry
>
> Page table structures need four pages for directories and page table
> proper.
> >
> > 2) suppose we have 1TB file on disk without holes and 100000 processes
> > mmaps this file to it's address space. are just pages shared or can
> > pagetables be shared too? how much memory is used to manage such
> > situation?
> Only pages are shared. Pagetables are not.
>
> For one thing, this indeed causes more memory use for the OS. This is
> somewhat mitigated by automatic use of superpages. Superpage promotion
> still keeps the 4KB page table around, so most savings from the
> superpages are due to more efficient use of TLB.
>
>
You are correct about the page table page.  However, a superpage mapping
consumes a single PV entry, in place of 512 or 1024 PV entries.  This winds
up saving about three physical pages worth of memory for every superpage
mapping.

Alan



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAJUyCcMKZ1E5LoJ0BFZju_OH_jjDeqgvBMf8WZ%2BwDvJRFsbH6Q>