Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp5592898imu; Wed, 26 Dec 2018 05:40:46 -0800 (PST) X-Google-Smtp-Source: ALg8bN6dKrQ1Xav81P+mViRtGj3x9ip0pq2WgBgWKRdvkK2mToNxCbb/swi003l2eb8w1HadH3fW X-Received: by 2002:a17:902:47aa:: with SMTP id r39mr19588927pld.219.1545831646438; Wed, 26 Dec 2018 05:40:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545831646; cv=none; d=google.com; s=arc-20160816; b=fGicOlptbukAet2e8P3tC2S6mqBbyPQLnDFwc8Ua7Bz9ygct0hBQBV9ryFsy9EKFTz 4t++/s0RVT+AV7e76Idii1J1G90L3xTHfWLUU6u0dzh4bJ07qL6msCfiHDQrb32aZqJR SJXb8fXaF+vwjhhpOzLs+FaCoFtTJKnYoiCNmD9q67P5GKNOur+lm+UlIlSSHsnpsR8X HuvoTkFQs8lptlwvopjAVulx+UBsBYKIxB/wkg2JSDG6eWSe9Ux6+NxpsFqa4pqhdeSD tMEEDCzjNIb5k0QdMOQgWHO4koaibpWZ+9Pj/OVkHnYV/NjYMRB2TC9hDVT4/Ct6Gs2B qOCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition:mime-version :references:subject:cc:cc:cc:cc:cc:cc:cc:cc:cc:cc:cc:to:from:date :user-agent:message-id; bh=65FA41VLdlPtPOOJtgzAErEZDKqpBZV5hcSbMKUAFtQ=; b=f7bDk+fi4WO5+wWEQMpWuSMyog7lyvzK8Z2xXzt4UJp5xsmh+8hdKezDYBhzwlc3Ok 6vgwD4lNSB6B6F9tGwtr9ZaQsEiIrMSAoRJvkzdVITkeLA0en+WRq5tDQGU0XCD1ec5W oZbnjqRieNvmHpYoH07Bob6spOnSDFk3hmkqn6GRbQZ1lXl18ZoPW80QaPC+a4kxScGa IqQlDvm8I5Cr/Mp/P6kzZsPpM3kJO2eHVcTX3hrnZNv7RSg7MgUSQO6ieiryMxkTuloI NPVtAqT8U3m8ccHkflSDO4L/+EXw2wzDzlSWKlhMN6zkzvlcwXSdQ1nwfRS6fTxMVcem LcPg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t1si32596161pgj.542.2018.12.26.05.40.31; Wed, 26 Dec 2018 05:40:46 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727296AbeLZNjD (ORCPT + 99 others); Wed, 26 Dec 2018 08:39:03 -0500 Received: from mga12.intel.com ([192.55.52.136]:31975 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726949AbeLZNhG (ORCPT ); Wed, 26 Dec 2018 08:37:06 -0500 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Dec 2018 05:37:05 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,400,1539673200"; d="scan'208";a="113358929" Received: from wangdan1-mobl1.ccr.corp.intel.com (HELO wfg-t570.sh.intel.com) ([10.254.210.154]) by orsmga003.jf.intel.com with ESMTP; 26 Dec 2018 05:37:02 -0800 Received: from wfg by wfg-t570.sh.intel.com with local (Exim 4.89) (envelope-from ) id 1gc9Mr-0005Oj-Em; Wed, 26 Dec 2018 21:37:01 +0800 Message-Id: <20181226133351.703380444@intel.com> User-Agent: quilt/0.65 Date: Wed, 26 Dec 2018 21:14:57 +0800 From: Fengguang Wu To: Andrew Morton cc: Linux Memory Management List , Yao Yuan , Fengguang Wu cc: kvm@vger.kernel.org Cc: LKML cc: Fan Du cc: Peng Dong cc: Huang Ying CC: Liu Jingqi cc: Dong Eddie cc: Dave Hansen cc: Zhang Yi cc: Dan Williams Subject: [RFC][PATCH v2 11/21] kvm: allocate page table pages from DRAM References: <20181226131446.330864849@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline; filename=0001-kvm-allocate-page-table-pages-from-DRAM.patch Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yao Yuan Signed-off-by: Yao Yuan Signed-off-by: Fengguang Wu --- arch/x86/kvm/mmu.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) --- linux.orig/arch/x86/kvm/mmu.c 2018-12-26 20:54:48.846720344 +0800 +++ linux/arch/x86/kvm/mmu.c 2018-12-26 20:54:48.842719614 +0800 @@ -950,6 +950,16 @@ static void mmu_free_memory_cache(struct kmem_cache_free(cache, mc->objects[--mc->nobjs]); } +static unsigned long __get_dram_free_pages(gfp_t gfp_mask) +{ + struct page *page; + + page = __alloc_pages(GFP_KERNEL_ACCOUNT, 0, numa_node_id()); + if (!page) + return 0; + return (unsigned long) page_address(page); +} + static int mmu_topup_memory_cache_page(struct kvm_mmu_memory_cache *cache, int min) { @@ -958,7 +968,7 @@ static int mmu_topup_memory_cache_page(s if (cache->nobjs >= min) return 0; while (cache->nobjs < ARRAY_SIZE(cache->objects)) { - page = (void *)__get_free_page(GFP_KERNEL_ACCOUNT); + page = (void *)__get_dram_free_pages(GFP_KERNEL_ACCOUNT); if (!page) return cache->nobjs >= min ? 0 : -ENOMEM; cache->objects[cache->nobjs++] = page;