From patchwork Mon Apr 4 23:41:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yosry Ahmed X-Patchwork-Id: 1613216 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=L95YB6y1; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20210112 header.b=jZKt3Q4W; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=kvm-riscv-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KXS4239fTz9s75 for ; Tue, 5 Apr 2022 09:42:10 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:References: Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=tkLreRLzZgNUn7CDe2nqb4tBISkNNbLuzSNNswEvZPE=; b=L95YB6y1LWaVqsYD4iYT/VhtJr R7gYle/Jq8SUhZf4mj2WbUb5Qo31gMF6WCCee2HtvaqeLWTqsiUSzdDien/lElTpx57VBfDkQYOgu UstuAlLxYhfFu89rPSpYu3oPXBL9vqh175w7kvCBv34tSr1mDJMUxMV04tPc6NgoZcGVHN11LPASO KRexUaeq0PZLktN7gzO9xW0tjIidK8wEGLI/tkqK+RvO2GkjZQwem3suSgwGG5uF8FiIwHGdUoTWn 6/69xWK7KSOhExZKxbcJg5Fr+TQMxZircmeEeR4wbdAk2Lfpg97ejHWZfeQ42V1vSBABQ2eqe9JUN njvV3LTw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nbWKm-00GhaK-7c; Mon, 04 Apr 2022 23:42:08 +0000 Received: from mail-pg1-x549.google.com ([2607:f8b0:4864:20::549]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nbWKj-00GhZJ-F0 for kvm-riscv@lists.infradead.org; Mon, 04 Apr 2022 23:42:06 +0000 Received: by mail-pg1-x549.google.com with SMTP id r16-20020a638f50000000b00386086767c6so6346910pgn.6 for ; Mon, 04 Apr 2022 16:42:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=CaD5i7uWV8aXENdqT5/Q1IvKQzX6yvHELCk0D3aIz+A=; b=jZKt3Q4Wq9KSvffmXMldabyC+4MvZErOoCul5wp26X3fVT7avqVOywE6dRTV5JJo11 Lm4ZyJkQKcU6bzStWVXFKpng/HMzb0ZtmfE6Nd/d6RU6cNkQ84Wt3BpalH6kyvulvAYr zShnZTa4A2gBE2r/kwAWzJBueRGlu4o86+XfaQ68iLhbvA/N2T1r2CnXE7LYiv3IBC9b 3CL7MFjQ40fQAwER6JcDbx/XuT0DGvKUPlXuLZNEWli6lVkHQPjWTLNfDUk4OjPqLTYU 2oyOjUsiPjPTpHWPApftGdp/0I5gf1OiMGXydG4zv0rrxfDYablQdArb0FX9DyXUBsbK 23jQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=CaD5i7uWV8aXENdqT5/Q1IvKQzX6yvHELCk0D3aIz+A=; b=eK5FeB2rsFbXh+DBinmJ7cABz9zcHv1zncwGnFcbCLO3xJk8roL3Ly1HdRypnBZ/If FcIJF0HFxP/HvCdT49ZGmst5TUWY84NsbfC5/lNXrSYvHxuZNbN9txsIB0Gt7eRt4E3t UbHsuGAKIhggZ3N2H9RJyBdiT7rfUOOpbk3KIKnZjwd0iTsFq+cUwzcKDqIV4OYvQqGh PfxtdeaA8+G5MGHEnWlaiwHjk7b8PHsQyqMJ/qwEPxRvalKyR702ACtShO6MxOd77Sbb +QaHCGwB+4vkKHybzuCXj76eH4N5BzyXs/Pa+0sp39f0vBkCAsySwmdjcB2kFdO/+K9J KyVA== X-Gm-Message-State: AOAM530EaafeV6PvN8NYXryCSNeThEsPV4UjraYrd9BNb8uLQcd6S+Da q5hP/5s/rZj1MWDZo4cCJ3hbzC/9a7UPxldC X-Google-Smtp-Source: ABdhPJznx5CPgiI0z19F0ZkzF+3RdCQG8+R2KZlvfK7h7Xj/Uh7x/vARspwj7iObyoaIy9/NWmWCwv74G/ufbWL6 X-Received: from yosry.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:2327]) (user=yosryahmed job=sendgmr) by 2002:a17:90a:db48:b0:1ca:ab67:d75 with SMTP id u8-20020a17090adb4800b001caab670d75mr73933pjx.1.1649115722406; Mon, 04 Apr 2022 16:42:02 -0700 (PDT) Date: Mon, 4 Apr 2022 23:41:50 +0000 In-Reply-To: <20220404234154.1251388-1-yosryahmed@google.com> Message-Id: <20220404234154.1251388-2-yosryahmed@google.com> Mime-Version: 1.0 References: <20220404234154.1251388-1-yosryahmed@google.com> X-Mailer: git-send-email 2.35.1.1094.g7c7d902a7c-goog Subject: [PATCH v2 1/5] KVM: mm: add a helper to account page table pages used by KVM. From: Yosry Ahmed To: Huacai Chen , Aleksandar Markovic , Anup Patel , Atish Patra , Paolo Bonzini , Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel Cc: mizhang@google.com, David Matlack , kvm@vger.kernel.org, kvm-riscv@lists.infradead.org, linux-mips@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Shakeel Butt , Andrew Morton , Yosry Ahmed X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220404_164205_536016_E2C4A5E4 X-CRM114-Status: UNSURE ( 9.83 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -7.7 (-------) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Add a helper to account pages used by KVM for page tables as pagetable stats. This function will be used by subsequent patches in different archs. Signed-off-by: Yosry Ahmed --- include/linux/kvm_host.h | 9 +++++++++ 1 file changed, 9 insertions(+) Content analysis details: (-7.7 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:549 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -7.5 USER_IN_DEF_DKIM_WL From: address is in the default DKIM white-list -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.0 DKIMWL_WL_MED DKIMwl.org - Medium trust sender X-BeenThere: kvm-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "kvm-riscv" Errors-To: kvm-riscv-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Add a helper to account pages used by KVM for page tables as pagetable stats. This function will be used by subsequent patches in different archs. Signed-off-by: Yosry Ahmed --- include/linux/kvm_host.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index 252ee4a61b58..ca46b68e7086 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h @@ -2221,6 +2221,15 @@ static inline void kvm_handle_signal_exit(struct kvm_vcpu *vcpu) } #endif /* CONFIG_KVM_XFER_TO_GUEST_WORK */ +/* + * If nr > 1, we assume virt is the address of the first page of a block of + * pages that were allocated together (i.e accounted together). + */ +static inline void kvm_account_pgtable_pages(void *virt, int nr) +{ + mod_lruvec_page_state(virt_to_page(virt), NR_PAGETABLE, nr); +} + /* * This defines how many reserved entries we want to keep before we * kick the vcpu to the userspace to avoid dirty ring full. This