Received: from eggs.gnu.org ([2001:4830:134:3::10]:52889) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yqe8t-0001Z8-3h for qemu-devel@nongnu.org; Fri, 08 May 2015 05:00:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Yqe8p-0003hP-2M for qemu-devel@nongnu.org; Fri, 08 May 2015 05:00:23 -0400 From: Alberto Garcia In-Reply-To: <20150424130406.GC3838@noname.redhat.com> References: <1429629639-14328-1-git-send-email-berto@igalia.com> <20150422102602.GA20029@stefanha-thinkpad.redhat.com> <20150423101504.GG8811@stefanha-thinkpad.redhat.com> <20150424092621.GD13278@stefanha-thinkpad.redhat.com> <20150424095214.GB3838@noname.redhat.com> <20150424130406.GC3838@noname.redhat.com> Date: Fri, 08 May 2015 11:00:08 +0200 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Subject: Re: [Qemu-devel] [Qemu-block] [PATCH] qcow2: do lazy allocation of the L2 cache List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf Cc: Stefan Hajnoczi , Stefan Hajnoczi , qemu-devel , qemu block On Fri 24 Apr 2015 03:04:06 PM CEST, Kevin Wolf wrote: >> >> I think it would be nice to have a way to free unused cache >> >> entries after a while. >> > >> > Do you think mmap plus a periodic timer would work? >> > >> > I'm hesitant about changes like this because they make QEMU more >> > complex, slow down the guest, and make the memory footprint >> > volatile. But if a simple solution addresses the problem, then I'd >> > be happy. >> >> I understand. One possible approach would be to use the timer only if >> the cache size requested by the user is large, so >> >> 1) we only try to save memory when the amount of memory to save is >> significant. >> 2) we don't make the default scenario slower. >> >> I'll try to see if I can come up with a good solution (and with more >> numbers). > > I suspect that at this point, Anthony would have reminded us about > separation of policy and mechanism. The very least we need is some > option to control the policy (probably defaulting to no automatic > cache size changes). There's also the problem that with a single chunk of memory for all cache tables it's not so easy to free individual entries. One possible solution would be madvise() with MADV_DONTNEED, and that's rather simple to use, but I'm unsure about its portability. > The other option would be to let the management tool change the cache > size options at runtime (and as it happens, my current bdrv_reopen() > overhaul allows just that - except that a QMP interface isn't planned > yet), but I'm not sure if it has enough information to make good > decisions. If we know what the criteria are, they could possibly be > exposed, though. But what would you do there? Recreate the whole cache? Berto