From patchwork Sat Mar 11 00:38:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Berger X-Patchwork-Id: 13170542 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 21E17C6FD19 for ; Sat, 11 Mar 2023 00:40:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B13916B0072; Fri, 10 Mar 2023 19:40:04 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id AC1218E0008; Fri, 10 Mar 2023 19:40:04 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8ECE48E0007; Fri, 10 Mar 2023 19:40:04 -0500 (EST) 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 7F5D36B0072 for ; Fri, 10 Mar 2023 19:40:04 -0500 (EST) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 57594A0185 for ; Sat, 11 Mar 2023 00:40:04 +0000 (UTC) X-FDA: 80554760328.16.BE5DC97 Received: from mail-qv1-f42.google.com (mail-qv1-f42.google.com [209.85.219.42]) by imf26.hostedemail.com (Postfix) with ESMTP id 8C9B0140003 for ; Sat, 11 Mar 2023 00:40:02 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=QuGf7CPV; spf=pass (imf26.hostedemail.com: domain of opendmb@gmail.com designates 209.85.219.42 as permitted sender) smtp.mailfrom=opendmb@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1678495202; 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=i8Ej0xERH/saZ/pDi1cj12vURZcx4JMPO5LgIvCru00=; b=3Rf40WrtY7eB9XMp/xVmlp1It8xT0ScKauK7MSrUO1uPtluZeDWq9KA+u+xLzyMDtAwxZa ePJLx89Md6y2+37TfmYy6USrOI7MNJmgVgg4PyfRxlFOCPu8osZEPnxh+vT2xxxMgAWhzk vB7WRL1eLq4w/zy7ZbzxHh70NYJNASI= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=QuGf7CPV; spf=pass (imf26.hostedemail.com: domain of opendmb@gmail.com designates 209.85.219.42 as permitted sender) smtp.mailfrom=opendmb@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1678495202; a=rsa-sha256; cv=none; b=0Z+hxwJLj+YavsgHdX2n8qoKJSqxiw3Pm6rEn8mUIfh8cmo4wQMh+xG5NDOFQAVvNCGbKF Ke32TENWimAZFbRdguyLaXE3B6y+o6c94VJgB+p0DR425mpqx80TiKNW/ZCxbaczUFWDzv d+b08GL8Tlq+x4qK67AjjugMzysAM3o= Received: by mail-qv1-f42.google.com with SMTP id jl13so832581qvb.10 for ; Fri, 10 Mar 2023 16:40:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678495201; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=i8Ej0xERH/saZ/pDi1cj12vURZcx4JMPO5LgIvCru00=; b=QuGf7CPVoKCsHOOIjm2NK5cjpLghKA1j7kJ/1K741bb8Tjt2zne1lcBoQKG5RZFaLH d+9iDxF3djo9jXBNdij0VGTP6ZY1SP8dGV2Shkve2mUoxGpnaN76uokoWkwI7LKRvxaz KF+uFAAEj6TJzhXi7bf5vxZsTi5W+CbUoaBE2wno33o87jXYbrldRxk4635GHPh9JKm9 VfG5OUzjlwFRg/KWjFtjZSd0w2xGePXLgufWztrOsXM8yCuJbytBX4lGLAtjafBKNG5q fVvaqQHAnJwIYiTQug11IA0ltwfKKzu0TeoRULLmWlo061rrvJL/iDxv+7SOUACOFXta PEiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678495202; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=i8Ej0xERH/saZ/pDi1cj12vURZcx4JMPO5LgIvCru00=; b=U7tdylpEl2RbFxDRIu+VH69kwjdQg0knh1XqtUZjiV/B0+kNEk7hPcp2bvF+P5cgul 6XLAqntDfdv2nlXmtUvsCzDifxWUmKIDlZhxa0zjf7wiqJ8U97xu0NlpX88R/jr9r9m1 F0RDx+Z1vNLBQkHTzMqwLG1tjVfyQjD434YYgrjJmTh6zucPO2XBmEeaf6izXZ6+mBZK /KbRT4XwXY9HpbHKljwzaDKnUMEIeqOnQv7xDK1Ax0RB4HnyfXLNQ1mvGdj+HXubcqVJ jP3v5j8qAFPMdp6TALD9kLXpXKc7Q8L6RAuGDcc4wVzLNlGzuMxb82po5UQy0LBdFKw9 ywxQ== X-Gm-Message-State: AO0yUKW58KtKGryvH0CFVEkdoXPrQ1azweQUJxml7hh4aQil52OqLgN+ gUkcqBpyRkif4MjccH03nYA= X-Google-Smtp-Source: AK7set/lVXoZ5W4bIAwoTLxlwAsTqWdy1gsFvdTIDfjsCCmW6gc1QRgTGtZT2GQJIiWjAJ6Nsll19w== X-Received: by 2002:a05:6214:124b:b0:5a1:d44:79a7 with SMTP id r11-20020a056214124b00b005a10d4479a7mr1926784qvv.20.1678495201744; Fri, 10 Mar 2023 16:40:01 -0800 (PST) Received: from stbirv-lnx-1.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id a5-20020ac84345000000b003bfaff2a6b9sm868874qtn.10.2023.03.10.16.39.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Mar 2023 16:40:01 -0800 (PST) From: Doug Berger To: Andrew Morton Cc: Jonathan Corbet , Mike Rapoport , Borislav Petkov , "Paul E. McKenney" , Randy Dunlap , Neeraj Upadhyay , Damien Le Moal , Kim Phillips , "Steven Rostedt (Google)" , Michal Hocko , Johannes Weiner , Vlastimil Babka , KOSAKI Motohiro , Mel Gorman , Muchun Song , Mike Kravetz , Florian Fainelli , David Hildenbrand , Oscar Salvador , Joonsoo Kim , Sukadev Bhattiprolu , Rik van Riel , Roman Gushchin , Minchan Kim , Chris Goldsworthy , "Georgi Djakov" , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Doug Berger Subject: [PATCH v4 5/9] mm/page_alloc: introduce init_reserved_pageblock() Date: Fri, 10 Mar 2023 16:38:51 -0800 Message-Id: <20230311003855.645684-6-opendmb@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230311003855.645684-1-opendmb@gmail.com> References: <20230311003855.645684-1-opendmb@gmail.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam03 X-Stat-Signature: mqctfnxnads5z77h97hrr9geky4gbch1 X-Rspamd-Queue-Id: 8C9B0140003 X-HE-Tag: 1678495202-305602 X-HE-Meta: U2FsdGVkX1/Gr2RbzfPyH6g4WgeB7jbZeTHvOhug/7aoctxcMo5FVXDMJtZrGYRGIkFowrEke2voberCMl06p0k1qSX1tXGKVmx6K6LA1jheO0EtxbmbOdiOCTSl/FFD6poLpplG8aS3zzV6iKbMQWNCKWxsrSqfpbh5S6LlDQZAuCxeyDY/CLM1Hu7amIfEiEGbFM9Xo0nnfvenXFx3uLIjx2jTVx8FmCELrg0+xpugvwkw3zxh1yB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VBQgJ7nQs3NhRx9PhM2ktbLfyuv0PQspxIqUFJZ0ids14tl7CeBUy1nKr4Bk+Cv5hZTM0v7+M20qNqwdT0qCC9t7nzkfC9aXW5mGfM7RT9U2VSN5WwdUlUIjsvji1vWNW6hnxodbBKTt6NzxLSKlkczfgVEOfTcjcmb8Wh+3XGwGTaEvDJEH2C0PzYbujqvz98aeKP8lmq+koDmdOxiWW/0SrYQSo4aqc1/qm+zalw1htpOPX5oDyS1a968ScCpeTadMVm6rjTuMgHteTqkugGrPUYfd977xo8= 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: Most of the implementation of init_cma_reserved_pageblock() is common to the initialization of any reserved pageblock for use by the page allocator. This commit breaks that functionality out into the new common function init_reserved_pageblock() for use by code other than CMA. The CMA specific code is relocated from page_alloc to the point where init_cma_reserved_pageblock() was invoked and the new function is used there instead. The error path is also updated to use the function to operate on pageblocks rather than pages. Signed-off-by: Doug Berger --- include/linux/gfp.h | 5 +---- mm/cma.c | 15 +++++++++++---- mm/page_alloc.c | 8 ++------ 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/include/linux/gfp.h b/include/linux/gfp.h index 65a78773dcca..a7892b3c436b 100644 --- a/include/linux/gfp.h +++ b/include/linux/gfp.h @@ -361,9 +361,6 @@ extern struct page *alloc_contig_pages(unsigned long nr_pages, gfp_t gfp_mask, #endif void free_contig_range(unsigned long pfn, unsigned long nr_pages); -#ifdef CONFIG_CMA -/* CMA stuff */ -extern void init_cma_reserved_pageblock(struct page *page); -#endif +extern void init_reserved_pageblock(struct page *page); #endif /* __LINUX_GFP_H */ diff --git a/mm/cma.c b/mm/cma.c index a7263aa02c92..cc462df68781 100644 --- a/mm/cma.c +++ b/mm/cma.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include "cma.h" @@ -116,8 +117,13 @@ static void __init cma_activate_area(struct cma *cma) } for (pfn = base_pfn; pfn < base_pfn + cma->count; - pfn += pageblock_nr_pages) - init_cma_reserved_pageblock(pfn_to_page(pfn)); + pfn += pageblock_nr_pages) { + struct page *page = pfn_to_page(pfn); + + set_pageblock_migratetype(page, MIGRATE_CMA); + init_reserved_pageblock(page); + page_zone(page)->cma_pages += pageblock_nr_pages; + } spin_lock_init(&cma->lock); @@ -133,8 +139,9 @@ static void __init cma_activate_area(struct cma *cma) out_error: /* Expose all pages to the buddy, they are useless for CMA. */ if (!cma->reserve_pages_on_error) { - for (pfn = base_pfn; pfn < base_pfn + cma->count; pfn++) - free_reserved_page(pfn_to_page(pfn)); + for (pfn = base_pfn; pfn < base_pfn + cma->count; + pfn += pageblock_nr_pages) + init_reserved_pageblock(pfn_to_page(pfn)); } totalcma_pages -= cma->count; cma->count = 0; diff --git a/mm/page_alloc.c b/mm/page_alloc.c index e574c6a79e2f..da1af678995b 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -2308,9 +2308,8 @@ void __init page_alloc_init_late(void) set_zone_contiguous(zone); } -#ifdef CONFIG_CMA -/* Free whole pageblock and set its migration type to MIGRATE_CMA. */ -void __init init_cma_reserved_pageblock(struct page *page) +/* Free whole pageblock */ +void __init init_reserved_pageblock(struct page *page) { unsigned i = pageblock_nr_pages; struct page *p = page; @@ -2320,14 +2319,11 @@ void __init init_cma_reserved_pageblock(struct page *page) set_page_count(p, 0); } while (++p, --i); - set_pageblock_migratetype(page, MIGRATE_CMA); set_page_refcounted(page); __free_pages(page, pageblock_order); adjust_managed_page_count(page, pageblock_nr_pages); - page_zone(page)->cma_pages += pageblock_nr_pages; } -#endif /* * The order of subdivision here is critical for the IO subsystem.