From: Igor Mammedov <imammedo@redhat.com>
To: Hu Tao <hutao@cn.fujitsu.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
lersek@redhat.com, qemu-devel@nongnu.org,
Wanlong Gao <gaowanlong@cn.fujitsu.com>
Subject: Re: [Qemu-devel] [PATCH v18 13/14] memory backend: fill memory backend ram fields
Date: Wed, 26 Feb 2014 10:10:56 +0100 [thread overview]
Message-ID: <20140226101056.1a9ec3b3@nial.usersys.redhat.com> (raw)
In-Reply-To: <20140226055706.GA5090@G08FNSTD100614.fnst.cn.fujitsu.com>
On Wed, 26 Feb 2014 13:57:06 +0800
Hu Tao <hutao@cn.fujitsu.com> wrote:
> On Wed, Feb 19, 2014 at 10:36:57AM +0100, Igor Mammedov wrote:
> > On Wed, 19 Feb 2014 10:03:13 +0100
> > Paolo Bonzini <pbonzini@redhat.com> wrote:
> >
> > > 19/02/2014 08:54, Hu Tao ha scritto:
> > > > Thus makes user control how to allocate memory for ram backend.
> > > >
> > > > Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
> > > > ---
> > > > backends/hostmem-ram.c | 158 ++++++++++++++++++++++++++++++++++++++++++++++++
> > > > include/sysemu/sysemu.h | 2 +
> > > > 2 files changed, 160 insertions(+)
> > > >
> > > > diff --git a/backends/hostmem-ram.c b/backends/hostmem-ram.c
> > [...]
> >
> > > > static int
> > > > ram_backend_memory_init(HostMemoryBackend *backend, Error **errp)
> > > > {
> > > > + HostMemoryBackendRam *ram_backend = MEMORY_BACKEND_RAM(backend);
> > > > + int mode = ram_backend->policy;
> > > > + void *p;
> > > > + unsigned long maxnode;
> > > > +
> > > > if (!memory_region_size(&backend->mr)) {
> > > > memory_region_init_ram(&backend->mr, OBJECT(backend),
> > > > object_get_canonical_path(OBJECT(backend)),
> > > > backend->size);
> > > > +
> > > > + p = memory_region_get_ram_ptr(&backend->mr);
> > > > + maxnode = find_last_bit(ram_backend->host_nodes, MAX_NODES);
> > > > +
> > > > + mode |= ram_backend->relative ? MPOL_F_RELATIVE_NODES :
> > > > + MPOL_F_STATIC_NODES;
> > > > + /* This is a workaround for a long standing bug in Linux'
> > > > + * mbind implementation, which cuts off the last specified
> > > > + * node. To stay compatible should this bug be fixed, we
> > > > + * specify one more node and zero this one out.
> > > > + */
> > > > + if (syscall(SYS_mbind, p, backend->size, mode,
> > > > + ram_backend->host_nodes, maxnode + 2, 0)) {
> > >
> > > This does not compile on non-Linux; also, does libnuma include the
> > > workaround? If so, this is a hint that we should be using libnuma
> > > instead...
> > >
> > > Finally, all this code should be in hostmem.c, not hostmem-ram.c,
> > > because the same policies can be applied to hugepage-backed memory.
> > >
> > > Currently host_memory_backend_get_memory is calling bc->memory_init.
> > > Probably the call should be replaced by something like
> > I've pushed to github updated version of memdev, where
> > host_memory_backend_get_memory() is just convenience wrapper to get
> > access to memdev's internal MemoryRegion.
> >
> > All initialization now is done in user_creatable->complete() method
> > which calls ram_backend_memory_init() so leaving it as is should be fine.
>
> If lines about memory polices are moved up to hostmem.c, the only thing
> left in ram_backend_memory_init() is calling memory_region_init_ram() to
> allocate memory. Then it comes a problem that when to apply memory
> polices? Choices:
>
> 1. apply memory polices in hostmem.c since this is the place user sets
> memory polices. But user_creatable_complete() seems not to support
> this.( but fix me)
if we assume that NUMA policies apply to every hostmem derived backend,
then we could realize() approach used by DEVICE. i.e.
set NUMA policies in hostmem.c:hostmemory_backend_memory_init()
Add parent_complete field to ram-backend class and store there parent's
complete pointer. Then we can do:
ram_backend_memory_init(UserCreatable *uc, Error **errp) {
memory_region_init_ram();
...
MEMORY_BACKEND_RAM_CLASS(uc)->parent_complete(uc, errp);
...
}
>
> 2. cast to HostMemoryBackend in ram_backend_memory_init() (or in other
> memory backends) and add lines to apply memory polices.
>
> 3. provide an interface in HostMemoryBackendClass to do the thing and
> call it in subclasses. (this is basically the same as 2 except that
> we can reuse code)
>
> Opinions?
>
>
next prev parent reply other threads:[~2014-02-26 9:11 UTC|newest]
Thread overview: 53+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-19 7:53 [Qemu-devel] [PATCH v18 00/14] Add support for binding guest numa nodes to host numa nodes Hu Tao
2014-02-19 7:53 ` [Qemu-devel] [PATCH v18 01/14] NUMA: move numa related code to new file numa.c Hu Tao
2014-02-19 7:53 ` [Qemu-devel] [PATCH v18 02/14] NUMA: check if the total numa memory size is equal to ram_size Hu Tao
2014-02-25 13:38 ` Eric Blake
2014-02-19 7:53 ` [Qemu-devel] [PATCH v18 03/14] NUMA: Add numa_info structure to contain numa nodes info Hu Tao
2014-02-19 9:26 ` Igor Mammedov
2014-02-21 2:54 ` hu tao
2014-02-19 7:53 ` [Qemu-devel] [PATCH v18 04/14] NUMA: convert -numa option to use OptsVisitor Hu Tao
2014-02-19 7:53 ` [Qemu-devel] [PATCH v18 05/14] NUMA: expand MAX_NODES from 64 to 128 Hu Tao
2014-02-19 7:53 ` [Qemu-devel] [PATCH v18 06/14] qapi: add SIZE type parser to string_input_visitor Hu Tao
2014-02-19 9:54 ` Igor Mammedov
2014-02-19 7:53 ` [Qemu-devel] [PATCH v18 07/14] add memdev backend infrastructure Hu Tao
2014-02-19 9:15 ` Igor Mammedov
2014-02-19 7:53 ` [Qemu-devel] [PATCH v18 08/14] pc: pass QEMUMachineInitArgs to pc_memory_init Hu Tao
2014-02-19 7:54 ` [Qemu-devel] [PATCH v18 09/14] numa: introduce memory_region_allocate_system_memory Hu Tao
2014-02-19 7:54 ` [Qemu-devel] [PATCH v18 10/14] numa: add -numa node, memdev= option Hu Tao
2014-02-19 9:50 ` Igor Mammedov
2014-02-19 11:53 ` Paolo Bonzini
2014-03-04 0:10 ` Eric Blake
2014-03-04 2:20 ` Hu Tao
2014-02-19 7:54 ` [Qemu-devel] [PATCH v18 11/14] qapi: make string input visitor parse int list Hu Tao
2014-02-19 8:17 ` Hu Tao
2014-02-19 8:42 ` Paolo Bonzini
2014-02-19 7:54 ` [Qemu-devel] [PATCH v18 12/14] qapi: add HostMemPolicy enum type Hu Tao
2014-02-19 9:08 ` Paolo Bonzini
2014-02-19 11:23 ` Igor Mammedov
2014-02-19 7:54 ` [Qemu-devel] [PATCH v18 13/14] memory backend: fill memory backend ram fields Hu Tao
2014-02-19 9:03 ` Paolo Bonzini
2014-02-19 9:36 ` Igor Mammedov
2014-02-25 10:20 ` Hu Tao
2014-02-25 14:15 ` Paolo Bonzini
2014-02-26 5:00 ` Hu Tao
2014-02-26 8:47 ` Igor Mammedov
2014-02-26 8:59 ` Hu Tao
2014-02-26 12:19 ` Igor Mammedov
2014-02-26 11:22 ` Paolo Bonzini
2014-02-26 5:57 ` Hu Tao
2014-02-26 9:05 ` Paolo Bonzini
2014-02-26 9:10 ` Igor Mammedov [this message]
2014-02-26 10:33 ` Paolo Bonzini
2014-02-26 12:31 ` Igor Mammedov
2014-02-26 12:45 ` Paolo Bonzini
2014-02-26 12:58 ` Marcelo Tosatti
2014-02-26 13:14 ` Paolo Bonzini
2014-02-26 13:43 ` Igor Mammedov
2014-02-26 13:47 ` Paolo Bonzini
2014-02-26 14:25 ` Igor Mammedov
2014-02-26 14:39 ` Paolo Bonzini
2014-02-25 10:09 ` Hu Tao
2014-03-03 3:24 ` Hu Tao
2014-02-19 7:54 ` [Qemu-devel] [PATCH v18 14/14] amp: add query-memdev Hu Tao
2014-02-19 8:14 ` Hu Tao
2014-02-19 9:07 ` Paolo Bonzini
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=20140226101056.1a9ec3b3@nial.usersys.redhat.com \
--to=imammedo@redhat.com \
--cc=gaowanlong@cn.fujitsu.com \
--cc=hutao@cn.fujitsu.com \
--cc=lersek@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.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;
as well as URLs for NNTP newsgroup(s).