From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44021) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WiPgA-0004Yu-TH for qemu-devel@nongnu.org; Thu, 08 May 2014 10:52:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WiPg1-00019A-Qa for qemu-devel@nongnu.org; Thu, 08 May 2014 10:52:10 -0400 Received: from mail-ee0-x232.google.com ([2a00:1450:4013:c00::232]:61756) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WiPg1-00018y-Iu for qemu-devel@nongnu.org; Thu, 08 May 2014 10:52:01 -0400 Received: by mail-ee0-f50.google.com with SMTP id e51so1801902eek.23 for ; Thu, 08 May 2014 07:52:00 -0700 (PDT) Sender: Paolo Bonzini Message-ID: <536B9A0C.6040103@redhat.com> Date: Thu, 08 May 2014 16:51:56 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v3.1 00/31] NUMA series, and hostmem improvements List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Hu Tao , qemu-devel@nongnu.org Cc: Igor Mammedov Il 06/05/2014 11:27, Hu Tao ha scritto: > This series includes work on QOMifying the memory backends. > the idea is to delegate all properties of the memory backend to > a new QOM class hierarchy, in which the concrete classes > are hostmem-ram and hostmem-file. The backend is passed to the > machine via "-numa node,memdev=foo" where "foo" is the id of the > backend object. Hello, I noticed now that if you have the host-nodes property set Linux requires you to set a policy other than "default" too. If you don't, the mbind system call fails. What about squashing something like this? Paolo diff --git a/backends/hostmem.c b/backends/hostmem.c index d3f8476..a0a3111 100644 --- a/backends/hostmem.c +++ b/backends/hostmem.c @@ -299,12 +299,23 @@ host_memory_backend_memory_init(UserCreatable *uc, Error **errp) #ifdef CONFIG_NUMA unsigned long maxnode = find_last_bit(backend->host_nodes, MAX_NODES); + unsigned policy = backend->policy; + + /* Linux does not accept MPOL_DEFAULT with nonzero bitmap, but + * "-object memory-ram,size=128M,hostnodes=0,policy=bind" is a + * bit of a mouthful. So if the host_nodes bitmap is nonzero, + * pick the BIND policy. + */ + if (find_first_bit(backend->host_nodes, MAX_NODES) != MAX_NODES && + policy == MPOL_DEFAULT) { + policy = MPOL_BIND; + } /* This is a workaround for a long standing bug in Linux' * mbind implementation, which cuts off the last specified * node. */ - if (mbind(ptr, sz, backend->policy, backend->host_nodes, maxnode + 2, 0)) { + if (mbind(ptr, sz, policy, backend->host_nodes, maxnode + 2, 0)) { error_setg_errno(errp, errno, "cannot bind memory to host NUMA nodes");