From mboxrd@z Thu Jan 1 00:00:00 1970 From: Xiao Guangrong Subject: Re: [PATCH v2] KVM: Avoid zapping unrelated shadows in __kvm_set_memory_region() Date: Mon, 16 Apr 2012 11:53:03 +0800 Message-ID: <4F8B979F.5080905@linux.vnet.ibm.com> References: <20120410220503.36efa6bfb776e741ba076115@gmail.com> <4F84F64B.4090704@linux.vnet.ibm.com> <20120414101220.7ddbca6b558e3e60d6612802@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Cc: avi@redhat.com, mtosatti@redhat.com, kvm@vger.kernel.org, yoshikawa.takuya@oss.ntt.co.jp To: Takuya Yoshikawa Return-path: Received: from e23smtp06.au.ibm.com ([202.81.31.148]:58470 "EHLO e23smtp06.au.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750714Ab2DPEAJ (ORCPT ); Mon, 16 Apr 2012 00:00:09 -0400 Received: from /spool/local by e23smtp06.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 16 Apr 2012 03:48:36 +1000 Received: from d23av01.au.ibm.com (d23av01.au.ibm.com [9.190.234.96]) by d23relay03.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q3G3r6hi12583088 for ; Mon, 16 Apr 2012 13:53:06 +1000 Received: from d23av01.au.ibm.com (loopback [127.0.0.1]) by d23av01.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q3G3r59H030212 for ; Mon, 16 Apr 2012 13:53:06 +1000 In-Reply-To: <20120414101220.7ddbca6b558e3e60d6612802@gmail.com> Sender: kvm-owner@vger.kernel.org List-ID: On 04/14/2012 09:12 AM, Takuya Yoshikawa wrote: > Hi, > > On Wed, 11 Apr 2012 11:11:07 +0800 > Xiao Guangrong wrote: > >>> restart: >>> - list_for_each_entry_safe(sp, node, &kvm->arch.active_mmu_pages, link) >>> - if (kvm_mmu_prepare_zap_page(kvm, sp, &invalid_list)) >>> - goto restart; >>> + zapped = 0; >>> + list_for_each_entry_safe(sp, node, &kvm->arch.active_mmu_pages, link) { >>> + if ((slot >= 0) && !test_bit(slot, sp->slot_bitmap)) >>> + continue; >>> + >>> + zapped |= kvm_mmu_prepare_zap_page(kvm, sp, &invalid_list); >> >> >> You should "goto restart" here like the origin code, also, "safe" version of >> list_for_each is not needed. > > > Thank you for looking into this part. > > I understand that we can eliminate _safe in the original implementation. > > > Can you tell me the reason why we should do "goto restart" immediately here? > For performance, or correctness issue? > kvm_mmu_prepare_zap_page may remove many sp in kvm->arch.active_mmu_pages list that means the next node cached in list_for_each_entry_safe will become invalid.