Received: by 2002:a05:7412:7c14:b0:fa:6e18:a558 with SMTP id ii20csp329984rdb; Mon, 22 Jan 2024 05:45:05 -0800 (PST) X-Google-Smtp-Source: AGHT+IFkfUSciVt77pakmmk6W2qqkQ6zvTBcA0yfyKl3mQw5ai9KUpuERU+gumul2834Y2VtqVnv X-Received: by 2002:a92:d086:0:b0:35f:f383:ac7b with SMTP id h6-20020a92d086000000b0035ff383ac7bmr6554489ilh.16.1705931104855; Mon, 22 Jan 2024 05:45:04 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705931104; cv=pass; d=google.com; s=arc-20160816; b=uhCuP8xWt+0TgEFLsX/n4IdGI11z4XGStD5jnlTPv4SYkLX3BhvVHJ8HT1jKjWdpOF 5jO/atwFm/jiuGx0n14YE4RffR8vVFqyK9Y0Kj9H7vVd8/dXczJAefHj3u1FsHNAZGDY KG/cABGTEr9swb8Zqxb/EOV1sT1MO7Kr6G9iIVVqyt4UqNcqi2shP6q2FlG6qXCMX6Py nLNQkjcb7OqfaX0nTmBUes1pds5x7OOowL4Mzv5JNfGrrstP1StlqWi5rC8WT69i0a78 DourgiPjELbMdy4jOCLAeDkPVDXGB/RIe+WBRhel7bCQymAkR0ms1c1vJR1mom7CO8Q1 k8Ww== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from; bh=Awqm017N7vQFp4JrgKRCbTmtieueFVH0lrkzBTkrwqY=; fh=d9pJCX5vSK094y0UIO2X0tiUx0EnU/0Eu+L/hdtnuUA=; b=Lq9HjQKraIMOOgxJX9TZkefRWKC37AcO6xsZNOVsev+lqW1pHL1TrLoGeqQH621VLy lKGNVBmeFo12l1E3Bidn8O9AwW4yZ9OYMlmRIO6RoraXFGKVVwgIgz3/L8TZXIKO0noY qRpe2ogJqJJdVreJmuHUPmSIeGuCYb6WP+ChXgBZScBperHBQWUIgo4ROVJzP8UbWqYu JrBM08u8x33BK7kuUIolO1hgqGHPptwhBx6jsB71HezNrfPm2SJD7DGVOgj+r2+9rNBa pdFvoHeaDJMgLmvt7maNg653mxgUtNG12Wm8gxBbx/O/aTMiz1WRvF3zmsr5Y5vdff75 vIYg== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=linux.alibaba.com dmarc=pass fromdomain=linux.alibaba.com); spf=pass (google.com: domain of linux-kernel+bounces-33063-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-33063-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id o12-20020a656a4c000000b005cde435ff91si8326489pgu.878.2024.01.22.05.45.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jan 2024 05:45:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-33063-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=linux.alibaba.com dmarc=pass fromdomain=linux.alibaba.com); spf=pass (google.com: domain of linux-kernel+bounces-33063-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-33063-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id CFF3DB25DF3 for ; Mon, 22 Jan 2024 13:02:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C65D63CF62; Mon, 22 Jan 2024 13:02:10 +0000 (UTC) Received: from out30-97.freemail.mail.aliyun.com (out30-97.freemail.mail.aliyun.com [115.124.30.97]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 38C033CF54 for ; Mon, 22 Jan 2024 13:02:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.97 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705928530; cv=none; b=sFDS1+SgzDhNYNf2+IuoGE3PVcXPj17Thucjr6sGW23E0e0GMs5ycS3tYryLqZXByNdgzMvYA8e2FJpaBAtvwBx96e4yRxQMke2tRzcxK6eUOTCvDbuas1GqrW5PsPCkxndZ94qbH7fo64O6MH0cFqb+Z6gaBLHZhMTt9zIB7kU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705928530; c=relaxed/simple; bh=Vn4PVyIT4D0ggBEBiZMoEVPYf37DU55xxBmCF2O+1lk=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=cWVy2WfbNw9elX97skL67y1lrwmH34IZ/flodb/dzVT4Xp2Sy1IU+IISXiYJy+9mdQ77oyrOisICtD5pSwY3QLY640gi7sYLjFWoOOh8YG+u2ATfytWTHeSvzt/gkFriNANXzZU4d1KtsZBi4EDcmcQwTbB6hVRufaxUQroFm8A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; arc=none smtp.client-ip=115.124.30.97 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R771e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045170;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=6;SR=0;TI=SMTPD_---0W.9DBn2_1705928520; Received: from localhost(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0W.9DBn2_1705928520) by smtp.aliyun-inc.com; Mon, 22 Jan 2024 21:02:01 +0800 From: Baolin Wang To: akpm@linux-foundation.org Cc: mgorman@techsingularity.net, vbabka@suse.cz, baolin.wang@linux.alibaba.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] mm: compaction: limit the suitable target page order to be less than cc->order Date: Mon, 22 Jan 2024 21:01:53 +0800 Message-Id: X-Mailer: git-send-email 2.39.3 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit It can not improve the fragmentation if we isolate the target free pages exceeding cc->order, especially when the cc->order is less than pageblock_order. For example, suppose the pageblock_order is MAX_ORDER (size is 4M) and cc->order is 2M THP size, we should not isolate other 2M free pages to be the migration target, which can not improve the fragmentation. Moreover this is also applicable for large folio compaction. Signed-off-by: Baolin Wang --- mm/compaction.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mm/compaction.c b/mm/compaction.c index 27ada42924d5..066b72b3471a 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -1346,12 +1346,14 @@ static bool suitable_migration_target(struct compact_control *cc, { /* If the page is a large free page, then disallow migration */ if (PageBuddy(page)) { + int order = cc->order > 0 ? cc->order : pageblock_order; + /* * We are checking page_order without zone->lock taken. But * the only small danger is that we skip a potentially suitable * pageblock, so it's not worth to check order for valid range. */ - if (buddy_order_unsafe(page) >= pageblock_order) + if (buddy_order_unsafe(page) >= order) return false; } -- 2.39.3