From owner-freebsd-hackers@FreeBSD.ORG Fri Oct 7 17:39:14 2011 Return-Path: Delivered-To: hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E1BA1106564A for ; Fri, 7 Oct 2011 17:39:12 +0000 (UTC) (envelope-from alan.l.cox@gmail.com) Received: from mail-vw0-f54.google.com (mail-vw0-f54.google.com [209.85.212.54]) by mx1.freebsd.org (Postfix) with ESMTP id 9E6168FC14 for ; Fri, 7 Oct 2011 17:39:12 +0000 (UTC) Received: by vws11 with SMTP id 11so4722191vws.13 for ; Fri, 07 Oct 2011 10:39:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:reply-to:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; bh=bTGYv7796STHE4ErRqgwoQr7DJFRZPigHCq/G4eNzKE=; b=GT62QPNMuFDqZKt8gY5lNk6x3OOB41NRm+hsxXu9VEnddnJw0z76Z/CYWaqmFND3nH RNaw0kDmcL7RsbHsIUMVSaInlhr/e3lzdbHFuS0jJlMGgAzPkhINYCD3yH/YfUD7HGWf wD2Emma2IQJl18NlGyEKTdvYml22d1BoKIQ+Y= MIME-Version: 1.0 Received: by 10.68.208.229 with SMTP id mh5mr15208962pbc.124.1318007611585; Fri, 07 Oct 2011 10:13:31 -0700 (PDT) Received: by 10.142.166.3 with HTTP; Fri, 7 Oct 2011 10:13:31 -0700 (PDT) In-Reply-To: <20111006160159.GQ1511@deviant.kiev.zoral.com.ua> References: <20111006160159.GQ1511@deviant.kiev.zoral.com.ua> Date: Fri, 7 Oct 2011 12:13:31 -0500 Message-ID: From: Alan Cox To: Kostik Belousov Content-Type: text/plain; charset=ISO-8859-1 X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: Wojciech Puchar , hackers@freebsd.org, Grzegorz Kulewski Subject: Re: mmap performance and memory use X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: alc@freebsd.org List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 07 Oct 2011 17:39:14 -0000 On Thu, Oct 6, 2011 at 11:01 AM, Kostik Belousov 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