Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752735AbbKPCuS (ORCPT ); Sun, 15 Nov 2015 21:50:18 -0500 Received: from tama500.ecl.ntt.co.jp ([129.60.39.148]:45397 "EHLO tama500.ecl.ntt.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751955AbbKPCuQ (ORCPT ); Sun, 15 Nov 2015 21:50:16 -0500 Subject: Re: [PATCH 05/10] KVM: x86: MMU: Use for_each_rmap_spte macro instead of pte_list_walk() To: Marcelo Tosatti References: <20151112204849.ba920599a8426d7196a0df73@lab.ntt.co.jp> <20151112205245.6bd773737cfa78422dac5a79@lab.ntt.co.jp> <20151113214727.GA29103@amt.cnet> <20151114092047.GA25627@amt.cnet> Cc: pbonzini@redhat.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org From: Takuya Yoshikawa Message-ID: <564944A3.5080005@lab.ntt.co.jp> Date: Mon, 16 Nov 2015 11:51:15 +0900 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: <20151114092047.GA25627@amt.cnet> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-TM-AS-MML: disable Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2589 Lines: 79 On 2015/11/14 18:20, Marcelo Tosatti wrote: > The actual issue is this: a higher level page that had, under its children, > no out of sync pages, now, due to your addition, a child that is unsync: > > initial state: > level1 > > final state: > > level1 -x-> level2 -x-> level3 > > Where -x-> are the links created by this pagefault fixing round. > > If _any_ page under you is unsync (not necessarily the ones this > pagefault is accessing), you have to mark parents unsync. I understand this, but I don't think my patch will break this. What kvm_mmu_mark_parents_unsync() does is: for each p_i in sp->parent_ptes rmap chain mark_unsync(p_i); Then, mark_unsync() finds the parent sp including that p_i to set ->unsync_child_bitmap and increment ->unsync_children if necessary. It may also call kvm_mmu_mark_parents_unsync() recursively. I understand we need to tell the parents "you have an unsync child/descendant" until this information reaches the top level by that recursive calls. But since these recursive calls cannot come back to the starting sp, the child->parent graph has no loop, each mark_unsync(p_i) will not be affected by other parents in that sp->parent_ptes rmap chain, from which we started the recursive calls. As the following code shows, my patch does mark_unsync(parent_pte) separately, and then mmu_page_add_parent_pte(vcpu, sp, parent_pte): > - } else if (sp->unsync) > + if (parent_pte) > + mark_unsync(parent_pte); > + } else if (sp->unsync) { > kvm_mmu_mark_parents_unsync(sp); > + if (parent_pte) > + mark_unsync(parent_pte); > + } > + mmu_page_add_parent_pte(vcpu, sp, parent_pte); So, as you worried, during each mark_unsync(p_i) is processed, this parent_pte does not exist in that sp->parent_ptes rmap chain. But as I explained above, this does not change anything about what each mark_unsync(p_i) call does, so keeps the original behaviour. By the way, I think "kvm_mmu_mark_parents_unsync" and "mark_unsync" do not tell what they actually do well. When I first saw the names, I thought they would just set the parents' sp->unsync. To reflect the following meaning better, it should be propagate_unsync(_to_parents) or something: Tell the parents "you have an unsync child/descendant" until this unsync information reaches the top level Thanks, Takuya -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/