Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp5138603iog; Wed, 22 Jun 2022 12:50:37 -0700 (PDT) X-Google-Smtp-Source: AGRyM1ugygnk/SKtZUC3Zv3lQ3yGnabmILOu75yRjBaw0436dzNlmN33cSTu+RKdt762cVSURTHg X-Received: by 2002:a17:906:1c9:b0:712:1115:42a5 with SMTP id 9-20020a17090601c900b00712111542a5mr4619306ejj.662.1655927436831; Wed, 22 Jun 2022 12:50:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655927436; cv=none; d=google.com; s=arc-20160816; b=xUd341SN/Xj1sWfK3VZWzkFu0MqQ6OYADFpxdiZ+Ly840pKYnJqVdaCQNmcYQkZ7T1 XsE1LFfqZcPxIMvmpGNPnAE6s7FB/CA2fVTOwgD2CkWYXWkQH7RA3DEwyqHw/v9ASnwS dxNHuRJM9IztoXkiFdhT6ciGxwJJI2ywb3L7/O79qUrmfaVQ3Qat6C6h5uIXOy2PiHBP 7Zqk6+FL5trQN/iYKgIAf5KpYsDd6iFscbtlECUy2GPW9Aras9nBL78AaTvKWyFuaVS1 /VrrGjg5rwsQpcIDd8iwPKJ1GmC2eMwlwVhPGsnt7HDQ5OtGLb9PNI8ICa9p6AsBQ2rP HSvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=s79FYBIMXt/xfR/BYP7Rgx7NPNiR6fmBmIixdnDaf6E=; b=U+0U+inPyQeTiSV3Pk89Ne+qVmhxe4wo2GSliXlMpP3mNLHlpu4epFkgGcYw97eGFz LcwjTHV1mQzKoAX2GO+CFA5S+EmQuEPVlF07fTJvayVpZFE8AwrtDreC7Ikc1UKf2CHQ emxK1Zrs5f2u86PmtGufs+w6jg3Xu2+ttk1gqTJy/9TY/jErF5CurfOfbV1x/a4z2+8E wI/1Ze7/q7yG0wI2lGjqj6MeEsfMtyUGh22QPW1VYQLLM7TUqqx76LQbVAGhP+/n5KSd j8aMQmND25yb9XrBlIuzOPVXFZmCqz7yotLLZYyU8S3Ivubq/iTui6NfeLuhyTxlRGq9 adPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=GwCozIw6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j8-20020a05640211c800b00435c541fcaasi379389edw.245.2022.06.22.12.50.10; Wed, 22 Jun 2022 12:50:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=GwCozIw6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1358008AbiFVT2v (ORCPT + 99 others); Wed, 22 Jun 2022 15:28:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357734AbiFVT12 (ORCPT ); Wed, 22 Jun 2022 15:27:28 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 446B73EAB8 for ; Wed, 22 Jun 2022 12:27:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655926042; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=s79FYBIMXt/xfR/BYP7Rgx7NPNiR6fmBmIixdnDaf6E=; b=GwCozIw6XCHndRjoki9LPfl81ZHldukTlXuJksyuUps/uacI3h4HMx9KVEeSY+pHrQG6Eh brYzA/F80P7OgS2kGJT6aXGYBojX+MAyve3+Ncct/Zhbye2JkDHrM4xkngcPnMFdg3QETy CFDoe/UGJ/f4W8TTnWxJY+jOjyyofbE= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-418-3z5H9ysNMoepB2tICsIqMg-1; Wed, 22 Jun 2022 15:27:18 -0400 X-MC-Unique: 3z5H9ysNMoepB2tICsIqMg-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8CA4B811E76; Wed, 22 Jun 2022 19:27:17 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3838C141510C; Wed, 22 Jun 2022 19:27:17 +0000 (UTC) From: Paolo Bonzini To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: maz@kernel.org, anup@brainfault.org, seanjc@google.com, bgardon@google.com, peterx@redhat.com, maciej.szmigiero@oracle.com, kvmarm@lists.cs.columbia.edu, linux-mips@vger.kernel.org, kvm-riscv@lists.infradead.org, pfeiner@google.com, jiangshanlai@gmail.com, dmatlack@google.com Subject: [PATCH v7 16/23] KVM: x86/mmu: Update page stats in __rmap_add() Date: Wed, 22 Jun 2022 15:27:03 -0400 Message-Id: <20220622192710.2547152-17-pbonzini@redhat.com> In-Reply-To: <20220622192710.2547152-1-pbonzini@redhat.com> References: <20220622192710.2547152-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: David Matlack Update the page stats in __rmap_add() rather than at the call site. This will avoid having to manually update page stats when splitting huge pages in a subsequent commit. No functional change intended. Reviewed-by: Ben Gardon Reviewed-by: Peter Xu Signed-off-by: David Matlack Message-Id: <20220516232138.1783324-17-dmatlack@google.com> Signed-off-by: Paolo Bonzini --- arch/x86/kvm/mmu/mmu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c index a8cdbe2958d9..7cca28d89a85 100644 --- a/arch/x86/kvm/mmu/mmu.c +++ b/arch/x86/kvm/mmu/mmu.c @@ -1562,6 +1562,8 @@ static void __rmap_add(struct kvm *kvm, sp = sptep_to_sp(spte); kvm_mmu_page_set_gfn(sp, spte - sp->spt, gfn); + kvm_update_page_stats(kvm, sp->role.level, 1); + rmap_head = gfn_to_rmap(gfn, sp->role.level, slot); rmap_count = pte_list_add(cache, spte, rmap_head); @@ -2783,7 +2785,6 @@ static int mmu_set_spte(struct kvm_vcpu *vcpu, struct kvm_memory_slot *slot, if (!was_rmapped) { WARN_ON_ONCE(ret == RET_PF_SPURIOUS); - kvm_update_page_stats(vcpu->kvm, level, 1); rmap_add(vcpu, slot, sptep, gfn); } -- 2.31.1