From patchwork Mon Dec 12 09:53:02 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xie Yisheng X-Patchwork-Id: 9470319 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 279BA60476 for ; Mon, 12 Dec 2016 09:57:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1FF2328477 for ; Mon, 12 Dec 2016 09:57:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 148E22847C; Mon, 12 Dec 2016 09:57:28 +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=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9665128477 for ; Mon, 12 Dec 2016 09:57:27 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1cGNKs-0002xX-C7; Mon, 12 Dec 2016 09:55:54 +0000 Received: from szxga02-in.huawei.com ([119.145.14.65]) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1cGNKh-0001WK-92 for linux-arm-kernel@lists.infradead.org; Mon, 12 Dec 2016 09:55:47 +0000 Received: from 172.24.1.137 (EHLO SZXEML424-HUB.china.huawei.com) ([172.24.1.137]) by szxrg02-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id DRZ69601; Mon, 12 Dec 2016 17:53:10 +0800 (CST) Received: from [127.0.0.1] (10.177.29.40) by SZXEML424-HUB.china.huawei.com (10.82.67.153) with Microsoft SMTP Server id 14.3.235.1; Mon, 12 Dec 2016 17:53:02 +0800 Subject: Re: [PATCH] arm64: mm: Fix NOMAP page initialization To: Robert Richter , Russell King , Catalin Marinas , "Will Deacon" References: <1481307042-29773-1-git-send-email-rrichter@cavium.com> <83d6e6d0-cfb3-ec8b-241b-ec6a50dc2aa9@huawei.com> From: Yisheng Xie Message-ID: <9168b603-04aa-4302-3197-00f17fb336bd@huawei.com> Date: Mon, 12 Dec 2016 17:53:02 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.1.0 MIME-Version: 1.0 In-Reply-To: <83d6e6d0-cfb3-ec8b-241b-ec6a50dc2aa9@huawei.com> X-Originating-IP: [10.177.29.40] X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161212_015545_371929_0841D76F X-CRM114-Status: GOOD ( 13.84 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , David Daney , Ard Biesheuvel , linux-kernel@vger.kernel.org, linux-mm@kvack.org, James Morse , Hanjun Guo , Hanjun Guo , Xishi Qiu , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP hi Robert, On 2016/12/12 11:12, Yisheng Xie wrote: > hi Robert, > > On 2016/12/10 2:10, Robert Richter wrote: >> On ThunderX systems with certain memory configurations we see the >> following BUG_ON(): >> >> kernel BUG at mm/page_alloc.c:1848! >> >> This happens for some configs with 64k page size enabled. The BUG_ON() >> checks if start and end page of a memmap range belongs to the same >> zone. >> >> The BUG_ON() check fails if a memory zone contains NOMAP regions. In >> this case the node information of those pages is not initialized. This >> causes an inconsistency of the page links with wrong zone and node >> information for that pages. NOMAP pages from node 1 still point to the >> mem zone from node 0 and have the wrong nid assigned. >> > The patch can work for zone contains NOMAP regions. > > However, if BIOS do not add WB/WT/WC attribute to a physical address range, the > is_memory(md) will return false and this range will not be added to memblock. > efi_init > -> reserve_regions > if (is_memory(md)) { > early_init_dt_add_memory_arch(paddr, size); > > if (!is_usable_memory(md)) > memblock_mark_nomap(paddr, size); > } > > Then BUG_ON() check will also fails. Any idea about it? > It seems that memblock_is_memory() is also too strict for early_pfn_valid, so what about this patch, which use common pfn_valid as early_pfn_valid when CONFIG_HAVE_ARCH_PFN_VALID=y: ------------ diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index 0f088f3..9d596f3 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -1200,7 +1200,17 @@ static inline int pfn_present(unsigned long pfn) #define pfn_to_nid(pfn) (0) #endif +#ifdef CONFIG_HAVE_ARCH_PFN_VALID +static inline int early_pfn_valid(unsigned long pfn) +{ + if (pfn_to_section_nr(pfn) >= NR_MEM_SECTIONS) + return 0; + return valid_section(__nr_to_section(pfn_to_section_nr(pfn))); +} +#define early_pfn_valid early_pfn_valid +#else #define early_pfn_valid(pfn) pfn_valid(pfn) +#endif void sparse_init(void); #else #define sparse_init() do {} while (0)