From patchwork Tue Sep 13 19:55:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Berger X-Patchwork-Id: 12975322 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 DBAB4C54EE9 for ; Tue, 13 Sep 2022 19:58:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 78EC36B0093; Tue, 13 Sep 2022 15:58:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 73E466B0095; Tue, 13 Sep 2022 15:58:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5B8468D0001; Tue, 13 Sep 2022 15:58:47 -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 498CA6B0093 for ; Tue, 13 Sep 2022 15:58:47 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 215A612017A for ; Tue, 13 Sep 2022 19:58:47 +0000 (UTC) X-FDA: 79908125052.28.CC663F2 Received: from mail-qt1-f176.google.com (mail-qt1-f176.google.com [209.85.160.176]) by imf02.hostedemail.com (Postfix) with ESMTP id D09B8800AB for ; Tue, 13 Sep 2022 19:58:46 +0000 (UTC) Received: by mail-qt1-f176.google.com with SMTP id y2so9616387qtv.5 for ; Tue, 13 Sep 2022 12:58:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=Q4ZU5cexm9Q08qLiEijmmMTjwuY3GlJ1Cn90C3bzJMU=; b=DPtm4ok3PSf82mq7JMYxEELlSbe2Rh/g3fQ51ooEmzdbhvAmX7bq1p/PDmYadgyeC1 zi9y/jcGd3D1R6ZJkZ/FQsWIwfFLD+Pb0MJITbf3fgUqnK83ONtjfJ+HMIIxaq6Be8T0 7yW02a5Gpkn6GV6C9TtbKwXcBYYQfckEhhDlRw3kQGNLccCEAsysOi1687eQCVwa1Snz UzUeXpguUoApWzimdM3XamY7zoYoXwniOBrFXnFh1C31eUhw4i9vT9n/3okZ8ZMJuUbE x2Q9CpCURykZLJagLzDO5v/o6/9ctT6KeQ6BSDQrVAvGz6WE7hB0JQGNvnw+QEyD9e4R S75w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=Q4ZU5cexm9Q08qLiEijmmMTjwuY3GlJ1Cn90C3bzJMU=; b=XYBPsAxRTfWT2k2WGcuDZXnhbifg2tmP+IHBgc9nNkG7H9tqlfJHWrMKeGkGm+x1WX XS+JYRMbEMRdTJf0lg+UiYCg6DtPI+UMZX72tawJ/gc5w72pN1pzjYrLwa0Y6RBawR+4 51HRdr2qmM5MwDz5JdvXeR9ZMHijenkBAOPDP3DxArs5erkS7FiGLmCU5ezHs76NBVE2 b+PX1/4VUlLN0Lme/deozQazC6MZ+lulPizs1jd/1eCAYN/7g80kFqZduTu+Tz77IaZC T4lEtgDdC+1T3jC08WJgIx+xU7lfzyRKBAQabU/Qd7DqdcoBQdH1PeV00q8Mgn/b21Cj VAfg== X-Gm-Message-State: ACgBeo3bjnVRQQ925bCi5P95M4Xsv1qMzDWcFTkVMs2sLMkDn+5vT6W3 sATanP6WcEzw8MdTxQDll7Q= X-Google-Smtp-Source: AA6agR79LKnSKwsuEjaHOZbqMf9sDJeff1s7ltAoeOd0yWLYcv6FI23B3yp+SehZLzBtT5Q7988TlQ== X-Received: by 2002:a05:622a:174b:b0:343:1fc:14d8 with SMTP id l11-20020a05622a174b00b0034301fc14d8mr29317695qtk.579.1663099126048; Tue, 13 Sep 2022 12:58:46 -0700 (PDT) Received: from stbirv-lnx-3.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id s11-20020a05620a29cb00b006b8e049cf08sm276305qkp.2.2022.09.13.12.58.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Sep 2022 12:58:45 -0700 (PDT) From: Doug Berger To: Andrew Morton Cc: Jonathan Corbet , Rob Herring , Krzysztof Kozlowski , Frank Rowand , Mike Kravetz , Muchun Song , Mike Rapoport , Christoph Hellwig , Marek Szyprowski , Robin Murphy , Borislav Petkov , "Paul E. McKenney" , Neeraj Upadhyay , Randy Dunlap , Damien Le Moal , Doug Berger , Florian Fainelli , David Hildenbrand , Zi Yan , Oscar Salvador , Hari Bathini , Kees Cook , - , KOSAKI Motohiro , Mel Gorman , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-mm@kvack.org, iommu@lists.linux.dev Subject: [PATCH 14/21] mm/page_alloc: make alloc_contig_pages DMB aware Date: Tue, 13 Sep 2022 12:55:01 -0700 Message-Id: <20220913195508.3511038-15-opendmb@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220913195508.3511038-1-opendmb@gmail.com> References: <20220913195508.3511038-1-opendmb@gmail.com> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1663099126; a=rsa-sha256; cv=none; b=StO7XWXScHF1l+dg15b37BY4Zl1w8nXNsl1UDPM2aKRmkf0Srja/IYS7Ut6LycasYeTmJ4 iDMhmUUBs4HcE/QqBOypWv4EUJhJKysyrEKNL2+Q3ymJWFFj2IWu/sTAYl41lav2/EG1Pf ef4DLeWvwdHiE6Jv5k3NHSa4ky/cBG4= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=DPtm4ok3; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf02.hostedemail.com: domain of opendmb@gmail.com designates 209.85.160.176 as permitted sender) smtp.mailfrom=opendmb@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1663099126; 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=Q4ZU5cexm9Q08qLiEijmmMTjwuY3GlJ1Cn90C3bzJMU=; b=5O/Ju8bAS3KsFFeJLac3KqLiouI/BYI453CKw35onZlDeQdtYDVdKtVMpPIIgRPAsNzCVR hHMcrwLAEOcd4sLMR0qur+dw1W00reeGcOVl0pWmN+srMrb+lqf7TxS2HJR1dhnt82degz SFkq3IIdLyXoyKU8gQaBBTCORvOGeNY= Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=DPtm4ok3; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf02.hostedemail.com: domain of opendmb@gmail.com designates 209.85.160.176 as permitted sender) smtp.mailfrom=opendmb@gmail.com X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: D09B8800AB X-Stat-Signature: 5sii3bkui4348zi36zqgehpyehagr5a7 X-Rspam-User: X-HE-Tag: 1663099126-925498 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: Designated Movable Blocks are skipped when attempting to allocate contiguous pages. Doing per page validation across all spanned pages within a zone can be extra inefficient when Designated Movable Blocks create large overlaps between zones. Use dmb_intersects() within pfn_range_valid_contig as an early check to signal the range is not valid. The zone_movable_pfn array which represents the start of non- overlapped ZONE_MOVABLE on the node is now preserved to be used at runtime to skip over any DMB-only portion of the zone. Signed-off-by: Doug Berger --- mm/page_alloc.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index e723094d1e1e..69753cc51e19 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -435,7 +435,7 @@ static unsigned long required_kernelcore_percent __initdata; static unsigned long required_movablecore __initdata; static unsigned long required_movablecore_percent __initdata; static unsigned long min_dmb_pfn[MAX_NUMNODES] __initdata; -static unsigned long zone_movable_pfn[MAX_NUMNODES] __initdata; +static unsigned long zone_movable_pfn[MAX_NUMNODES]; bool mirrored_kernelcore __initdata_memblock; /* movable_zone is the "real" zone pages in ZONE_MOVABLE are taken from */ @@ -9370,6 +9370,9 @@ static bool pfn_range_valid_contig(struct zone *z, unsigned long start_pfn, unsigned long i, end_pfn = start_pfn + nr_pages; struct page *page; + if (dmb_intersects(start_pfn, end_pfn)) + return false; + for (i = start_pfn; i < end_pfn; i++) { page = pfn_to_online_page(i); if (!page) @@ -9426,7 +9429,10 @@ struct page *alloc_contig_pages(unsigned long nr_pages, gfp_t gfp_mask, gfp_zone(gfp_mask), nodemask) { spin_lock_irqsave(&zone->lock, flags); - pfn = ALIGN(zone->zone_start_pfn, nr_pages); + if (zone_idx(zone) == ZONE_MOVABLE && zone_movable_pfn[nid]) + pfn = ALIGN(zone_movable_pfn[nid], nr_pages); + else + pfn = ALIGN(zone->zone_start_pfn, nr_pages); while (zone_spans_last_pfn(zone, pfn, nr_pages)) { if (pfn_range_valid_contig(zone, pfn, nr_pages)) { /*