From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52082) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WLTsM-0004ts-Fm for qemu-devel@nongnu.org; Thu, 06 Mar 2014 03:42:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WLTsB-0003v4-Ef for qemu-devel@nongnu.org; Thu, 06 Mar 2014 03:41:58 -0500 Received: from mail-ee0-x235.google.com ([2a00:1450:4013:c00::235]:36612) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WLTsB-0003uu-7h for qemu-devel@nongnu.org; Thu, 06 Mar 2014 03:41:47 -0500 Received: by mail-ee0-f53.google.com with SMTP id e51so954707eek.40 for ; Thu, 06 Mar 2014 00:41:46 -0800 (PST) Sender: Paolo Bonzini Message-ID: <531834C4.3070609@redhat.com> Date: Thu, 06 Mar 2014 09:41:40 +0100 From: Paolo Bonzini MIME-Version: 1.0 References: <5316E6C3.3030502@redhat.com> In-Reply-To: Content-Type: text/plain; charset=GB2312 Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [RFC] support memory reserved feature and optimize mlock guest memory propose List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Zhanghailiang Cc: "edgar.iglesias@xilinx.com" , "kwolf@redhat.com" , "quintela@redhat.com" , "libvir-list@redhat.com" , Stefan Hajnoczi , "qemu-devel@nongnu.org" , "Huangpeng (Peter)" , Huangzhichao , Huazhiqiang Il 06/03/2014 09:06, Zhanghailiang ha scritto: > >> Il 05/03/2014 09:01, Zhanghailiang ha scritto: >>> Hi all£º >>> >>> Currently, we use cgroup(memory) to support memory QoS on KVM >>> platform, and use "mlock" on qemu to support "memory reserved". >>> >>> The "mlock" seems to be not appropriate. >>> >>> Now qemu "mlock" memory in the main thread, which would lock iothread >>> (qemu_mutex_lock_iothread), if the memory size is large, that will >>> consume lots of time. >>> >>> It means whenever we want to set a new 'mlock', the VM would be >>> blocked for a while. >> >> I'm not sure I understand how the mlock-ed memory is used. Are you using a >> custom malloc, for example with g_mem_set_vtable? >> >> Paolo > > Hi Paolo£º > > Thanks for your reply. > As you know qemu has an option "-mlock", I think it has some problems. > If we set "-realtime mlock=on", then qemu will mlockall vm's memory, It is a very time consuming action, and it will block the libvirt api until it finished. > so I think it is better to do 'mlock' asynchronously, the flow chart can be described like below. Is an asynchronous mlock valid for all workloads? Until the mlock finishes, there is no guarantee that the guest will have "real-time--friendly" response to memory allocation. > Is it ok? > Flow chart: > main funciton qmp command "set_ram_minguarantee" > | | > | | > create "mlock" thread change value of lock_ram_size > | | > | | > |------>thread wait<-------------wake up "mlock" thread > | | > | | > | | > |-------mlock(lock_ram_zie) Also, I'm not sure what the arguments to mlock are. How do you find the address range to pass to mlock? Paolo