From mboxrd@z Thu Jan 1 00:00:00 1970 From: Takuya Yoshikawa Subject: Re: [PATCH v2] KVM: Avoid zapping unrelated shadows in __kvm_set_memory_region() Date: Sat, 14 Apr 2012 10:12:20 +0900 Message-ID: <20120414101220.7ddbca6b558e3e60d6612802@gmail.com> References: <20120410220503.36efa6bfb776e741ba076115@gmail.com> <4F84F64B.4090704@linux.vnet.ibm.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: avi@redhat.com, mtosatti@redhat.com, kvm@vger.kernel.org, yoshikawa.takuya@oss.ntt.co.jp To: Xiao Guangrong Return-path: Received: from mail-pb0-f46.google.com ([209.85.160.46]:51804 "EHLO mail-pb0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752741Ab2DNBMZ (ORCPT ); Fri, 13 Apr 2012 21:12:25 -0400 Received: by pbcun15 with SMTP id un15so4194035pbc.19 for ; Fri, 13 Apr 2012 18:12:25 -0700 (PDT) In-Reply-To: <4F84F64B.4090704@linux.vnet.ibm.com> Sender: kvm-owner@vger.kernel.org List-ID: 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? I thought doing "goto restart" after the list scan would be more efficient. Takuya