From patchwork Mon Mar 18 14:21:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13595399 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 D170DC54E58 for ; Mon, 18 Mar 2024 14:21:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3F9A26B0087; Mon, 18 Mar 2024 10:21:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3AAD96B0088; Mon, 18 Mar 2024 10:21:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 24A926B0089; Mon, 18 Mar 2024 10:21:57 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 10E4F6B0087 for ; Mon, 18 Mar 2024 10:21:57 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id E06011A0EFE for ; Mon, 18 Mar 2024 14:21:56 +0000 (UTC) X-FDA: 81910373832.03.5AD071C Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf24.hostedemail.com (Postfix) with ESMTP id 3643D18002D for ; Mon, 18 Mar 2024 14:21:54 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=jNEgGlwe; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf24.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1710771715; 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=XJOj3+4C3poxnpNPxWTMxrcMSQ1iTdDLFjOZc5Aa/AQ=; b=dwzkDmUXFvdEEjZ2efRMQRJD8DbGo3IYh834ytG4lc77OcUFyLj7qHQFcwkMIDE3LJxKqc cDIK1a4zWC5QUhsjp2cii3Q4prIqT5XL+59oRQuOzKVaOuLRXLw9Pz8OhOIqmEXl9Cz2rk CY3sYEzTTzn1X+pV3hctuelWAEBgFIY= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=jNEgGlwe; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf24.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1710771715; a=rsa-sha256; cv=none; b=QsKrMMS+7Z+czW+FJ0urTg5mlTvX38xSa4nX7L3/4Xdk1VFFpWM1iQc1NyhzHmiVUeUZpt wMB6m9ar14FgHP+irXxJa0HLQDbsKJo0AYW1UG0vOPW0CVOwERHZA3v/sVb73BAOiRl0rX 3CB4Y+VWKC98OauxuL4aS5FXY7rxeok= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710771714; 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=XJOj3+4C3poxnpNPxWTMxrcMSQ1iTdDLFjOZc5Aa/AQ=; b=jNEgGlwemU3T2M1tk2uTLou5n8uloB6LrPKJwIbOEOZr3/L47HwN7z8BifNCQoSSys8tb+ PTIEIt2BatxQ/ZnvI/F6I2s4p3U/lm9CDRZM19HIskIbzeczVV9pomH1FVN8mbPOrZdTLH 3M2psUregHUESQzeAYb+BaZSqb2x0Hs= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-534-jIm9PpjXNxK1eCnTJrVipA-1; Mon, 18 Mar 2024 10:21:53 -0400 X-MC-Unique: jIm9PpjXNxK1eCnTJrVipA-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (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 8B2A8380009C; Mon, 18 Mar 2024 14:21:52 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (unknown [10.72.116.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9F74A492BD1; Mon, 18 Mar 2024 14:21:49 +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 1/6] mm/mm_init.c: remove the useless dma_reserve Date: Mon, 18 Mar 2024 22:21:33 +0800 Message-ID: <20240318142138.783350-2-bhe@redhat.com> In-Reply-To: <20240318142138.783350-1-bhe@redhat.com> References: <20240318142138.783350-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.10 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 3643D18002D X-Stat-Signature: nhhtbp5wchkbceeyhga4jqqq61wj7gnn X-HE-Tag: 1710771714-3416 X-HE-Meta: U2FsdGVkX1/DPrs0rMMX0hXJRgJYHH7ZodNLaNemRsXxnatuH1c3J1Y6spJQ7aBQTmVWTQCqai+Oit5izrlnr8vGeCmAQD6PTwuadk0vEWxAVsyPUOVxudaEVa8OMStQbdHTpy43xLf9nyemaYXqThm2gZMS9yYMpt9LvaPwzgZmO2Em0kwoRYkv+UOJuG4JzZZcpiHzXAm6mhcJ0T2BYdts09/XtHNMCxCSK32DYLlpbQxeK8RMt4Vqg/Bc07FcepMWw1klkBlHsXUH+NP2Mvh5AKYJkbWFEODd1nXwloLmglrdc5RAQn/slY/bF18TYqn1T3+BgTT6RLiHNqIA9g2+d2H3C1AMQQCFCWykLAko4rcProyYfaUoUwc1rdMPBwDvulMvgvkNmTHqm4/I5wmMded/1n/TAaeZCWjq11axV18CVVOFPH3ExPaDVe3w/QS0cRY+ezACv6s9xEE21bcVpdpgNAwlTsLmf+mB44UegHlXk8sSIDmi633wuQO8AMXc4XV/RalVpXUECFtKGDybeG7977UE3B+chJyVBzUgvboBSKhzS3LQaXH6SAy9R/7Qbq5cBDH4qAR7N1z2RSzf6Havb6EZoJjShIjNHqsvBc9+cCafCLZ0WDlED+IKmPko3lZQiuayAkNYlopdn0L4yakVHTJSlohGhvf/kLdhBzU6842m4rPSaxyaiMZa1WJjIzefgeAp8X4FteBdzJ6kQzZW686i+vDp7b8txjfjHOf5ulowtqz1oVznqsl/86oeV9YlxWFtemrhAny+KjE1nlkb1LP+qFueAcSAb6bV+sE+sD5U8uXoxUs2/zY2M0CzVraZimHHTXsHWXjwj8xfDshGD4x1/ISJKOoZGQGOEbLwlVBpqQXHsbTueWGfg63Y+JaOktgFBG1z75xJqhcsjB7DKSJ5WzcTzGTYL7ZGYY5ocCkqKJA/2qF2UTpn 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 dma_reserve and its handling in free_area_init_core() because it's useless and causes confusion. Signed-off-by: Baoquan He --- arch/x86/mm/init.c | 2 -- include/linux/mm.h | 1 - mm/mm_init.c | 23 ----------------------- 3 files changed, 26 deletions(-) diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c index 679893ea5e68..5209549e8192 100644 --- a/arch/x86/mm/init.c +++ b/arch/x86/mm/init.c @@ -1032,8 +1032,6 @@ void __init memblock_find_dma_reserve(void) if (start_pfn < end_pfn) nr_free_pages += end_pfn - start_pfn; } - - set_dma_reserve(nr_pages - nr_free_pages); #endif } diff --git a/include/linux/mm.h b/include/linux/mm.h index 2c0910bc3e4a..1888b1935103 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -3210,7 +3210,6 @@ static inline int early_pfn_to_nid(unsigned long pfn) extern int __meminit early_pfn_to_nid(unsigned long pfn); #endif -extern void set_dma_reserve(unsigned long new_dma_reserve); extern void mem_init(void); extern void __init mmap_init(void); diff --git a/mm/mm_init.c b/mm/mm_init.c index 549e76af8f82..153fb2dc666f 100644 --- a/mm/mm_init.c +++ b/mm/mm_init.c @@ -226,7 +226,6 @@ static unsigned long required_movablecore_percent __initdata; static unsigned long nr_kernel_pages __initdata; static unsigned long nr_all_pages __initdata; -static unsigned long dma_reserve __initdata; static bool deferred_struct_pages __meminitdata; @@ -1583,12 +1582,6 @@ static void __init free_area_init_core(struct pglist_data *pgdat) zone_names[j], memmap_pages, freesize); } - /* Account for reserved pages */ - if (j == 0 && freesize > dma_reserve) { - freesize -= dma_reserve; - pr_debug(" %s zone: %lu pages reserved\n", zone_names[0], dma_reserve); - } - if (!is_highmem_idx(j)) nr_kernel_pages += freesize; /* Charge for highmem memmap if there are enough kernel pages */ @@ -2547,22 +2540,6 @@ void *__init alloc_large_system_hash(const char *tablename, return table; } -/** - * set_dma_reserve - set the specified number of pages reserved in the first zone - * @new_dma_reserve: The number of pages to mark reserved - * - * The per-cpu batchsize and zone watermarks are determined by managed_pages. - * In the DMA zone, a significant percentage may be consumed by kernel image - * and other unfreeable allocations which can skew the watermarks badly. This - * function may optionally be used to account for unfreeable pages in the - * first zone (e.g., ZONE_DMA). The effect will be lower watermarks and - * smaller per-cpu batchsize. - */ -void __init set_dma_reserve(unsigned long new_dma_reserve) -{ - dma_reserve = new_dma_reserve; -} - void __init memblock_free_pages(struct page *page, unsigned long pfn, unsigned int order) {