From patchwork Mon Apr 4 23:41:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yosry Ahmed X-Patchwork-Id: 12800930 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 97E62C433F5 for ; Mon, 4 Apr 2022 23:42:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E1FB36B0071; Mon, 4 Apr 2022 19:42:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DCF786B0073; Mon, 4 Apr 2022 19:42:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C6F866B0074; Mon, 4 Apr 2022 19:42:09 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.27]) by kanga.kvack.org (Postfix) with ESMTP id B78806B0071 for ; Mon, 4 Apr 2022 19:42:09 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay11.hostedemail.com (Postfix) with ESMTP id 8A14C8046A for ; Mon, 4 Apr 2022 23:41:59 +0000 (UTC) X-FDA: 79320821958.02.582B45D Received: from mail-pg1-f201.google.com (mail-pg1-f201.google.com [209.85.215.201]) by imf20.hostedemail.com (Postfix) with ESMTP id F3EEF1C001C for ; Mon, 4 Apr 2022 23:41:58 +0000 (UTC) Received: by mail-pg1-f201.google.com with SMTP id w3-20020a639343000000b003821fb4a367so6322023pgm.21 for ; Mon, 04 Apr 2022 16:41:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:message-id:mime-version:subject:from:to:cc; bh=c548FhlQVCeLASWi2SW4ftOYWvDCDMWewdhtv6ZW6gY=; b=pZ5ptiPrn0E9ZV+xzv07J81V/0Zux8TrUyo6jMG4kpMMh0K7HX28tDLAThcepAu89X jpvZME1VMw6StSg5iiL/4rPgoHaOxfhzFjG6Snu6piKhp/k5UnX283JNxefdJX944xjq dNQfi90BLutn0DfEG7mlMm2Q+X1nCiE7OwmJnyx4JdCOIINKCLdZ/jPNWkqEpBocJEIh opdie5q3vplCxy3ps+0zsh181ABEsygF6O+I5ntyX2TeFYBAowthwCCfrcrvIyt4xUPT YzaaaPuGx7wC1EbgwXE/pGRx1wcfad8pnHtkgPcUufqXShC2RupXspVY6eHOUw0hoU4Q Aygw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=c548FhlQVCeLASWi2SW4ftOYWvDCDMWewdhtv6ZW6gY=; b=WEzz7e613VzUqWTUYogVOemmZOYB4zl2P1+YDBE7YskNG2mKbuTcZTCGZV6mXc1c4d RZV0OVdwjkNg5kysKfiswO+ZCwgFEXIiZN0pZpMj71FkqIo3Y9mBKo70MfywhYwAzkxR PrrC749ix5JaykTM1rmBj3eHLzeVBYkalwctd82wvxCEO8h3JJkrhnsSyT2gZjNIMOId hviIBMMoBoTy8hG2olWMvyBbexyI7Cro9gDK+8ur+AHfpvbvLG1/gI9BTQJTk1696ctA SzWxWDvpmp6S0H1AtclvFSIfTL4n2306UYA5AEveeygHSVXwW5DcGBYyLsGHUtxj5Hin FSMQ== X-Gm-Message-State: AOAM5339iI/20ltl0yYp4k+lOUXEMxonj72is8IrANDXz1/dJBvGkHWH cTt82J2CwEMKt6s+DqP2MSblePypCsmHotl6 X-Google-Smtp-Source: ABdhPJzje5soq4C+73JHuqeLRvcYbRyyXekrcv2pJ3NUiCSG6xvCvoMeUjg8LbTBhyVFW5mEm2HJbc0MPJNQoep5 X-Received: from yosry.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:2327]) (user=yosryahmed job=sendgmr) by 2002:aa7:9019:0:b0:4fa:7532:9551 with SMTP id m25-20020aa79019000000b004fa75329551mr553545pfo.26.1649115717724; Mon, 04 Apr 2022 16:41:57 -0700 (PDT) Date: Mon, 4 Apr 2022 23:41:49 +0000 Message-Id: <20220404234154.1251388-1-yosryahmed@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.35.1.1094.g7c7d902a7c-goog Subject: [PATCH v2 0/5] KVM: mm: count KVM page table pages in pagetable stats 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-Stat-Signature: cincdkh6uqikxqnm1axpxhj96q89qdq4 Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=pZ5ptiPr; spf=pass (imf20.hostedemail.com: domain of 3RYJLYgoKCJAI8CBIu16yx08805y.w86527EH-664Fuw4.8B0@flex--yosryahmed.bounces.google.com designates 209.85.215.201 as permitted sender) smtp.mailfrom=3RYJLYgoKCJAI8CBIu16yx08805y.w86527EH-664Fuw4.8B0@flex--yosryahmed.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com X-Rspam-User: X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: F3EEF1C001C X-HE-Tag: 1649115718-775943 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: We keep track of several kernel memory stats (total kernel memory, page tables, stack, vmalloc, etc) on multiple levels (global, per-node, per-memcg, etc). These stats give insights to users to how much memory is used by the kernel and for what purposes. Currently, memory used by kvm for its page tables is not accounted in the pagetable stats. This patch series accounts the memory pages used by KVM for page tables in those stats. The riscv and mips patches are not tested properly due to lack of resources. Feel free to test or drop them. Yosry Ahmed (5): KVM: mm: add a helper to account page table pages used by KVM. KVM: x86: mm: count KVM page table pages in pagetable stats KVM: arm64: mm: count KVM page table pages in pagetable stats KVM: riscv: mm: count KVM page table pages in pagetable stats KVM: mips: mm: count KVM page table pages in pagetable stats arch/arm64/kernel/image-vars.h | 3 ++ arch/arm64/kvm/hyp/pgtable.c | 50 +++++++++++++++++++++------------- arch/mips/kvm/mips.c | 1 + arch/mips/kvm/mmu.c | 9 +++++- arch/riscv/kvm/mmu.c | 26 +++++++++++++----- arch/x86/kvm/mmu/mmu.c | 16 +++++++++-- arch/x86/kvm/mmu/tdp_mmu.c | 16 +++++++++-- include/linux/kvm_host.h | 9 ++++++ 8 files changed, 99 insertions(+), 31 deletions(-)