All of lore.kernel.org
 help / color / mirror / Atom feed
From: Igor Mammedov <imammedo@redhat.com>
To: Marcelo Tosatti <mtosatti@redhat.com>
Cc: aarcange@redhat.com, peter.maydell@linaro.org, gleb@redhat.com,
	quintela@redhat.com, jan.kiszka@siemens.com,
	qemu-devel@nongnu.org, aliguori@amazon.com, pbonzini@redhat.com,
	afaerber@suse.de, rth@twiddle.net
Subject: Re: [Qemu-devel] [RFC PATCH] pc: align gpa<->hpa on 1GB boundary by splitting RAM on several regions
Date: Wed, 30 Oct 2013 20:56:17 +0100	[thread overview]
Message-ID: <20131030205617.585b9cb9@thinkpad> (raw)
In-Reply-To: <20131030185129.GB18378@amt.cnet>

On Wed, 30 Oct 2013 16:51:29 -0200
Marcelo Tosatti <mtosatti@redhat.com> wrote:

> On Wed, Oct 30, 2013 at 05:49:49PM +0100, Igor Mammedov wrote:
> > On Tue, 29 Oct 2013 19:38:44 -0200
> > Marcelo Tosatti <mtosatti@redhat.com> wrote:
> > 
> > > On Tue, Oct 29, 2013 at 07:18:49PM +0100, Igor Mammedov wrote:
> > > > Otherwise 1GB TLBs cannot be cached for the range.
> > > 
> > > This fails to back non-1GB-aligned gpas, but 2MB aligned, with 2MB large
> > > pages.
> > With current command line only one hugetlbfs mount point is possible, so it
> > will back with whatever alignment specified hugetlbfs mount point has.
> > Anything that doesn't fit into page aligned region goes to tail using
> > non hugepage baked phys_mem_set_alloc()=qemu_anon_ram_alloc() allocator.
> 
> The patch you propose allocates the non-1GB aligned tail of RAM with 4k
> pages. As mentioned, this is not acceptable (2MB pages should be used
> whenever 1GB alignment is not possible).
> 
> I believe its easier for the user to allocate enough 1GB pages to back
> all of guest RAM, since allocation is static, than for him to allocate
> mixed 1GB/2MB pages in hugetlbfs.
tail, if it's present at all, is always less than 1Gb.
why tail allocated with 4K pages is not acceptable?

btw: now if QEMU can't allocate hugepages for whole guest size it will fallback
to 4k pages anyway for whole guest size, with warning that isn't visible if
user doesn't start QEMU manually.

> 
> > > Since hugetlbfs allocation is static, it requires the user to inform
> > > different 1GB and 2MB sized hugetlbfs mount points (with proper number
> > > of corresponding hugetlbfs pages allocated). This is incompatible with
> > > the current command line, and i'd like to see this problem handled in a
> > > way that is command line backwards compatible.
> > patch doesn't change that, it uses provided hugetlbfs and fallbacks (hunk 2)
> > to phys_mem_alloc if requested memory region is not hugepage size aligned.
> > So there is no any CLI change, only fixing memory leak.
> > 
> > > Also, if the argument for one-to-one mapping between dimms and linear host
> > > virtual address sections holds, it means virtual DIMMs must be
> > > partitioned into whatever hugepage alignment is necessary (and in
> > > that case, why they can't be partitioned similarly with the memory
> > > region aliases?).
> > Because during hotplug a new memory region of desired size is allocated
> > and it could be mapped directly without any aliasing. And if some day we
> > convert adhoc initial memory allocation to dimm devices there is no reason to
> > alloc one huge block and then invent means how to alias hole somewhere else,
> > we could just reuse memdev/dimm and allocate several memory regions
> > with desired properties each represented by a memdev/dimm pair.
> > 
> > one-one mapping simplifies design and interface with ACPI part during memory
> > hotplug.
> > 
> > for hotplug case flow could look like:
> >  memdev_add id=x1,size=1Gb,mem-path=/hugetlbfs/1gb,other-host-related-stuff-options
> >  #memdev could enforce size to be backend aligned
> >  device_add dimm,id=y1,backend=x1,addr=xxxxxx
> >  #dimm could get alignment from associated memdev or fail if addr
> >  #doesn't meet alignment of memdev backend
> > 
> >  memdev_add id=x2,size=2mb,mem-path=/hugetlbfs/2mb
> >  device_add dimm,id=y2,backend=x2,addr=yyyyyyy
> > 
> >  memdev_add id=x3,size=1mb
> >  device_add dimm,id=y3,backend=x3,addr=xxxxxxx
> > 
> > linear memory block is allocated at runtime (user has to make sure that enough
> > hugepages are available) by each memdev_add command and that RAM memory region
> > is mapped into GPA by virtual DIMM as is, there wouldn't be any need for
> > aliasing.
> > 
> > Now back to intial memory and bright future we are looking forward to (i.e.
> > ability to create machine from configuration file without adhoc codding
> > like(pc_memory_init)):
> > 
> > legacy cmdline "-m 4512 -mem-path /hugetlbfs/1gb" could be automatically
> > translated into:
> > 
> > -memdev id=x1,size=3g,mem-path=/hugetlbfs/1gb -device dimm,backend=x1,addr=0
> > -memdev id=x2,size=1g,mem-path=/hugetlbfs/1gb -device dimm,backend=x2,addr=4g
> > -memdev id=x3,size=512m -device dimm,backend=x3,addr=5g
> > 
> > or user could drop legacy CLI and assume fine grained control over memory
> > configuration:
> > 
> > -memdev id=x1,size=3g,mem-path=/hugetlbfs/1gb -device dimm,backend=x1,addr=0
> > -memdev id=x2,size=1g,mem-path=/hugetlbfs/1gb -device dimm,backend=x2,addr=4g
> > -memdev id=x3,size=512m,mem-path=/hugetlbfs/2mb -device dimm,backend=x3,addr=5g
> > 
> > So if we are going to break migration compatibility for new machine type
> > lets do a way that could painlessly changed to memdev/device in future.
> 
> Ok then please improve your proposal to allow for multiple hugetlbfs
> mount points.
> 
> > > > PS:
> > > > as side effect we are not wasting ~1Gb of memory if
> > > > 1Gb hugepages are used and -m "hpagesize(in Mb)*n + 1"
> > > 
> > > This is how hugetlbfs works. You waste 1GB hugepage if an extra
> > > byte is requested.
> > it looks more a bug than feature,
> > why do it if leak could be avoided as shown below?
> 
> Because IMO it is confusing for the user, since hugetlbfs allocation is
> static. But if you have a necessity for the one-to-one relationship, 
> feel free to support mixed hugetlbfs page sizes.
> 
> 


-- 
Regards,
  Igor

  parent reply	other threads:[~2013-10-30 19:57 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-24 21:11 [Qemu-devel] [patch 0/2] align >4GB guest RAM to a 1GB boundary, in case of 1GB-sized hugetlbfs Marcelo Tosatti
2013-10-24 21:11 ` [Qemu-devel] [patch 1/2] exec: add qemu_get_ram_hpagesize Marcelo Tosatti
2013-10-24 21:12 ` [Qemu-devel] [patch 2/2] i386: pc: align gpa<->hpa on 1GB boundary Marcelo Tosatti
2013-10-24 21:55   ` Peter Maydell
2013-10-24 22:48     ` Marcelo Tosatti
2013-10-24 23:55   ` Paolo Bonzini
2013-10-25  4:58     ` Marcelo Tosatti
2013-10-25  8:52       ` Paolo Bonzini
2013-10-25 19:50         ` Marcelo Tosatti
2013-10-25 22:53           ` Paolo Bonzini
2013-10-30 11:07             ` Gerd Hoffmann
2013-10-30 11:47               ` Paolo Bonzini
2013-10-25  9:57       ` igor Mammedov
2013-10-25 13:34         ` Marcelo Tosatti
2013-10-27 15:20           ` igor Mammedov
2013-10-28 14:04             ` Marcelo Tosatti
2013-10-28 14:20               ` Marcelo Tosatti
2013-10-29 18:00               ` Igor Mammedov
2013-10-29 21:21                 ` Marcelo Tosatti
2013-10-30  8:48                   ` Gleb Natapov
2013-10-30 18:30                     ` Marcelo Tosatti
2013-10-29 18:18               ` [Qemu-devel] [RFC PATCH] pc: align gpa<->hpa on 1GB boundary by splitting RAM on several regions Igor Mammedov
2013-10-29 21:38                 ` Marcelo Tosatti
2013-10-30 16:49                   ` Igor Mammedov
2013-10-30 18:51                     ` Marcelo Tosatti
2013-10-30 19:03                       ` Marcelo Tosatti
2013-10-30 19:56                       ` Igor Mammedov [this message]
2013-10-30 23:44                         ` Marcelo Tosatti
2013-11-07 15:25                           ` Igor Mammedov
2013-10-30 19:31                     ` Marcelo Tosatti
2013-10-30 20:28                       ` Paolo Bonzini
2013-11-06  1:49   ` [Qemu-devel] i386: pc: align gpa<->hpa on 1GB boundary (v2) Marcelo Tosatti
2013-11-06  1:55     ` [Qemu-devel] i386: pc: align gpa<->hpa on 1GB boundary (v3) Marcelo Tosatti
2013-11-06 11:59       ` Igor Mammedov
2013-11-06 12:07         ` Paolo Bonzini
2013-11-06 12:22           ` Igor Mammedov
2013-11-06 12:24             ` Paolo Bonzini
2013-11-06 21:31       ` [Qemu-devel] i386: pc: align gpa<->hpa on 1GB boundary (v4) Marcelo Tosatti
2013-11-06 21:40         ` Michael S. Tsirkin
2013-11-06 21:53           ` Marcelo Tosatti
2013-11-06 22:15             ` Michael S. Tsirkin
2013-11-06 22:24               ` Marcelo Tosatti
2013-11-07 15:24         ` Igor Mammedov
2013-11-07 21:53           ` Marcelo Tosatti
2013-11-10 20:47             ` [Qemu-devel] i386: pc: align gpa<->hpa on 1GB boundary (v5) Marcelo Tosatti
2013-11-12 12:45               ` Igor Mammedov
2013-11-12 20:32                 ` Marcelo Tosatti
2013-11-12 21:16               ` [Qemu-devel] i386: pc: align gpa<->hpa on 1GB boundary (v6) Marcelo Tosatti
2013-11-13 13:59                 ` Igor Mammedov
2013-11-13 17:13                 ` Paolo Bonzini
     [not found]                   ` <20131113195832.GA29433@amt.cnet>
2013-11-13 20:39                     ` Marcelo Tosatti
2013-11-13 21:49                       ` Paolo Bonzini
2013-11-13 19:08                 ` Michael S. Tsirkin

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=20131030205617.585b9cb9@thinkpad \
    --to=imammedo@redhat.com \
    --cc=aarcange@redhat.com \
    --cc=afaerber@suse.de \
    --cc=aliguori@amazon.com \
    --cc=gleb@redhat.com \
    --cc=jan.kiszka@siemens.com \
    --cc=mtosatti@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    --cc=rth@twiddle.net \
    /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.