From patchwork Fri Nov 27 14:19:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muchun Song X-Patchwork-Id: 11936417 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C75BDC63798 for ; Fri, 27 Nov 2020 14:19:15 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E29262223D for ; Fri, 27 Nov 2020 14:19:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=bytedance-com.20150623.gappssmtp.com header.i=@bytedance-com.20150623.gappssmtp.com header.b="aDNLbwXm" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E29262223D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=bytedance.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 075C36B005C; Fri, 27 Nov 2020 09:19:14 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 026766B006C; Fri, 27 Nov 2020 09:19:13 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E7E5E6B006E; Fri, 27 Nov 2020 09:19:13 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0195.hostedemail.com [216.40.44.195]) by kanga.kvack.org (Postfix) with ESMTP id D2DE66B005C for ; Fri, 27 Nov 2020 09:19:13 -0500 (EST) Received: from smtpin25.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 7C6253626 for ; Fri, 27 Nov 2020 14:19:13 +0000 (UTC) X-FDA: 77530405386.25.chalk95_4e119de27388 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin25.hostedemail.com (Postfix) with ESMTP id 9184B1804E3BB for ; Fri, 27 Nov 2020 14:19:12 +0000 (UTC) X-HE-Tag: chalk95_4e119de27388 X-Filterd-Recvd-Size: 5666 Received: from mail-pf1-f194.google.com (mail-pf1-f194.google.com [209.85.210.194]) by imf05.hostedemail.com (Postfix) with ESMTP for ; Fri, 27 Nov 2020 14:19:11 +0000 (UTC) Received: by mail-pf1-f194.google.com with SMTP id e8so4729938pfh.2 for ; Fri, 27 Nov 2020 06:19:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=ZVrd6qs4ki2UlD5jguyTyXf7x5AtIUQVbvxCxPiXfO0=; b=aDNLbwXmYnolsPDaydC++XyPfDwRIFKddL8MhZ3YwIlBZaLqYvleF/yDFEj4d76t7l oNYpJMwMQV/8jTi1A4YNWeeb0KWuoMWn+F2II6Z8/9aNgA0xhkmV93kBnHSQBqwWZDQo ZsVZvpJIebdADw8olIZ1x2TCPfRZoAVPmHSxZo2s6X+C7IQrf7AQhQBB1JiceDo2cDWg SpxabpvYsVtqkn+EHy9q4RlyPj4BKzybOQt3N/TG7VzoPTBM41FBahaRX8vFNl72ndg7 vTnI97WKczdYrOxgHsRdiPnaiXa8bU0pQdNAuX79oMlwaNDZE0EHMBxmB3k96SRQy1as 33oQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=ZVrd6qs4ki2UlD5jguyTyXf7x5AtIUQVbvxCxPiXfO0=; b=SEYQQC+mhdmTz3aRkTgwwVcNjG3hylrGMpApyliIncnPpdqvhC1mSEoRI3vgQklMAo noQeGZRISv98sOgRYOmRD8Cq2c1mxvWIAIQmKKxKLKCBwC6hGmjgRzkS2pwYlCobdh8P HJbFrGy8AGwP5F4Okec0ltt9Ed3jB6jQr4VQo1JOPqnMBiKm5pjLvY7XgGpq0/eZ83Gw p/H9n4/ab7EY/OqU1HBnYTvGhUjmCgJh6UMn0JAw7UG0ka3hD9f8f6VjB71ezwm0QY8X LyyKI56wNdAuFQ0smqECutMesrGJqA2hQy6hwOW4KWtKUMIH+bToVKvSS2s8qCEPXL1Q Km+w== X-Gm-Message-State: AOAM530Kp5U+NS5BUula+x5w5s5Q7oWZdpovTNjv+swtnQptdlY3fXiY Wy6aknxPa3aJIu9pXNgf0m9iyw== X-Google-Smtp-Source: ABdhPJyYuKLf2waW3TRKRuKyMAOfAM66cBhkMb6c6Sr5LP/M7lAjsaZB95K7oeA4k3fWyXHCIaxInA== X-Received: by 2002:a63:4a0e:: with SMTP id x14mr6853146pga.376.1606486749013; Fri, 27 Nov 2020 06:19:09 -0800 (PST) Received: from localhost.bytedance.net ([103.136.220.120]) by smtp.gmail.com with ESMTPSA id z126sm7945117pfz.120.2020.11.27.06.19.06 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 27 Nov 2020 06:19:08 -0800 (PST) From: Muchun Song To: akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Muchun Song Subject: [PATCH] mm/page_alloc: Do not isolate redundant pageblock Date: Fri, 27 Nov 2020 22:19:00 +0800 Message-Id: <20201127141900.43348-1-songmuchun@bytedance.com> X-Mailer: git-send-email 2.21.0 (Apple Git-122) MIME-Version: 1.0 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: Current pageblock isolation logic could isolate each pageblock individually since commit d9dddbf55667 ("mm/page_alloc: prevent merging between isolated and other pageblocks"). So we not need to concern about page allocator merges buddies from different pageblocks and changes MIGRATE_ISOLATE to some other migration type. Signed-off-by: Muchun Song --- mm/page_alloc.c | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index cefbef32bf4a..608a2c2b8ab7 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -8313,16 +8313,14 @@ struct page *has_unmovable_pages(struct zone *zone, struct page *page, } #ifdef CONFIG_CONTIG_ALLOC -static unsigned long pfn_max_align_down(unsigned long pfn) +static unsigned long pfn_align_down(unsigned long pfn) { - return pfn & ~(max_t(unsigned long, MAX_ORDER_NR_PAGES, - pageblock_nr_pages) - 1); + return pfn & ~(pageblock_nr_pages - 1); } -static unsigned long pfn_max_align_up(unsigned long pfn) +static unsigned long pfn_align_up(unsigned long pfn) { - return ALIGN(pfn, max_t(unsigned long, MAX_ORDER_NR_PAGES, - pageblock_nr_pages)); + return ALIGN(pfn, pageblock_nr_pages); } /* [start, end) must belong to a single zone. */ @@ -8415,14 +8413,6 @@ int alloc_contig_range(unsigned long start, unsigned long end, INIT_LIST_HEAD(&cc.migratepages); /* - * What we do here is we mark all pageblocks in range as - * MIGRATE_ISOLATE. Because pageblock and max order pages may - * have different sizes, and due to the way page allocator - * work, we align the range to biggest of the two pages so - * that page allocator won't try to merge buddies from - * different pageblocks and change MIGRATE_ISOLATE to some - * other migration type. - * * Once the pageblocks are marked as MIGRATE_ISOLATE, we * migrate the pages from an unaligned range (ie. pages that * we are interested in). This will put all the pages in @@ -8438,8 +8428,8 @@ int alloc_contig_range(unsigned long start, unsigned long end, * put back to page allocator so that buddy can use them. */ - ret = start_isolate_page_range(pfn_max_align_down(start), - pfn_max_align_up(end), migratetype, 0); + ret = start_isolate_page_range(pfn_align_down(start), pfn_align_up(end), + migratetype, 0); if (ret) return ret; @@ -8522,8 +8512,8 @@ int alloc_contig_range(unsigned long start, unsigned long end, free_contig_range(end, outer_end - end); done: - undo_isolate_page_range(pfn_max_align_down(start), - pfn_max_align_up(end), migratetype); + undo_isolate_page_range(pfn_align_down(start), pfn_align_up(end), + migratetype); return ret; } EXPORT_SYMBOL(alloc_contig_range);