From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marcelo Tosatti Subject: Re: [PATCH] KVM: MMU: Fix mmu_shrink() so that it can free mmu pages as intended Date: Wed, 18 Jul 2012 17:52:46 -0300 Message-ID: <20120718205246.GB18886@amt.cnet> References: <20120705195607.2e940693.yoshikawa.takuya@oss.ntt.co.jp> <20120705114959.GD15459@redhat.com> <20120705230546.ed314f3d83b5f727492db2f1@gmail.com> <20120712183509.8e04491c.yoshikawa.takuya@oss.ntt.co.jp> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Takuya Yoshikawa , Gleb Natapov , avi@redhat.com, kvm@vger.kernel.org To: Takuya Yoshikawa Return-path: Received: from mx1.redhat.com ([209.132.183.28]:4641 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753394Ab2GRUxV (ORCPT ); Wed, 18 Jul 2012 16:53:21 -0400 Content-Disposition: inline In-Reply-To: <20120712183509.8e04491c.yoshikawa.takuya@oss.ntt.co.jp> Sender: kvm-owner@vger.kernel.org List-ID: On Thu, Jul 12, 2012 at 06:35:09PM +0900, Takuya Yoshikawa wrote: > On Thu, 5 Jul 2012 23:05:46 +0900 > Takuya Yoshikawa wrote: > > > On Thu, 5 Jul 2012 14:50:00 +0300 > > Gleb Natapov wrote: > > > > > > Note that "if (!nr_to_scan--)" check is removed since we do not try to > > > > free mmu pages from more than one VM. > > > > > > > IIRC this was proposed in the past that we should iterate over vm list > > > until freeing something eventually, but Avi was against it. I think the > > > probability of a VM with kvm->arch.n_used_mmu_pages == 0 is low, so > > > it looks OK to drop nr_to_scan to me. > > > > Since our batch size is 128, the minimum positive @nr_to_scan, it's almost > > impossible to see the effect of the check. > > Thinking more about this: > > I think freeing mmu pages by shrink_slab() is problematic. > > For example, if we do > # echo 2 /proc/sys/vm/drop_caches > on the host, some mmu pages will be freed. > > This is not what most people expect, probably. > > > Although this patch is needed to care about shadow paging's extreme > mmu page usage, we should do somthing better in the future. > > What I think reasonable is not treating all mmu pages as freeable: > - determine some base number of mmu pages: base_mmu_pages > - return (total_mmu_pages - base_mmu_pages) to the caller > > * We may use n_max_mmu_pages for calculating this base number. > > By doing so, we can avoid freeing mmu pages especially when EPT/NPT ON. Takuya, Can't understand, can you please expand more clearly? TIA