From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757808AbZC2NPa (ORCPT ); Sun, 29 Mar 2009 09:15:30 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753201AbZC2NPQ (ORCPT ); Sun, 29 Mar 2009 09:15:16 -0400 Received: from mx2.redhat.com ([66.187.237.31]:49902 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751598AbZC2NPO (ORCPT ); Sun, 29 Mar 2009 09:15:14 -0400 Message-ID: <49CF745B.5010001@redhat.com> Date: Sun, 29 Mar 2009 16:15:07 +0300 From: Avi Kivity User-Agent: Thunderbird 2.0.0.21 (X11/20090320) MIME-Version: 1.0 To: Joerg Roedel CC: Joerg Roedel , Marcelo Tosatti , kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 4/7] kvm mmu: implement necessary data structures for second huge page accounting References: <1238164319-16092-1-git-send-email-joerg.roedel@amd.com> <1238164319-16092-5-git-send-email-joerg.roedel@amd.com> <49CF5F68.1020507@redhat.com> <20090329130353.GK31080@8bytes.org> In-Reply-To: <20090329130353.GK31080@8bytes.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Joerg Roedel wrote: >> >>> +static int has_wrprotected_largepage(struct kvm *kvm, gfn_t gfn) >>> +{ >>> + struct kvm_memory_slot *slot; >>> + int *hugepage_idx; >>> + >>> + gfn = unalias_gfn(kvm, gfn); >>> + slot = gfn_to_memslot_unaliased(kvm, gfn); >>> + if (slot) { >>> + hugepage_idx = slot_hugepage_idx(gfn, slot); >>> >>> >> slot_largepage_idx() here? >> >> I don't think we ever write protect large pages, so why is this needed? >> > > For 2mb pages we need to check if there is a write-protected 4k page in it > before we map a 2mb page for writing. If there is any write-protected 4k > page in a 2mb area this 2mb page is considered write-protected. These > 'write-protected' 2mb pages are accounted in the account_shadow() > function. This information is taken into account when we decide if we > can map a guest 1gb page as a 1gb page on the host too. > account_shadowed() actually increments a hugepage write_count by 1 for every 4K page, not 2M page, if I read the code correctly. The code I commented on is right though. The naming is confusing. I suggest has_wrprotected_page_in_{large,huge}page(). although with the a level parameter we can keep has_wrprotected_page(). btw, if we implement account_shadow() as you describe it (only account hugepages on largepage transition 0->1 or 1->0) we save a potential cacheline bounce on the hugepage write_count accounting array. -- error compiling committee.c: too many arguments to function