From patchwork Thu Oct 20 21:53:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Berger X-Patchwork-Id: 13014055 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 126DFC4332F for ; Thu, 20 Oct 2022 21:54:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A6D6E8E000C; Thu, 20 Oct 2022 17:54:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A1D618E0001; Thu, 20 Oct 2022 17:54:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8BE2C8E000C; Thu, 20 Oct 2022 17:54:46 -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 7EAF98E0001 for ; Thu, 20 Oct 2022 17:54:46 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 6308AA11FD for ; Thu, 20 Oct 2022 21:54:46 +0000 (UTC) X-FDA: 80042682972.03.E49D048 Received: from mail-qk1-f180.google.com (mail-qk1-f180.google.com [209.85.222.180]) by imf11.hostedemail.com (Postfix) with ESMTP id F189C40004 for ; Thu, 20 Oct 2022 21:54:45 +0000 (UTC) Received: by mail-qk1-f180.google.com with SMTP id a18so925120qko.0 for ; Thu, 20 Oct 2022 14:54:45 -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 :message-id:reply-to; bh=cizdPvmJ1B17OrSNKxRqtl13qIriognWBTeBRaDyut8=; b=KB+L2mJLWgHCBesUojexARn3KfzhK2H8uBHU+VHa8RVf7cVaGNVrwuXj5H0u/3lYNt wcRhSDne7ByyOYLA9cvoYeZ3VkJnXDvSNYrN7WLs2Y8egIdBuC1tsxWHa8GuimGAILbi HpD84Z7bldzP6/kQGQaZBJtwCmr8b/q3S10e3mNdrpXjva2ZtAfgkTBffc6/iyI1nZh8 Dkvb6WhFlo7oG5GjOPlOEGO7jqBEgByfJJkRI0qvYtt0VrUgU2wXlz0p4gbq6SsQ+iYg B0OQZMc70gmWoyH7TxZ9cLUl4CmQ26VS1NmykgFEz179lNiZQ6BbQaEEdltfzN3ILZRT GG9A== 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:message-id:reply-to; bh=cizdPvmJ1B17OrSNKxRqtl13qIriognWBTeBRaDyut8=; b=dAUmHeK2/36AUQnq6+8RnW1gbfcfpN1/qHFBeTQ+hNFKBeFjCtR4XPghL1cDG5aRQr +piTnm9yUxePj3BPwOvUElf4ix//pthcUFv5vbvVIu97CiNCInok7XaJvA7LM/1K2Q0K 09vQjqJW5jpPuym8YCi+K5C+++nYXxwGg45XBuu+R741ENibBWyjtxxmv6Sa4TBUDZ3V afQvfKNeBBMqttX/XQMJUdmEW/IfkEnxFEOkLKNlv/bpxVUzgVfGHGP80cPhpf27qlCP qnqO1CXU2C2uI596PvQ/owM9tjta5EYl1QdD5K4kq5WFK389LPvMgS6AZJw+eUVbLd5i UgPw== X-Gm-Message-State: ACrzQf0/dd3XUC+wZLQ7lFqsFoiB41GqieByACcFpE4qjLKaef2BEl8d yRejDJ4lVdzvV9FV10BP06c= X-Google-Smtp-Source: AMsMyM4TfR3bYlmhEQVS3hRsR8tGQaHhGxaCz70N0D3SiJn/URFTRu7Q8Q87qGF4C+fS2BQtoGIQDg== X-Received: by 2002:a05:620a:4510:b0:6ee:e598:a185 with SMTP id t16-20020a05620a451000b006eee598a185mr10499940qkp.765.1666302885214; Thu, 20 Oct 2022 14:54:45 -0700 (PDT) Received: from stbirv-lnx-3.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id bj41-20020a05620a192900b006bb29d932e1sm8121067qkb.105.2022.10.20.14.54.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Oct 2022 14:54:44 -0700 (PDT) From: Doug Berger To: Andrew Morton Cc: Jonathan Corbet , Mike Rapoport , Borislav Petkov , "Paul E. McKenney" , Neeraj Upadhyay , Randy Dunlap , Damien Le Moal , Muchun Song , Vlastimil Babka , Johannes Weiner , Michal Hocko , KOSAKI Motohiro , Mel Gorman , Mike Kravetz , Florian Fainelli , David Hildenbrand , Oscar Salvador , Joonsoo Kim , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Doug Berger Subject: [PATCH v3 8/9] mm/page_alloc: make alloc_contig_pages DMB aware Date: Thu, 20 Oct 2022 14:53:17 -0700 Message-Id: <20221020215318.4193269-9-opendmb@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221020215318.4193269-1-opendmb@gmail.com> References: <20221020215318.4193269-1-opendmb@gmail.com> MIME-Version: 1.0 ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=KB+L2mJL; spf=pass (imf11.hostedemail.com: domain of opendmb@gmail.com designates 209.85.222.180 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=1666302886; a=rsa-sha256; cv=none; b=tjvY9gcxcZXBnWxvcMygGVMisgsgA0BOsme80LQsgkW82GImlKFgdI5f4qJuN973O3zWrb dqy9dmY1t1Hb09Sg1uEFNpbMcA+q4hXu4fnmJGdDiYvUjjs12rK9iLiKQ5oTKhlEiLeyp+ gB8NeKMe4Q2q1B1MmVAvA7jW2aF5Yg0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1666302886; 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=cizdPvmJ1B17OrSNKxRqtl13qIriognWBTeBRaDyut8=; b=aJGwi52oqCRYZi6ngdiA0GX+1oAHky6fciYzgeUY3NZisT90y6P2BzPJqziFIsTyTjZ/G/ JkeY6hW3VVZ3mEGHWaRNlRJevNElcFWBQk0BDlCcWgqTZW9XBNqGx02kC3FbEEoyL5k/Xl CTHQS44DY9P/COVxkwPCm3+/QgmvEVE= Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=KB+L2mJL; spf=pass (imf11.hostedemail.com: domain of opendmb@gmail.com designates 209.85.222.180 as permitted sender) smtp.mailfrom=opendmb@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Stat-Signature: 7y1scdbhyd7xn45m414w86zzjhsorrzc X-Rspamd-Queue-Id: F189C40004 X-Rspamd-Server: rspam02 X-Rspam-User: X-HE-Tag: 1666302885-864937 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 82cad751e0b8..a39eca3bc01b 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -437,7 +437,7 @@ 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 max_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 */ @@ -9460,6 +9460,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) @@ -9516,7 +9519,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)) { /*