From patchwork Wed Dec 2 12:18:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muchun Song X-Patchwork-Id: 11945903 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 8FEF4C64E8A for ; Wed, 2 Dec 2020 12:20:26 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C1C31221FE for ; Wed, 2 Dec 2020 12:20:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C1C31221FE 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 C879C8D0003; Wed, 2 Dec 2020 07:20:24 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C36BA8D0002; Wed, 2 Dec 2020 07:20:24 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B26208D0003; Wed, 2 Dec 2020 07:20:24 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0170.hostedemail.com [216.40.44.170]) by kanga.kvack.org (Postfix) with ESMTP id 99D588D0002 for ; Wed, 2 Dec 2020 07:20:24 -0500 (EST) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 572143631 for ; Wed, 2 Dec 2020 12:20:24 +0000 (UTC) X-FDA: 77548249968.19.shame85_210bc1d273b3 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin19.hostedemail.com (Postfix) with ESMTP id 2559B1AD1BA for ; Wed, 2 Dec 2020 12:20:24 +0000 (UTC) X-HE-Tag: shame85_210bc1d273b3 X-Filterd-Recvd-Size: 4048 Received: from mail-pl1-f193.google.com (mail-pl1-f193.google.com [209.85.214.193]) by imf10.hostedemail.com (Postfix) with ESMTP for ; Wed, 2 Dec 2020 12:20:23 +0000 (UTC) Received: by mail-pl1-f193.google.com with SMTP id k5so1028271plt.6 for ; Wed, 02 Dec 2020 04:20:23 -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=7FKe5u39kZa3azkaY3U9g1f4IsOfUHKX7jY6pnUAmOY=; b=V3xlJkKZ70acNNBym+d6CYtKp1yDDc4ID6bmQ6KHu8jjBR61rLRA/1N/Ch62RjkzT8 SB0iV7jebdkFq/+sFyWs4GSTf3g+I6R4qkhXUXPAdC7UPrV9Jspern7G72Baamtx0fhf 1D2RTFqb9VExlgYlhkSeu1u9U0pMVXt+D17FGVhDmilkOKAMOUeeD+7omPQMztjpd3yS RGAI3GKCD3b/DrvlNiHWNiD4L4scifVM1cm0pe8CswTLjofiaIkPqZn9cTPxqOlgwrvf 1xBLgBsjdwVOZu2S8xqnpULrVGBeJ6EFhJrNJiltJiX9FuH0AQHSTS1/FtsSkPoXgomm mTnA== 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=7FKe5u39kZa3azkaY3U9g1f4IsOfUHKX7jY6pnUAmOY=; b=STzohj4c4xix4+9ctznop0HFKH6YvhwwTeLl54OyK6TVYoWcIBZq616boT3R07YVmm C05wY9Ha2iaZKhcMInG/QYj2fyE1IWL7brhnJvNUYNl6sAMZV2rXSJcQmt3PJo+4PO2m PgGHNd0N1HRfdF+zI/fKSLc5Wioz0c1L6eraKF8EPM9qgKr3Vs8r+OXOK37MGpAAES18 SyN1AWSKHt57HF4f5P+ldkkoQcE3KYudGfMFhty9rLy/w1ErmEcKgdcdrOBJzm6rNcRo vMRE7IZcAYCzFBVajiHftKQ78lb3eCTvBo7A4CiEzDhKtljxEDoB3i444ab5aLtgzrwQ FyKA== X-Gm-Message-State: AOAM533I1sZrwEPiC61yQFnDmBYb67vWJT2xbiSAQ7pU56vrtF5dkD83 EPTAG6WbKGRXGwb+cUyGCSWLIg== X-Google-Smtp-Source: ABdhPJysL+XklWYuRtEfA6QYEVT41b0A/ZoAWdmup3o7oQPNXQ9BGs9HvZUlvd5q/8z49Sg10YEijg== X-Received: by 2002:a17:90a:f0c1:: with SMTP id fa1mr1963337pjb.148.1606911622703; Wed, 02 Dec 2020 04:20:22 -0800 (PST) Received: from localhost.localdomain ([103.136.221.70]) by smtp.gmail.com with ESMTPSA id d68sm2320129pfc.135.2020.12.02.04.20.20 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 02 Dec 2020 04:20:22 -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: speeding up the iteration of max_order Date: Wed, 2 Dec 2020 20:18:38 +0800 Message-Id: <20201202121838.75218-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.000004, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: When we free a page whose order is very close to MAX_ORDER and greater than pageblock_order, it wastes some CPU cycles to increase max_order to MAX_ORDER one by one and check the pageblock migratetype of that page repeatedly especially when MAX_ORDER is much larger than pageblock_order. Signed-off-by: Muchun Song --- mm/page_alloc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 141f12e5142c..959541234e1d 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -1041,7 +1041,7 @@ static inline void __free_one_page(struct page *page, pfn = combined_pfn; order++; } - if (max_order < MAX_ORDER) { + if (max_order < MAX_ORDER && order < MAX_ORDER - 1) { /* If we are here, it means order is >= pageblock_order. * We want to prevent merge between freepages on isolate * pageblock and normal pageblock. Without this, pageblock @@ -1062,6 +1062,8 @@ static inline void __free_one_page(struct page *page, is_migrate_isolate(buddy_mt))) goto done_merging; } + if (unlikely(order != max_order - 1)) + max_order = order + 1; max_order++; goto continue_merging; }