From patchwork Fri Jan 31 06:14:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 11359239 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A42A9139A for ; Fri, 31 Jan 2020 06:14:24 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 637D120663 for ; Fri, 31 Jan 2020 06:14:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="VmcvpJfE" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 637D120663 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 82EE56B0531; Fri, 31 Jan 2020 01:14:22 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 78FB96B0533; Fri, 31 Jan 2020 01:14:22 -0500 (EST) 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 60A336B0534; Fri, 31 Jan 2020 01:14:22 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0118.hostedemail.com [216.40.44.118]) by kanga.kvack.org (Postfix) with ESMTP id 44FDD6B0531 for ; Fri, 31 Jan 2020 01:14:22 -0500 (EST) Received: from smtpin23.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 0D219824999B for ; Fri, 31 Jan 2020 06:14:22 +0000 (UTC) X-FDA: 76436914764.23.tramp12_26143592c7404 X-Spam-Summary: 2,0,0,dc650232ccab98fe,d41d8cd98f00b204,akpm@linux-foundation.org,:akpm@linux-foundation.org:anshuman.khandual@arm.com:borntraeger@de.ibm.com:gerald.schaefer@de.ibm.com:gor@linux.ibm.com:heiko.carstens@de.ibm.com::mm-commits@vger.kernel.org:prudo@linux.ibm.com:rppt@linux.ibm.com:schwidefsky@de.ibm.com:torvalds@linux-foundation.org:walling@linux.ibm.com,RULES_HIT:41:355:379:800:960:966:967:968:973:988:989:1260:1263:1345:1359:1381:1431:1437:1535:1544:1711:1730:1747:1777:1792:1963:2196:2198:2199:2200:2393:2525:2559:2563:2682:2685:2859:2899:2902:2933:2937:2939:2942:2945:2947:2951:2954:3022:3138:3139:3140:3141:3142:3355:3865:3866:3867:3868:3871:3872:3934:3936:3938:3941:3944:3947:3950:3953:3956:3959:4117:4250:4321:4385:4605:5007:6119:6261:6653:6737:7576:7875:7903:8603:9025:9121:9391:9545:9592:10004:10913:11026:11473:11658:11914:12043:12048:12114:12296:12297:12438:12517:12519:12555:12679:12783:12986:13846:14181:14721:14849:21080:21433:21451:21627:21819:21939:21990:30 003:3005 X-HE-Tag: tramp12_26143592c7404 X-Filterd-Recvd-Size: 6080 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf39.hostedemail.com (Postfix) with ESMTP for ; Fri, 31 Jan 2020 06:14:21 +0000 (UTC) Received: from localhost.localdomain (c-73-231-172-41.hsd1.ca.comcast.net [73.231.172.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 891202082E; Fri, 31 Jan 2020 06:14:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580451261; bh=MdNPv+7GVWcQSSG5oB0I7MxHSAI/wN4vXPwEAFnKAew=; h=Date:From:To:Subject:In-Reply-To:From; b=VmcvpJfEgTviuzJUoN5jfEY7iSL1csPeE6autafX4uv0gRNoi7aWgFULibE6CThah e4u1eATJOZclHS1v9bUumsRPqCo1PuvI4UlofbcCX+N/FItUwC5UFJreBurwIisERF R8pfEJZG5Gfhk+XtY97KE/jjh5FRZmB8FpQkVcl0= Date: Thu, 30 Jan 2020 22:14:20 -0800 From: Andrew Morton To: akpm@linux-foundation.org, anshuman.khandual@arm.com, borntraeger@de.ibm.com, gerald.schaefer@de.ibm.com, gor@linux.ibm.com, heiko.carstens@de.ibm.com, linux-mm@kvack.org, mm-commits@vger.kernel.org, prudo@linux.ibm.com, rppt@linux.ibm.com, schwidefsky@de.ibm.com, torvalds@linux-foundation.org, walling@linux.ibm.com Subject: [patch 059/118] mm/memblock: define memblock_physmem_add() Message-ID: <20200131061420.TnuyxFkQb%akpm@linux-foundation.org> In-Reply-To: <20200130221021.5f0211c56346d5485af07923@linux-foundation.org> User-Agent: s-nail v14.8.16 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: From: Anshuman Khandual Subject: mm/memblock: define memblock_physmem_add() On s390 platform memblock.physmem array is being built by directly calling into memblock_add_range() which is a low level function not intended to be used outside of memblock. Hence lets conditionally add helper functions for physmem array when HAVE_MEMBLOCK_PHYS_MAP is enabled. Also use MAX_NUMNODES instead of 0 as node ID similar to memblock_add() and memblock_reserve(). Make memblock_add_range() a static function as it is no longer getting used outside of memblock. Link: http://lkml.kernel.org/r/1578283835-21969-1-git-send-email-anshuman.khandual@arm.com Signed-off-by: Anshuman Khandual Reviewed-by: Mike Rapoport Acked-by: Heiko Carstens Cc: Vasily Gorbik Cc: Christian Borntraeger Cc: Martin Schwidefsky Cc: Collin Walling Cc: Gerald Schaefer Cc: Philipp Rudo Signed-off-by: Andrew Morton --- arch/s390/kernel/setup.c | 12 +++--------- include/linux/memblock.h | 7 +++---- mm/memblock.c | 14 +++++++++++++- 3 files changed, 19 insertions(+), 14 deletions(-) --- a/arch/s390/kernel/setup.c~mm-memblock-define-memblock_physmem_add +++ a/arch/s390/kernel/setup.c @@ -759,14 +759,6 @@ static void __init free_mem_detect_info( memblock_free(start, size); } -static void __init memblock_physmem_add(phys_addr_t start, phys_addr_t size) -{ - memblock_dbg("memblock_physmem_add: [%#016llx-%#016llx]\n", - start, start + size - 1); - memblock_add_range(&memblock.memory, start, size, 0, 0); - memblock_add_range(&memblock.physmem, start, size, 0, 0); -} - static const char * __init get_mem_info_source(void) { switch (mem_detect.info_source) { @@ -791,8 +783,10 @@ static void __init memblock_add_mem_dete get_mem_info_source(), mem_detect.info_source); /* keep memblock lists close to the kernel */ memblock_set_bottom_up(true); - for_each_mem_detect_block(i, &start, &end) + for_each_mem_detect_block(i, &start, &end) { + memblock_add(start, end - start); memblock_physmem_add(start, end - start); + } memblock_set_bottom_up(false); memblock_dump_all(); } --- a/include/linux/memblock.h~mm-memblock-define-memblock_physmem_add +++ a/include/linux/memblock.h @@ -113,6 +113,9 @@ int memblock_add(phys_addr_t base, phys_ int memblock_remove(phys_addr_t base, phys_addr_t size); int memblock_free(phys_addr_t base, phys_addr_t size); int memblock_reserve(phys_addr_t base, phys_addr_t size); +#ifdef CONFIG_HAVE_MEMBLOCK_PHYS_MAP +int memblock_physmem_add(phys_addr_t base, phys_addr_t size); +#endif void memblock_trim_memory(phys_addr_t align); bool memblock_overlaps_region(struct memblock_type *type, phys_addr_t base, phys_addr_t size); @@ -127,10 +130,6 @@ void reset_node_managed_pages(pg_data_t void reset_all_zones_managed_pages(void); /* Low level functions */ -int memblock_add_range(struct memblock_type *type, - phys_addr_t base, phys_addr_t size, - int nid, enum memblock_flags flags); - void __next_mem_range(u64 *idx, int nid, enum memblock_flags flags, struct memblock_type *type_a, struct memblock_type *type_b, phys_addr_t *out_start, --- a/mm/memblock.c~mm-memblock-define-memblock_physmem_add +++ a/mm/memblock.c @@ -575,7 +575,7 @@ static void __init_memblock memblock_ins * Return: * 0 on success, -errno on failure. */ -int __init_memblock memblock_add_range(struct memblock_type *type, +static int __init_memblock memblock_add_range(struct memblock_type *type, phys_addr_t base, phys_addr_t size, int nid, enum memblock_flags flags) { @@ -830,6 +830,18 @@ int __init_memblock memblock_reserve(phy return memblock_add_range(&memblock.reserved, base, size, MAX_NUMNODES, 0); } +#ifdef CONFIG_HAVE_MEMBLOCK_PHYS_MAP +int __init_memblock memblock_physmem_add(phys_addr_t base, phys_addr_t size) +{ + phys_addr_t end = base + size - 1; + + memblock_dbg("%s: [%pa-%pa] %pS\n", __func__, + &base, &end, (void *)_RET_IP_); + + return memblock_add_range(&memblock.physmem, base, size, MAX_NUMNODES, 0); +} +#endif + /** * memblock_setclr_flag - set or clear flag for a memory region * @base: base address of the region