From patchwork Tue May 8 02:30:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huaisheng HS1 Ye X-Patchwork-Id: 10385051 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 C39C060353 for ; Tue, 8 May 2018 02:18:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AF94B28CE9 for ; Tue, 8 May 2018 02:18:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A399F28CEE; Tue, 8 May 2018 02:18:44 +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=-2.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EAEA028CE9 for ; Tue, 8 May 2018 02:18:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 254296B000A; Mon, 7 May 2018 22:18:40 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 1ECDA6B026B; Mon, 7 May 2018 22:18:40 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E9EB96B000C; Mon, 7 May 2018 22:18:39 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf0-f197.google.com (mail-pf0-f197.google.com [209.85.192.197]) by kanga.kvack.org (Postfix) with ESMTP id A355F6B000C for ; Mon, 7 May 2018 22:18:39 -0400 (EDT) Received: by mail-pf0-f197.google.com with SMTP id j14so11025119pfn.11 for ; Mon, 07 May 2018 19:18:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=6abKIGgW4BecgJ/zp6t+hPZkxln2QNyzTFG2/tB9M24=; b=sLQEeDVKB0qByjmvxD+mgr4LP4lRRpsg4AXiCUuRTnpOefoIv3zR7nbC/UB2ZHvsBo IKM9xaHYCnXG/WhLf35FaLnL+rs+a923iJCEyCWFbVa/j9du+MIP/LxgVgSaAIEv+SfP BwGamLGU5Ag1Vc+Fn14NS/1qYF1n1EVxxKcEtUuoMIsC+rkccnM2G8xnFBlFU6jtAztR 7G6WFinVA/MzlO818LT3ZvG+9OUrS/iwT3d1bWoiLsLiVbmVgMG4F5qHxDl0CffZJjZ9 7cEXSsGIc3B8/YlrdVw7WHqa6mgGH/0NA1FI6yXT0Yl9aN8HXpv4mGk0tc5uVAzN9+Zt BmpQ== X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 103.244.59.4 is neither permitted nor denied by best guess record for domain of root@dev31.localdomain) smtp.mailfrom=root@dev31.localdomain; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=lenovo.com X-Gm-Message-State: ALQs6tAbcUZQ95uVmDafNs3rdXZ59wNo3tm9E7dE2I5s8uO1djF67+As 7ltIG07gW6KwSoXMGJth3SZ2TcWOqeopZeONTolhtCSkAFMbLsIziPIXS+MI4ClZGZMESbEMCUd vILweJ6+bZCQe/56HvN9P+6RITgmV4Y1iB47iTPHniaHSxAMJOUOKU2LEe1zPlzY= X-Received: by 2002:a17:902:6b0c:: with SMTP id o12-v6mr18193580plk.159.1525745919333; Mon, 07 May 2018 19:18:39 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpig2EdRNCOCsEal91759Bpv4uyHV6jv9pdhYDvvC4Osg0jICFhbT3eIIbYtHM4lRptb6yH X-Received: by 2002:a17:902:6b0c:: with SMTP id o12-v6mr18193529plk.159.1525745918141; Mon, 07 May 2018 19:18:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525745918; cv=none; d=google.com; s=arc-20160816; b=EFWT3XFVOJIRNexKS/miJZEy24s6LS385tJu74nHa6zj9Dc9CQAfmnFA5gt4woVagK CE5kDcFHgLl8D8lDHB0tMT1W3/Fpba+7Yhx2l98ND2xu3V1470pVLr/Jm7TApenStGaW KppF26/Lx+H5ptR89wk4O5EvkucEX7zKCGliy3e+VdFklv/s0hFwddXWhuYm9s+1Syj2 fyFblOE4ueHd1DYAaFAhSncHbvxXsp0FheLF/4XDXVnn7MlfWid+4tI5d/jnWEGEyOFm 17iwHi9hPJOLIUJG6Bf0XrCYyCU/Gi3J6/X/1ER0inQeQldP4JC2bFfTdX8l/mmfHq+r CFEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=6abKIGgW4BecgJ/zp6t+hPZkxln2QNyzTFG2/tB9M24=; b=fnPwKVZP9hZSCFDTeiTGVHMv0JpD2gKxIQEeYHiZK1bp4UqS2rxoE1os/ruS8MvR2r bsIrTXOKQt2130O9HySKIREqw4ZzYc4QwxdB1slKqc2W6QZEa4rLCd9t3sDbzDt5nx9k o5x78yEDRQWe5GHW9pm97Yz77QnSoCL55s9m/m4SqQrNfv5g7NzKp75LfVw95t/3AADB 4QTAb0apUniW5K3MwkLj/AZbpYaO2bvntWCIdrEb1zOezXrZMkFnrA40/th40Ptvkfi3 gFex3B1xi7LUAoQBpOYLAV5US8QJvKnaV0buzUBDVCnfmiakT6qRQf0VRYmS3XrsTiqt oEIg== ARC-Authentication-Results: i=1; mx.google.com; spf=neutral (google.com: 103.244.59.4 is neither permitted nor denied by best guess record for domain of root@dev31.localdomain) smtp.mailfrom=root@dev31.localdomain; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=lenovo.com Received: from dev31.localdomain ([103.244.59.4]) by mx.google.com with ESMTP id u2-v6si20368745plm.379.2018.05.07.19.18.37 for ; Mon, 07 May 2018 19:18:38 -0700 (PDT) Received-SPF: neutral (google.com: 103.244.59.4 is neither permitted nor denied by best guess record for domain of root@dev31.localdomain) client-ip=103.244.59.4; Authentication-Results: mx.google.com; spf=neutral (google.com: 103.244.59.4 is neither permitted nor denied by best guess record for domain of root@dev31.localdomain) smtp.mailfrom=root@dev31.localdomain; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=lenovo.com Received: by dev31.localdomain (Postfix, from userid 0) id 6FCAF2C06D1BA; Tue, 8 May 2018 10:30:45 +0800 (CST) From: Huaisheng Ye To: akpm@linux-foundation.org, linux-mm@kvack.org Cc: mhocko@suse.com, willy@infradead.org, vbabka@suse.cz, mgorman@techsingularity.net, pasha.tatashin@oracle.com, alexander.levin@verizon.com, hannes@cmpxchg.org, penguin-kernel@I-love.SAKURA.ne.jp, colyli@suse.de, chengnt@lenovo.com, hehy1@lenovo.com, linux-kernel@vger.kernel.org, linux-nvdimm@lists.01.org, Huaisheng Ye Subject: [RFC PATCH v1 4/6] arch/x86/kernel: mark NVDIMM regions from e820_table Date: Tue, 8 May 2018 10:30:26 +0800 Message-Id: <1525746628-114136-5-git-send-email-yehs1@lenovo.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1525746628-114136-1-git-send-email-yehs1@lenovo.com> References: <1525746628-114136-1-git-send-email-yehs1@lenovo.com> 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: X-Virus-Scanned: ClamAV using ClamSMTP During e820__memblock_setup memblock gets entries with type E820_TYPE_RAM, E820_TYPE_RESERVED_KERN and E820_TYPE_PMEM from e820_table, then marks NVDIMM regions with flag MEMBLOCK_NVDIMM. Create function as e820__end_of_nvm_pfn to calculate max_pfn with NVDIMM region, while zone_sizes_init needs max_pfn to get arch_zone_lowest/highest_possible_pfn. During free_area_init_nodes, the possible pfns need to be recalculated for ZONE_NVM. Signed-off-by: Huaisheng Ye Signed-off-by: Ocean He --- arch/x86/include/asm/e820/api.h | 3 +++ arch/x86/kernel/e820.c | 20 +++++++++++++++++++- arch/x86/kernel/setup.c | 8 ++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/arch/x86/include/asm/e820/api.h b/arch/x86/include/asm/e820/api.h index 62be73b..b8006c3 100644 --- a/arch/x86/include/asm/e820/api.h +++ b/arch/x86/include/asm/e820/api.h @@ -22,6 +22,9 @@ extern void e820__update_table_print(void); extern unsigned long e820__end_of_ram_pfn(void); +#ifdef CONFIG_ZONE_NVM +extern unsigned long e820__end_of_nvm_pfn(void); +#endif extern unsigned long e820__end_of_low_ram_pfn(void); extern u64 e820__memblock_alloc_reserved(u64 size, u64 align); diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c index 71c11ad..c1dc1cc 100644 --- a/arch/x86/kernel/e820.c +++ b/arch/x86/kernel/e820.c @@ -840,6 +840,13 @@ unsigned long __init e820__end_of_ram_pfn(void) return e820_end_pfn(MAX_ARCH_PFN, E820_TYPE_RAM); } +#ifdef CONFIG_ZONE_NVM +unsigned long __init e820__end_of_nvm_pfn(void) +{ + return e820_end_pfn(MAX_ARCH_PFN, E820_TYPE_PMEM); +} +#endif + unsigned long __init e820__end_of_low_ram_pfn(void) { return e820_end_pfn(1UL << (32 - PAGE_SHIFT), E820_TYPE_RAM); @@ -1246,11 +1253,22 @@ void __init e820__memblock_setup(void) end = entry->addr + entry->size; if (end != (resource_size_t)end) continue; - +#ifdef CONFIG_ZONE_NVM + if (entry->type != E820_TYPE_RAM && entry->type != E820_TYPE_RESERVED_KERN && + entry->type != E820_TYPE_PMEM) +#else if (entry->type != E820_TYPE_RAM && entry->type != E820_TYPE_RESERVED_KERN) +#endif continue; memblock_add(entry->addr, entry->size); + +#ifdef CONFIG_ZONE_NVM + if (entry->type == E820_TYPE_PMEM) { + /* Mark this region with PMEM flags */ + memblock_mark_nvdimm(entry->addr, entry->size); + } +#endif } /* Throw away partial pages: */ diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c index 4c616be..84c4ddb 100644 --- a/arch/x86/kernel/setup.c +++ b/arch/x86/kernel/setup.c @@ -1032,7 +1032,15 @@ void __init setup_arch(char **cmdline_p) * partially used pages are not usable - thus * we are rounding upwards: */ +#ifdef CONFIG_ZONE_NVM + max_pfn = e820__end_of_nvm_pfn(); + if (!max_pfn) { + printk(KERN_INFO "No physical NVDIMM has been found\n"); + max_pfn = e820__end_of_ram_pfn(); + } +#else max_pfn = e820__end_of_ram_pfn(); +#endif /* update e820 for memory not covered by WB MTRRs */ mtrr_bp_init();