From patchwork Tue May 8 02:00:16 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: 10385049 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 C71CE60236 for ; Tue, 8 May 2018 01:48:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B8E8628A30 for ; Tue, 8 May 2018 01:48:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AD05528A8E; Tue, 8 May 2018 01:48:24 +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 F3BCF28A30 for ; Tue, 8 May 2018 01:48:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 94FD06B000D; Mon, 7 May 2018 21:48:22 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 8FF4B6B0010; Mon, 7 May 2018 21:48:22 -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 7C83B6B0266; Mon, 7 May 2018 21:48:22 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl0-f71.google.com (mail-pl0-f71.google.com [209.85.160.71]) by kanga.kvack.org (Postfix) with ESMTP id 3A3426B000D for ; Mon, 7 May 2018 21:48:22 -0400 (EDT) Received: by mail-pl0-f71.google.com with SMTP id ay8-v6so859517plb.9 for ; Mon, 07 May 2018 18:48:22 -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=7+h9/JjoSFEKM+stmNeTIXcfOnTGUNvtjJ0zLFk+NAU=; b=ZsF359GKa0MJVUMKLMJZ6CF140Zqj3Qi3Ej8FnTwUdDfm9OqkG2q3pwm5JQ9CLtWAT tIN1BprLdYVU6aA3ObjLkF9lB/axinSm3fjHI5zFbqDz9DQkLbdr6HrwCZfQA5MkPLOw ey3iWpXfyx9Gxr579oMIgvTnVGfYlGYzQjNXMsvel/XuM/dWeFyGecG3/KG6IJBgzgUU oHATZiZ6//myUZf0T4U7/zPEWFrj4ECTldSoHPZH+xYhSjIoWubOdC+LYNpK8IDf5YB5 bh54AsgaQM1ZPWEuYqDjdWlaZcRhAu9Z5CKTrw8Be2FTG2pR5yQFwORMAl8z24X+Pvys UkCA== 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: ALQs6tBpJx9rJEI8fDAYt792bRgwDhKAfaGBX0gZLVyfpjn27Z1R125R mMVkzpeBAokllc4Np5ACmYNpPrDiLVhlZxaNZ3BKq3Q8sh4XdbSITkRpMVjdFuwrFOKVFiass7i pV2jwovtmNs4Z55cp6ydm/lH8SSjQ+6DyMqyBtIYivF9mBJEjqHmAKjcWApcy/uE= X-Received: by 2002:a63:6584:: with SMTP id z126-v6mr23574615pgb.168.1525744101892; Mon, 07 May 2018 18:48:21 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrf1BeFuomOukiCBIiPuLPEli1pYTXp//ye0Q1OzQjNQyU4Kuunf6QizvZagp/Q2LBmwawP X-Received: by 2002:a63:6584:: with SMTP id z126-v6mr23574567pgb.168.1525744100284; Mon, 07 May 2018 18:48:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525744100; cv=none; d=google.com; s=arc-20160816; b=aC7qV008cAqhgXc919RhUXICVF35V/aDsbgqXus4EqZOsras/1+UYjTRpzdLqa65pa qAlOmAhLUbm2ee7MuwOvsIM2JiDoHTvqZW48uBaXwCcl3rXXvd8DXOyW49zBLJRH2h74 wKqRsHhqmGAMKy2wnFL7ZU8E00aQQN8k88UaNWE7sfNzcUxi+dGIRx0NxPeb6Kb24MlZ 8d+o7IPzSuwHD/vsEBm8wBMGwvwaEKS9DCamOrxCcfpYxz9ZY1aF7k8y2/7uVDTmmugd ypCfQjpuUrEi3yupgB+K1KlaeuRRU4jIVEdpMCQBexXXc6MiMbclZBCN2IFVfkq9OzCT i/wg== 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=7+h9/JjoSFEKM+stmNeTIXcfOnTGUNvtjJ0zLFk+NAU=; b=xZgjUIM6F7whLnoCmf4+MpOnrl60PRELjxwP1wngLQxFUo4u8VYw6EzRgFBq0IEUbh SyNpdFZUqFkUf85ZDdsVtL0b6UEQ0eK73yTTbGGMWmeO800m4N2lgstsuVVe2JhAHZYR /sPSYbeD++2oPOneP4cC+3YB0ysH0tvDTKVcl6oo5vmWI4jzyv1F6f4xKJkTwRL1uZiI NZmj3jqNoZwJIOd3vBzn2a6UjS0eEmXXwwI/83/MLEjneWZuwAp5J39pcbUK8KHA3r6w 5bWX38O1/hL6IV+8Gsb58Zwz9ooIuxhzQEQcVMz11jJGV26YxyKTTN4fIofjqoSDYcrd L3Cg== 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 g77si24389439pfa.304.2018.05.07.18.48.19 for ; Mon, 07 May 2018 18:48:19 -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 4E9E02ECC8F3A; Tue, 8 May 2018 10:00:24 +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:00:16 +0800 Message-Id: <1525744818-110207-5-git-send-email-yehs1@lenovo.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1525744818-110207-1-git-send-email-yehs1@lenovo.com> References: <1525744818-110207-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 6a2cb14..1bf7876 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); @@ -1264,11 +1271,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 6285697..305975b 100644 --- a/arch/x86/kernel/setup.c +++ b/arch/x86/kernel/setup.c @@ -1031,7 +1031,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();