From patchwork Sun Mar 19 22:00:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 13180641 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id A6197C7618A for ; Sun, 19 Mar 2023 22:01:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4905190000F; Sun, 19 Mar 2023 18:01:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 440F3900002; Sun, 19 Mar 2023 18:01:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3087A90000F; Sun, 19 Mar 2023 18:01:12 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 22F8B900002 for ; Sun, 19 Mar 2023 18:01:12 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id F307480382 for ; Sun, 19 Mar 2023 22:01:11 +0000 (UTC) X-FDA: 80587019142.27.6E92633 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf09.hostedemail.com (Postfix) with ESMTP id 23800140025 for ; Sun, 19 Mar 2023 22:01:09 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=mM1Vr2+w; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf09.hostedemail.com: domain of rppt@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=rppt@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1679263270; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=jb5UHswS4WDrIMdMzQva9LfRH34XPC2+tjloBOHlJyY=; b=xAGw/FxoAbXxvpDJ+VwjwtFCN/9GKvPJdxp7JBYmFGBQZtzB++Nve+7wgPPhBHZa3yiUY2 7/5SKgokr0VDQaKq/q3kZs3akknz6mPo5sI4mmNp9pz8meQ0ZtiMq3gwPQaNNYz7KrbuV2 x3GhCasnlun3J2n8OKL277Mg9fPMNKY= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=mM1Vr2+w; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf09.hostedemail.com: domain of rppt@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=rppt@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1679263270; a=rsa-sha256; cv=none; b=YsE+Gjb20QivBPoQafXEgLkt4sP9hEDWOurNd/hZT+pKetH93VvBrOsAVz8VqEK+SQmeRC wBIpbCixyiAlCkBCvG4HzHbjE0bnrJOJkIWyA7wPHLyT78AjpJQuGBj1upqeHETZreP4AC ZWHzBsZY6lshsVms7TRCartxxLzSd2k= Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 384E2B80D2E; Sun, 19 Mar 2023 22:01:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E4F09C433A1; Sun, 19 Mar 2023 22:01:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1679263265; bh=BYCuSoeoE+R0Fgq41f+eIMZR+J4M0f4Ilxwf9ZY18IE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mM1Vr2+we//dVSbb0oJd235ZDrn59kE4Qyq71QnwosOv75bF+QcOee7a+KPpNC7WO Na8TF9Jaeb5Q+StXUw2tVLuOQHi0l3kByL9vKvQ7jkkqPlcWuomNFNL6bFb7ITNYQF zx3mhBvD9OuvGe8YST4IX+xf6LnKx5RtAh+ovZ9sPxyxj0LEvC+mgaSEUm7Pjn3Otr UJjubGuY50Drn59r4WjnLnAhSeI0n5tXB45LpjueAEkrYTfiktcYKyevHeQJfcf24d rSSyRMPXpbh1eGjlWOoKM8sLRKYQmbPZ1N8GydCPthI2SmRA189raVXHEk668HDNYi XwSOrnh+AObdA== From: Mike Rapoport To: Andrew Morton Cc: David Hildenbrand , Matthew Wilcox , Mel Gorman , Michal Hocko , Mike Rapoport , Thomas Bogendoerfer , Vlastimil Babka , linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 12/15] mm: move mem_init_print_info() to mm_init.c Date: Mon, 20 Mar 2023 00:00:05 +0200 Message-Id: <20230319220008.2138576-13-rppt@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230319220008.2138576-1-rppt@kernel.org> References: <20230319220008.2138576-1-rppt@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 23800140025 X-Rspamd-Server: rspam09 X-Rspam-User: X-Stat-Signature: c4ms61t38pcz1ru5i946m8d8dfb96hsr X-HE-Tag: 1679263269-206119 X-HE-Meta: U2FsdGVkX19DZQDEwVhcJNLJPZGOhNDCnoZCVhbKZSyvWauhuGxBs2v+o2s2vryOp7XHzPtBkdgtJhZD7EECzw8jPNQysv3VmQeFvST8BxDJgYwwL5LNycMOdKeIF1dLu9mvXGlosdkxxYq5j0V5WWU3QQRoSFi9TADgkbo27xxVn7Hsxc3o7mU6obVhVJLmHWzY1MZ0JAufxAPnhEkJHBJJXotqvOMOYsZRJSwYhMPnx9mdxMO+WhhwY2dGGrDL4xYOBVL5v9zvWH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VjmiBakDd1u4tptU1HY18jSh07FjQ5Ipt2QAGCxW0rnHuwqTCuiA== 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: "Mike Rapoport (IBM)" mem_init_print_info() is only called from mm_core_init(). Move it close to the caller and make it static. Signed-off-by: Mike Rapoport (IBM) Acked-by: David Hildenbrand --- include/linux/mm.h | 1 - mm/internal.h | 1 + mm/mm_init.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++ mm/page_alloc.c | 53 ---------------------------------------------- 4 files changed, 54 insertions(+), 54 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 2fecabb1a328..e249208f8fbe 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2925,7 +2925,6 @@ extern unsigned long free_reserved_area(void *start, void *end, int poison, const char *s); extern void adjust_managed_page_count(struct page *page, long count); -extern void mem_init_print_info(void); extern void reserve_bootmem_region(phys_addr_t start, phys_addr_t end); diff --git a/mm/internal.h b/mm/internal.h index 827499e39d78..1be4278d7913 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -201,6 +201,7 @@ pmd_t *mm_find_pmd(struct mm_struct *mm, unsigned long address); /* * in mm/page_alloc.c */ +#define K(x) ((x) << (PAGE_SHIFT-10)) extern char * const zone_names[MAX_NR_ZONES]; diff --git a/mm/mm_init.c b/mm/mm_init.c index 2d73d8b05a69..73964449669e 100644 --- a/mm/mm_init.c +++ b/mm/mm_init.c @@ -24,6 +24,8 @@ #include #include #include +#include +#include #include "internal.h" #include "shuffle.h" @@ -2635,6 +2637,57 @@ static void __init report_meminit(void) pr_info("mem auto-init: clearing system memory may take some time...\n"); } +static void __init mem_init_print_info(void) +{ + unsigned long physpages, codesize, datasize, rosize, bss_size; + unsigned long init_code_size, init_data_size; + + physpages = get_num_physpages(); + codesize = _etext - _stext; + datasize = _edata - _sdata; + rosize = __end_rodata - __start_rodata; + bss_size = __bss_stop - __bss_start; + init_data_size = __init_end - __init_begin; + init_code_size = _einittext - _sinittext; + + /* + * Detect special cases and adjust section sizes accordingly: + * 1) .init.* may be embedded into .data sections + * 2) .init.text.* may be out of [__init_begin, __init_end], + * please refer to arch/tile/kernel/vmlinux.lds.S. + * 3) .rodata.* may be embedded into .text or .data sections. + */ +#define adj_init_size(start, end, size, pos, adj) \ + do { \ + if (&start[0] <= &pos[0] && &pos[0] < &end[0] && size > adj) \ + size -= adj; \ + } while (0) + + adj_init_size(__init_begin, __init_end, init_data_size, + _sinittext, init_code_size); + adj_init_size(_stext, _etext, codesize, _sinittext, init_code_size); + adj_init_size(_sdata, _edata, datasize, __init_begin, init_data_size); + adj_init_size(_stext, _etext, codesize, __start_rodata, rosize); + adj_init_size(_sdata, _edata, datasize, __start_rodata, rosize); + +#undef adj_init_size + + pr_info("Memory: %luK/%luK available (%luK kernel code, %luK rwdata, %luK rodata, %luK init, %luK bss, %luK reserved, %luK cma-reserved" +#ifdef CONFIG_HIGHMEM + ", %luK highmem" +#endif + ")\n", + K(nr_free_pages()), K(physpages), + codesize / SZ_1K, datasize / SZ_1K, rosize / SZ_1K, + (init_data_size + init_code_size) / SZ_1K, bss_size / SZ_1K, + K(physpages - totalram_pages() - totalcma_pages), + K(totalcma_pages) +#ifdef CONFIG_HIGHMEM + , K(totalhigh_pages()) +#endif + ); +} + /* * Set up kernel memory allocators */ diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 2f333c26170c..bb0099f7da93 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -5239,8 +5239,6 @@ static bool show_mem_node_skip(unsigned int flags, int nid, nodemask_t *nodemask return !node_isset(nid, *nodemask); } -#define K(x) ((x) << (PAGE_SHIFT-10)) - static void show_migration_types(unsigned char type) { static const char types[MIGRATE_TYPES] = { @@ -6200,57 +6198,6 @@ unsigned long free_reserved_area(void *start, void *end, int poison, const char return pages; } -void __init mem_init_print_info(void) -{ - unsigned long physpages, codesize, datasize, rosize, bss_size; - unsigned long init_code_size, init_data_size; - - physpages = get_num_physpages(); - codesize = _etext - _stext; - datasize = _edata - _sdata; - rosize = __end_rodata - __start_rodata; - bss_size = __bss_stop - __bss_start; - init_data_size = __init_end - __init_begin; - init_code_size = _einittext - _sinittext; - - /* - * Detect special cases and adjust section sizes accordingly: - * 1) .init.* may be embedded into .data sections - * 2) .init.text.* may be out of [__init_begin, __init_end], - * please refer to arch/tile/kernel/vmlinux.lds.S. - * 3) .rodata.* may be embedded into .text or .data sections. - */ -#define adj_init_size(start, end, size, pos, adj) \ - do { \ - if (&start[0] <= &pos[0] && &pos[0] < &end[0] && size > adj) \ - size -= adj; \ - } while (0) - - adj_init_size(__init_begin, __init_end, init_data_size, - _sinittext, init_code_size); - adj_init_size(_stext, _etext, codesize, _sinittext, init_code_size); - adj_init_size(_sdata, _edata, datasize, __init_begin, init_data_size); - adj_init_size(_stext, _etext, codesize, __start_rodata, rosize); - adj_init_size(_sdata, _edata, datasize, __start_rodata, rosize); - -#undef adj_init_size - - pr_info("Memory: %luK/%luK available (%luK kernel code, %luK rwdata, %luK rodata, %luK init, %luK bss, %luK reserved, %luK cma-reserved" -#ifdef CONFIG_HIGHMEM - ", %luK highmem" -#endif - ")\n", - K(nr_free_pages()), K(physpages), - codesize / SZ_1K, datasize / SZ_1K, rosize / SZ_1K, - (init_data_size + init_code_size) / SZ_1K, bss_size / SZ_1K, - K(physpages - totalram_pages() - totalcma_pages), - K(totalcma_pages) -#ifdef CONFIG_HIGHMEM - , K(totalhigh_pages()) -#endif - ); -} - static int page_alloc_cpu_dead(unsigned int cpu) { struct zone *zone;