Received: by 10.223.148.5 with SMTP id 5csp6483612wrq; Wed, 17 Jan 2018 14:27:34 -0800 (PST) X-Google-Smtp-Source: ACJfBovTNnvPA4LfcplXPslbK1JD8+hhKBN2RbX3KvByVspTg96wJ4FieRut8Y0a64XVrHRNfNkj X-Received: by 10.84.140.1 with SMTP id 1mr11794401pls.55.1516228054854; Wed, 17 Jan 2018 14:27:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516228054; cv=none; d=google.com; s=arc-20160816; b=k4n1AGXnBdeVDrY/bKC+4nXeLdUeJtCF0W64u5rlqS1TAvtFZl/ju58cP09DloITM9 PZUiJ1M4+KyydJU+nlHAFohbHYMdYZru4CCqdbppyu77MIEepWGC7msBontCaTALLvh9 N7o3blc753iFoggFxhFRq3TrMk6a8WKpbdTBS3Vaf7bn/wNrAatHR4meF4VXB58UPU/o LQMdETdXeDrW/4BvJ62S0yL8s8srBwwfvvq0+QyVSKVkmHyC4dqYgVeWDGQ/87B331m1 fsFy3tEtnlT5hRRP23DNai7RJzfHwncgy91u3URx37l7vz+BsucD2oq9qm4pDuhFp7WW DlWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=fhvNyslbzo0NiHNxNVJa8V5HT4qnPRmHD2BJs0LxVL8=; b=Eudr4/F+s+i5E3VbMH7yvd/hmENRvX+OrVRzPZBFTp4RHqOMQIW4zSlx6simwpOFFo E9W0Ww9BLcX1tnQ8zMcQ7hOkZzUas0wCWwVfVb/lawyZyhOOnfyqaNHDRFDY46rBDguH 42DrENKzFC2gsANm/BZuZGX5KFzg1/X34juLLeBJs/S4ouAUbajoK5DJ6a7cwVU67jWN kqW1E0ho3/9vYREgSEIcY9YNfjOAoSb081Cwqr57niALF0L5HOOb/XFLLdiNcB5Btsne vu/P21LqXo9EWH9DCwIrjgJICQhoFVrtqi2T18y3yFqDfo6BePDeD31w9K0fRrVBlmn7 /l7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=vYsW771O; 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=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 3si5218536pfi.416.2018.01.17.14.27.21; Wed, 17 Jan 2018 14:27:34 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=vYsW771O; 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=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754698AbeAQW0P (ORCPT + 99 others); Wed, 17 Jan 2018 17:26:15 -0500 Received: from mail-lf0-f66.google.com ([209.85.215.66]:43870 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753361AbeAQWX0 (ORCPT ); Wed, 17 Jan 2018 17:23:26 -0500 Received: by mail-lf0-f66.google.com with SMTP id o89so19873011lfg.10 for ; Wed, 17 Jan 2018 14:23:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=fhvNyslbzo0NiHNxNVJa8V5HT4qnPRmHD2BJs0LxVL8=; b=vYsW771OWHxYRPeyAgX0jfOlsmPb4U5boHpLpKPheD1btVlCHuWzDIjCUQY7/US105 IKuVHYN8ZkpxsWEH946kNOAjj6T7d4egeJJ/0/k92km020kiL+1dATwqyqh1Q8pVhHLn wEk7LziujwlpMGHQOepmx5hrqhPAtE7zLVTnK4TITlqgzCV7doac4NEnRYskHCUUnivk rjoHt+0tEmJ7vw5Z2DbsXoOSDDBOaf8eiIeZp9A2EmhoM7UvvdCSdn3Swx5EMmuGDPtK 6HhF2wxil0PlO+tM58Cis8uc5p+9eJh55Qkt+Adt8hihZZeEpCig3HYcgls1lqPkVJ4y PtcQ== 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:in-reply-to :references; bh=fhvNyslbzo0NiHNxNVJa8V5HT4qnPRmHD2BJs0LxVL8=; b=NW3X0FcICDLshEP9mmePrEO6SwhdFfYq08xWXi+GXETfsJdIMoK6bLEES5rXvK1oYy AtxXYXlqyvqtUqlDjW2mxYDjO06B44Scz7cUjUewUxwX2OihDz+eUUUSzuUwXCUbm0ry Tl1YDRMcrmVUmZUyvgFtVVOUmUt5kqhCSzV1lsm9dPCIYH+4Fy74eExLOMMP2d0Wjw7P 3Aq7SEVeXdF5uIhSo2o9lELN6ZMRP9L0jP45MI0Csk+EWXUWL84fJhqJVS0kLCZchLuG aESlQRNfLqvkaDei/3PcVL1mFp4I/5lcqQG2oIHgb0yAQz/8HHHWLhwgNgSAYPgGJccQ 70Tw== X-Gm-Message-State: AKwxyteNplZlqpvv+p1UjML6OTs4vLV7PP3V2xuHqg4qpozB3IHn1J2n ncoYArg/10qXgKLFi/kQDEQ= X-Received: by 10.46.68.133 with SMTP id b5mr9607908ljf.62.1516227804407; Wed, 17 Jan 2018 14:23:24 -0800 (PST) Received: from linux.local ([95.79.164.146]) by smtp.gmail.com with ESMTPSA id l203sm953867lfb.59.2018.01.17.14.23.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 17 Jan 2018 14:23:23 -0800 (PST) From: Serge Semin To: ralf@linux-mips.org, miodrag.dinic@mips.com, jhogan@kernel.org, goran.ferenc@mips.com, david.daney@cavium.com, paul.gortmaker@windriver.com, paul.burton@mips.com, alex.belits@cavium.com, Steven.Hill@cavium.com Cc: alexander.sverdlin@nokia.com, matt.redfearn@mips.com, kumba@gentoo.org, marcin.nowakowski@mips.com, James.hogan@mips.com, Peter.Wotton@mips.com, Sergey.Semin@t-platforms.ru, linux-mips@linux-mips.org, linux-kernel@vger.kernel.org, Serge Semin Subject: [PATCH 04/14] MIPS: memblock: Discard bootmem initialization Date: Thu, 18 Jan 2018 01:23:02 +0300 Message-Id: <20180117222312.14763-5-fancer.lancer@gmail.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20180117222312.14763-1-fancer.lancer@gmail.com> References: <20180117222312.14763-1-fancer.lancer@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Since memblock is going to be used for the early memory allocation lets discard the bootmem node setup and all the related free-space search code. Low/high PFN extremums should be still calculated since they are needed on the paging_init stage. Since the current code is already doing memblock regions initialization the only thing left is to set the upper allocation limit to be up to the max low memory PFN, so the memblock API can be fully used from now. Signed-off-by: Serge Semin --- arch/mips/kernel/setup.c | 86 ++++-------------------------- 1 file changed, 11 insertions(+), 75 deletions(-) diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c index 1b8246e6c..0ffbc3bb5 100644 --- a/arch/mips/kernel/setup.c +++ b/arch/mips/kernel/setup.c @@ -367,29 +367,15 @@ static void __init bootmem_init(void) #else /* !CONFIG_SGI_IP27 */ -static unsigned long __init bootmap_bytes(unsigned long pages) -{ - unsigned long bytes = DIV_ROUND_UP(pages, 8); - - return ALIGN(bytes, sizeof(long)); -} - static void __init bootmem_init(void) { - unsigned long reserved_end; - unsigned long mapstart = ~0UL; - unsigned long bootmap_size; - bool bootmap_valid = false; int i; /* - * Sanity check any INITRD first. We don't take it into account - * for bootmem setup initially, rely on the end-of-kernel-code - * as our memory range starting point. Once bootmem is inited we + * Sanity check any INITRD first. Once memblock is inited we * will reserve the area used for the initrd. */ init_initrd(); - reserved_end = (unsigned long) PFN_UP(__pa_symbol(&_end)); /* * max_low_pfn is not a number of pages. The number of pages @@ -428,16 +414,6 @@ static void __init bootmem_init(void) max_low_pfn = end; if (start < min_low_pfn) min_low_pfn = start; - if (end <= reserved_end) - continue; -#ifdef CONFIG_BLK_DEV_INITRD - /* Skip zones before initrd and initrd itself */ - if (initrd_end && end <= (unsigned long)PFN_UP(__pa(initrd_end))) - continue; -#endif - if (start >= mapstart) - continue; - mapstart = max(reserved_end, start); } if (min_low_pfn >= max_low_pfn) @@ -463,53 +439,19 @@ static void __init bootmem_init(void) #endif max_low_pfn = PFN_DOWN(HIGHMEM_START); } - -#ifdef CONFIG_BLK_DEV_INITRD - /* - * mapstart should be after initrd_end - */ - if (initrd_end) - mapstart = max(mapstart, (unsigned long)PFN_UP(__pa(initrd_end))); +#ifdef CONFIG_HIGHMEM + pr_info("PFNs: low min %lu, low max %lu, high start %lu, high end %lu," + "max %lu\n", + min_low_pfn, max_low_pfn, highstart_pfn, highend_pfn, max_pfn); +#else + pr_info("PFNs: low min %lu, low max %lu, max %lu\n", + min_low_pfn, max_low_pfn, max_pfn); #endif /* - * check that mapstart doesn't overlap with any of - * memory regions that have been reserved through eg. DTB - */ - bootmap_size = bootmap_bytes(max_low_pfn - min_low_pfn); - - bootmap_valid = memory_region_available(PFN_PHYS(mapstart), - bootmap_size); - for (i = 0; i < boot_mem_map.nr_map && !bootmap_valid; i++) { - unsigned long mapstart_addr; - - switch (boot_mem_map.map[i].type) { - case BOOT_MEM_RESERVED: - mapstart_addr = PFN_ALIGN(boot_mem_map.map[i].addr + - boot_mem_map.map[i].size); - if (PHYS_PFN(mapstart_addr) < mapstart) - break; - - bootmap_valid = memory_region_available(mapstart_addr, - bootmap_size); - if (bootmap_valid) - mapstart = PHYS_PFN(mapstart_addr); - break; - default: - break; - } - } - - if (!bootmap_valid) - panic("No memory area to place a bootmap bitmap"); - - /* - * Initialize the boot-time allocator with low memory only. + * Initialize the boot-time allocator with low/high memory, but + * set the allocation limit to low memory only */ - if (bootmap_size != init_bootmem_node(NODE_DATA(0), mapstart, - min_low_pfn, max_low_pfn)) - panic("Unexpected memory size required for bootmap"); - for (i = 0; i < boot_mem_map.nr_map; i++) { unsigned long start, end; @@ -535,6 +477,7 @@ static void __init bootmem_init(void) memblock_add_node(PFN_PHYS(start), PFN_PHYS(end - start), 0); } + memblock_set_current_limit(PFN_PHYS(max_low_pfn)); /* * Register fully available low RAM pages with the bootmem allocator. @@ -570,8 +513,6 @@ static void __init bootmem_init(void) */ if (start >= max_low_pfn) continue; - if (start < reserved_end) - start = reserved_end; if (end > max_low_pfn) end = max_low_pfn; @@ -587,11 +528,6 @@ static void __init bootmem_init(void) memory_present(0, start, end); } - /* - * Reserve the bootmap memory. - */ - reserve_bootmem(PFN_PHYS(mapstart), bootmap_size, BOOTMEM_DEFAULT); - #ifdef CONFIG_RELOCATABLE /* * The kernel reserves all memory below its _end symbol as bootmem, -- 2.12.0