From patchwork Fri Jun 29 14:02:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Shakeel Butt X-Patchwork-Id: 10496641 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3A5CC601C7 for ; Fri, 29 Jun 2018 14:02:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2910C2939A for ; Fri, 29 Jun 2018 14:02:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1C76029705; Fri, 29 Jun 2018 14:02:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BC3F32939A for ; Fri, 29 Jun 2018 14:02:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936668AbeF2OCh (ORCPT ); Fri, 29 Jun 2018 10:02:37 -0400 Received: from mail-pg0-f68.google.com ([74.125.83.68]:33510 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S936663AbeF2OCf (ORCPT ); Fri, 29 Jun 2018 10:02:35 -0400 Received: by mail-pg0-f68.google.com with SMTP id e11-v6so4056032pgq.0 for ; Fri, 29 Jun 2018 07:02:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Uvosgf1N9qtGxuTqtWVf314atLsMKNgXkNX+PFJWIEg=; b=BtOwTi8SZ5Zdw44f+OHljBuo5QTixt4B6M4XLNtGqbWWZryS4fSRp1W16Vk/onn7xL sTZgRTsAKUah8X5P9ACqMnuIqiYAO2dULGQ09Y7zQIWYXIk8mJP7GzF1b5P14p1VxN2H wIevw27bI4UPskzi6gTUxwNzybOROW/Fh3sYJkgNJXlBOOZbnNqlZcGpj7vbNzrLo/+7 fAUoe2dc3goyLrAGU3X7JuHLzXt5Ll2b6Krp+rwZTOaxFV4hCr2MQv3F4ZhldSvZulnW mIWS7BSXgMETBaOB0x9Y0q2BCbaACgLJ+rS12wwFdOki3F0XApVCP/eIs8uFpcIfTHrf aVfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Uvosgf1N9qtGxuTqtWVf314atLsMKNgXkNX+PFJWIEg=; b=J8Mdldf2AYUlE0EaWO8mCfPu99YAHjyEGlEq1/a9PcKEGfarRdslcHFCX4NLzXJjVL mcI282WQ+InNgy8vHeGoV0T2zeWlkKxeYFyI3H4fALT6tbzQEY70nOKGxS00kGwspLM3 82c/s3XJMRKU3/xcnbzLZwr4v8inYAQRx3GLX3ksJ9s+VQ4s9liWJ4p+hdE1uT4z3kwJ rBKhBJst287tPWdYiTJS2wavHaFvK6ux/wPGjNIUQyAAXVw47hOsGvN5W4B4TscTbzYo clDL4AtmU5oBZUT2TOYx7SDuc9NmFK0uEodOfl//1OwjXjciIa+RfJ+e1r7QyCN9q9Eg Ay1A== X-Gm-Message-State: APt69E3TkMfshxi0PGmTwnxdxA27sLAOHN9yz030VijEScI9ainpqjaE lo8FE7NWuw3PXB+50joQ8ym1Ug== X-Google-Smtp-Source: AAOMgpfWU3mOSkcge8aysMCz/fqJzVgO7PoraqP3SShv2ewf/C8YDgDIfDNXtx4PYutfqvGKbU9hgg== X-Received: by 2002:a62:484d:: with SMTP id v74-v6mr14736989pfa.256.1530280954093; Fri, 29 Jun 2018 07:02:34 -0700 (PDT) Received: from shakeelb.mtv.corp.google.com ([2620:15c:2cb:201:3a5f:3a4f:fa44:6b63]) by smtp.gmail.com with ESMTPSA id z25-v6sm1193111pgu.53.2018.06.29.07.02.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 29 Jun 2018 07:02:32 -0700 (PDT) From: Shakeel Butt To: Paolo Bonzini , Andrew Morton Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, linux-mm@kvack.org, Shakeel Butt , Michal Hocko , Johannes Weiner , Vladimir Davydov , Greg Thelen , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , Peter Feiner , stable@vger.kernel.org Subject: [PATCH v2] kvm, mm: account shadow page tables to kmemcg Date: Fri, 29 Jun 2018 07:02:24 -0700 Message-Id: <20180629140224.205849-1-shakeelb@google.com> X-Mailer: git-send-email 2.18.0.rc2.346.g013aa6912e-goog MIME-Version: 1.0 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The size of kvm's shadow page tables corresponds to the size of the guest virtual machines on the system. Large VMs can spend a significant amount of memory as shadow page tables which can not be left as system memory overhead. So, account shadow page tables to the kmemcg. Signed-off-by: Shakeel Butt Cc: Michal Hocko Cc: Johannes Weiner Cc: Vladimir Davydov Cc: Paolo Bonzini Cc: Greg Thelen Cc: Radim Krčmář Cc: Peter Feiner Cc: Andrew Morton Cc: stable@vger.kernel.org --- Changelog since v1: - replaced (GFP_KERNEL|__GFP_ACCOUNT) with GFP_KERNEL_ACCOUNT arch/x86/kvm/mmu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index d594690d8b95..6b8f11521c41 100644 --- a/arch/x86/kvm/mmu.c +++ b/arch/x86/kvm/mmu.c @@ -890,7 +890,7 @@ static int mmu_topup_memory_cache_page(struct kvm_mmu_memory_cache *cache, if (cache->nobjs >= min) return 0; while (cache->nobjs < ARRAY_SIZE(cache->objects)) { - page = (void *)__get_free_page(GFP_KERNEL); + page = (void *)__get_free_page(GFP_KERNEL_ACCOUNT); if (!page) return -ENOMEM; cache->objects[cache->nobjs++] = page;