From patchwork Mon Mar 25 14:56:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13602376 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 EBFC4C54E58 for ; Mon, 25 Mar 2024 14:57:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7D6276B00A3; Mon, 25 Mar 2024 10:57:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 786D66B00A4; Mon, 25 Mar 2024 10:57:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 675A86B00A5; Mon, 25 Mar 2024 10:57:27 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 570206B00A3 for ; Mon, 25 Mar 2024 10:57:27 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 299451401FE for ; Mon, 25 Mar 2024 14:57:27 +0000 (UTC) X-FDA: 81935864934.21.E149DC2 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf12.hostedemail.com (Postfix) with ESMTP id 4598D40006 for ; Mon, 25 Mar 2024 14:57:24 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=IuXen+Ps; spf=pass (imf12.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1711378644; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=+c4yPtzG9SnjpO3Ux0abr18tbqf9XDz5JHpLVv3vCHY=; b=O2KyYDWJEAhvCJreGZic84VYZBG0w3VDFOQqpMyQR9jglzQMNsuZWXPFWBnV1lI1LSt7Cv zLw2jQe4l4+ujQ9/5b7vPPPv77PZIpIPbPAq9ZiNXswtlnHYQHzXGAhkXPP/l9CFixfclu OtSZQAu+virDiIC/6nAReug3mVTAc1g= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=IuXen+Ps; spf=pass (imf12.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1711378644; a=rsa-sha256; cv=none; b=4nsNxYIIrz5VYgUR+QMBM8XhdwqUux4tLxQWPY6soQx7JovxS3Sz2RhjQc8NeXja0e3oaI dgeEW6m1XxHmx0xCw+44kQFs7feJFKYZt8Dxm4UQ5zXrgskIs5nV6DyDp260wtX0Znopqf C1ATaRdd3e+N5ODbEgxu/mJbuO9Y98A= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1711378643; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+c4yPtzG9SnjpO3Ux0abr18tbqf9XDz5JHpLVv3vCHY=; b=IuXen+Ps+82pqkmdcS51jd72Eel/JLa2CfMGp2BJw7gqX6Epv3H4u4dAZMhZXG2KehBF7I n1VyvI+7RVDuqZ7f7XolRyFpj3Z3TXT6IHaLSmdkY0j9sZUC+cfDXOY5xc3lI9+vctdcY2 8py+gE9359dVLZukczhX8z6/uvAez2Y= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-252-_uq44HFeMq6xtpdXzT6_XA-1; Mon, 25 Mar 2024 10:57:20 -0400 X-MC-Unique: _uq44HFeMq6xtpdXzT6_XA-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id ACF061869C65; Mon, 25 Mar 2024 14:57:19 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (unknown [10.72.116.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 30A953C20; Mon, 25 Mar 2024 14:57:15 +0000 (UTC) From: Baoquan He To: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, x86@kernel.org, linuxppc-dev@lists.ozlabs.org, akpm@linux-foundation.org, rppt@kernel.org, Baoquan He Subject: [PATCH v2 1/6] x86: remove unneeded memblock_find_dma_reserve() Date: Mon, 25 Mar 2024 22:56:41 +0800 Message-ID: <20240325145646.1044760-2-bhe@redhat.com> In-Reply-To: <20240325145646.1044760-1-bhe@redhat.com> References: <20240325145646.1044760-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.1 X-Rspamd-Queue-Id: 4598D40006 X-Rspam-User: X-Stat-Signature: 99tpc1sjgphyezeifzubnp8ii44gq1mz X-Rspamd-Server: rspam01 X-HE-Tag: 1711378644-755540 X-HE-Meta: U2FsdGVkX1/5ydIpEEOzVUw3JzkDxUAFyQvVkM0id7L3y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EhoFBRhsXrJ2JhQtTnFiU4LXJ8GqU3ZnTGLiED/tZWWAaMSnOCLRi3YvjnUmoIVi8Z3B3Fq7rl8b9nOSFbOsjayerDceIKXH7A== 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: List-Subscribe: List-Unsubscribe: Variable dma_reserve and its usage was introduced in commit 0e0b864e069c ("[PATCH] Account for memmap and optionally the kernel image as holes"). Its original purpose was to accounting for the reserved pages in DMA zone to make DMA zone's watermarks calculation more accurate on x86. However, currently there's zone->managed_pages to account for all available pages for buddy, zone->present_pages to account for all present physical pages in zone. What is more important, on x86, calculating and setting the zone->managed_pages is a temporary move, all zone's managed_pages will be zeroed out and reset to the actual value according to how many pages are added to buddy allocator in mem_init(). Before mem_init(), no buddy alloction is requested. And zone's pcp and watermark setting are all done after mem_init(). So, no need to worry about the DMA zone's setting accuracy during free_area_init(). Hence, remove memblock_find_dma_reserve() to stop calculating and setting dma_reserve. Signed-off-by: Baoquan He Reviewed-by: Mike Rapoport (IBM) --- arch/x86/include/asm/pgtable.h | 1 - arch/x86/kernel/setup.c | 2 -- arch/x86/mm/init.c | 47 ---------------------------------- 3 files changed, 50 deletions(-) diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h index 315535ffb258..cefc7a84f7a4 100644 --- a/arch/x86/include/asm/pgtable.h +++ b/arch/x86/include/asm/pgtable.h @@ -1200,7 +1200,6 @@ static inline int pgd_none(pgd_t pgd) extern int direct_gbpages; void init_mem_mapping(void); void early_alloc_pgt_buf(void); -extern void memblock_find_dma_reserve(void); void __init poking_init(void); unsigned long init_memory_mapping(unsigned long start, unsigned long end, pgprot_t prot); diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c index ef206500ed6f..74873bd04ad1 100644 --- a/arch/x86/kernel/setup.c +++ b/arch/x86/kernel/setup.c @@ -1106,8 +1106,6 @@ void __init setup_arch(char **cmdline_p) */ arch_reserve_crashkernel(); - memblock_find_dma_reserve(); - if (!early_xdbc_setup_hardware()) early_xdbc_register_console(); diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c index 679893ea5e68..615f0bf4bda6 100644 --- a/arch/x86/mm/init.c +++ b/arch/x86/mm/init.c @@ -990,53 +990,6 @@ void __init free_initrd_mem(unsigned long start, unsigned long end) } #endif -/* - * Calculate the precise size of the DMA zone (first 16 MB of RAM), - * and pass it to the MM layer - to help it set zone watermarks more - * accurately. - * - * Done on 64-bit systems only for the time being, although 32-bit systems - * might benefit from this as well. - */ -void __init memblock_find_dma_reserve(void) -{ -#ifdef CONFIG_X86_64 - u64 nr_pages = 0, nr_free_pages = 0; - unsigned long start_pfn, end_pfn; - phys_addr_t start_addr, end_addr; - int i; - u64 u; - - /* - * Iterate over all memory ranges (free and reserved ones alike), - * to calculate the total number of pages in the first 16 MB of RAM: - */ - nr_pages = 0; - for_each_mem_pfn_range(i, MAX_NUMNODES, &start_pfn, &end_pfn, NULL) { - start_pfn = min(start_pfn, MAX_DMA_PFN); - end_pfn = min(end_pfn, MAX_DMA_PFN); - - nr_pages += end_pfn - start_pfn; - } - - /* - * Iterate over free memory ranges to calculate the number of free - * pages in the DMA zone, while not counting potential partial - * pages at the beginning or the end of the range: - */ - nr_free_pages = 0; - for_each_free_mem_range(u, NUMA_NO_NODE, MEMBLOCK_NONE, &start_addr, &end_addr, NULL) { - start_pfn = min_t(unsigned long, PFN_UP(start_addr), MAX_DMA_PFN); - end_pfn = min_t(unsigned long, PFN_DOWN(end_addr), MAX_DMA_PFN); - - if (start_pfn < end_pfn) - nr_free_pages += end_pfn - start_pfn; - } - - set_dma_reserve(nr_pages - nr_free_pages); -#endif -} - void __init zone_sizes_init(void) { unsigned long max_zone_pfns[MAX_NR_ZONES];