Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp6340299pxv; Thu, 29 Jul 2021 12:04:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy8WmfywHnyW6EeJgZqNiDCtxUoRKaHX2XplA8r81sQiFw0dCLddcO2dqcYOctVoaOU/DIg X-Received: by 2002:a17:906:30d0:: with SMTP id b16mr5951597ejb.495.1627585479107; Thu, 29 Jul 2021 12:04:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627585479; cv=none; d=google.com; s=arc-20160816; b=1Kc8e/vQMYkYxf/1mEtILgWttBpzbB2jqWWsc2sTWeT0LIYxhb8goMDukZfGf6BQDz wG11XmrCYm1/OtR+TvBOKGljRxvhe62i8UXb+f6H5vfLl444UhZDFF/x41ev5sIo37Ba wgr+XjbUH5TObJtPuPP8kWsKB5fhBECHnS08Lkj9jmaxRN77+h7/YqbhPghGFo47AxVd sv2e6rcdynbpYDv1K8KsRPwOLuKED/3pGZLdVb5TtiX11dqtNA8ljf5GHtZLVpD/csPU IvXY3/XXA6FyJiPYk2Y1/KHVU9+7LOVd5u1KAvJhv4FZQP78GiC1Ztwbjeo6Sup0wOpu fjOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=YqZsxUCzv1nae23QeEhOZX1NZ5hWxTmCpAqwWTcBvgs=; b=ZDErr0B6WsVK+ni60+CVX5pPCDLb3LvM6QIC2/R+PChr9f8XEsxKi2kknvyEGnOsi3 cTZ/2ry6RdKSsmhzIiaANvnURke697xscNwUNubtovMfi8gzn1EEV+GZbKSZyCx6Yl5a 7nGYMjIqj/ofWuViHjVK+sKrcCQCy1F/Ti1bkVG2CQ4R+oKZNQGF4gKAtcpuDS4wtXR2 5c9VciIw/ZnG0tF5JEjzuwWx+9eHX0l5RP5QdSBA/Vq8fhnBfhErZD5M71ywPt/LnHmL rs8Q1/2uVFzqMCubadcs2DJz+uAOxuHe7th9BPzN+cIecl4Vm3Pl87cC37V/6bFgaUGd KoDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="g/a5YHYC"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lc22si3548205ejc.720.2021.07.29.12.04.15; Thu, 29 Jul 2021 12:04:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="g/a5YHYC"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231984AbhG2TCz (ORCPT + 99 others); Thu, 29 Jul 2021 15:02:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44460 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229925AbhG2TCx (ORCPT ); Thu, 29 Jul 2021 15:02:53 -0400 Received: from mail-yb1-xb35.google.com (mail-yb1-xb35.google.com [IPv6:2607:f8b0:4864:20::b35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0EC1DC061765 for ; Thu, 29 Jul 2021 12:02:50 -0700 (PDT) Received: by mail-yb1-xb35.google.com with SMTP id k65so11780384yba.13 for ; Thu, 29 Jul 2021 12:02:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=YqZsxUCzv1nae23QeEhOZX1NZ5hWxTmCpAqwWTcBvgs=; b=g/a5YHYCKtRO0EJwzsoCB8TFISeJeQcBFKHob0LIZOeKkVIFXHcR7jJ0xYtaq14RYT CRU+twyymtgjt2xdKhkI8AySQBUkukb5oMzrVNnfgPMXqbDm2ZXJVFZFqm52wn3762Qe 3XfD2as2/lEU3ruovPckflst5UmcV/DZxHmjaRcJnhkOxQH6Xg0JlRYX/pHz0c1S2E67 8oj1DOIUIVjFI1O03MX9qXBUPM1GtyV+sXced/UOf1Pdu5pTT1eTAsRRCrP+8iIhoEmo W0YExJMNzqRZ0eh3GPSTi6g3VlyV831ucFL37jWfhpQkiTywgtGDRb7w7Lg8Sn5vM2Z7 4znw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=YqZsxUCzv1nae23QeEhOZX1NZ5hWxTmCpAqwWTcBvgs=; b=pzw3dzh6aeqw0lBNVzmWygbE/AQXR8JRhS0q0l2NDBEI8exGvoQQcL402bL3VGSdtH Xuf1eMhz/7TSXlogbVumIDMZVrdW/SFRxj9g34zAZ3/Ga1q8ZTgGf/jLdceQ84mlNMUm NY6sK4vUMdX/NyWWsfIFFxfu+9pezlBVY2ypX7rhcXTxZvnj5eUUHbE7Srk7SwYZijoT lUP96t/Hy3PGZ461H09gBi8o+egir2Q6s8RCX91lVWnCFDCqyFhMqvMq+ULdjpFQiHMW 0XskE91CVAUWGeKR8kEpKv7c5TQcdXPV38v/0kI9F6He+WJvVpbVt7wh/xjq7W05pTTQ +2VA== X-Gm-Message-State: AOAM533s+m4WfCCgAM8sAKVD9w2ldEgKK9R1P5rnl1WveW5uzRVFDanP 88LvABSTAchfWq1yeGhVNTvf1EU9ORAuIndkZzxxpA== X-Received: by 2002:a25:f503:: with SMTP id a3mr7922680ybe.501.1627585369133; Thu, 29 Jul 2021 12:02:49 -0700 (PDT) MIME-Version: 1.0 References: <20210726175357.1572951-1-mizhang@google.com> <20210726175357.1572951-4-mizhang@google.com> In-Reply-To: From: Mingwei Zhang Date: Thu, 29 Jul 2021 12:02:38 -0700 Message-ID: Subject: Re: [PATCH v2 3/3] KVM: x86/mmu: Add detailed page size stats To: Sean Christopherson Cc: Ben Gardon , Paolo Bonzini , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm , LKML , Jing Zhang Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jul 29, 2021 at 11:45 AM Sean Christopherson wrote: > > On Mon, Jul 26, 2021, Ben Gardon wrote: > > On Mon, Jul 26, 2021 at 10:54 AM Mingwei Zhang wrote: > > > diff --git a/arch/x86/kvm/mmu.h b/arch/x86/kvm/mmu.h > > > index 83e6c6965f1e..ad5638815311 100644 > > > --- a/arch/x86/kvm/mmu.h > > > +++ b/arch/x86/kvm/mmu.h > > > @@ -240,4 +240,6 @@ static inline bool kvm_memslots_have_rmaps(struct kvm *kvm) > > > return smp_load_acquire(&kvm->arch.memslots_have_rmaps); > > > } > > > > > > +void kvm_update_page_stats(struct kvm *kvm, int level, int count); > > > + > > > #endif > > > diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c > > > index 442cc554ebd6..7e0fc760739b 100644 > > > --- a/arch/x86/kvm/mmu/mmu.c > > > +++ b/arch/x86/kvm/mmu/mmu.c > > > @@ -588,16 +588,22 @@ static bool mmu_spte_update(u64 *sptep, u64 new_spte) > > > return flush; > > > } > > > > > > +void kvm_update_page_stats(struct kvm *kvm, int level, int count) > > > +{ > > > + atomic64_add(count, &kvm->stat.page_stats.pages[level - 1]); > > > +} > > This can be static inline in the header. Ignoring prolog+RET, it's four instructions, > and two of those are sign extending input params. will do.It is really nice to see that this big function has been finally shrinked to a single-line routine.