Received: by 2002:ab2:7407:0:b0:1f4:b336:87c4 with SMTP id e7csp202252lqn; Thu, 11 Apr 2024 20:37:13 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWctkR2isGFOagtTtilQFE6Orc/aMOcUJ2tUPM0Sb2QC5Ked4u/Lff43suvdsFCM//TTF+NCY0i5NKcd5UotIfnBMuBIRxY8aw5gRgrNA== X-Google-Smtp-Source: AGHT+IHHNfj7ko3c4b9rTgq24CHFiiiC9uwK5ljT3szdbdpKsYb03EYLYUY8wjOxRUpImmC++NdH X-Received: by 2002:a9d:7b4c:0:b0:6ea:2b3a:f389 with SMTP id f12-20020a9d7b4c000000b006ea2b3af389mr1336389oto.29.1712893033669; Thu, 11 Apr 2024 20:37:13 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712893033; cv=pass; d=google.com; s=arc-20160816; b=AN8QCOH9LExn42shEyieYjD81BDNaB8FS+GV+SFkOsAU2bfM3zHNVSrGHG/2UhiKvK Av4F45ntfXlX8PB4o/bEgUxOTQVfUxyY1Ga7RSHSAFdWOKWrEx5PJuaYDeMmlkFRl06h 9oKLFMPtgALkyufX1WnvCe6q1tLAHfTtIIUStXbrMtiuK/q3KCQSQ58qhs5luSI3r9q7 GwBVI31tBQKFy1zl3gFjzRU/TBnpURGp3lOEtftJ1IuuLncn7IY6D6sBkBr5DcRDMnOM FSC9boNdE9NYsefjWaU1JdlVVYYCm1WYd0pgs9a4LX+xO563k4VuuKzkM4E7tz0S7H8g soEA== 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:dkim-signature; bh=2fkGS+MFyueb1gRjvWZU73/oYEQkBz+kgZl5y/+I3Ww=; fh=OV35JJom4tBQLf6UAzXyaXZ4MOPLJhXBnO18Fr+SA24=; b=nVs0bp94QBrMXcODteUbyEvSN7bLh0YJToP9Dx2Aq2VDYWB/l/CylXGUjWVJi0mSeh 5lAAPBbrT1utEsjCjrPRoDbtP/mxKniHb41H4i9V3qbI9g35Zl424/sKLksEQlMXHHaP VZgS+Y2Mo4d3k4epNTetP1e5J1eO9Ym7GPej5gPCWAa2+8myJnWOTzHULOVUvLyeW1is 8g0XiFZpIe49vyE6bZqNkPQvKfxN9ye4C7L/n2ErLMdRJ/Q+rH0rMOKM0kgnv7kOMSim /EHo2ozTzZ+oFScfKAY/U47i1DmBIPuERgzd8eU3BQJ/IFRCo0Mqh+wCLwDBw5gacter BXsQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.alibaba.com header.s=default header.b=XGElWPrJ; arc=pass (i=1 spf=pass spfdomain=linux.alibaba.com dkim=pass dkdomain=linux.alibaba.com dmarc=pass fromdomain=linux.alibaba.com); spf=pass (google.com: domain of linux-kernel+bounces-141869-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-141869-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.alibaba.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 33-20020a630b21000000b005d8e38097ffsi2374705pgl.715.2024.04.11.20.37.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Apr 2024 20:37:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-141869-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.alibaba.com header.s=default header.b=XGElWPrJ; arc=pass (i=1 spf=pass spfdomain=linux.alibaba.com dkim=pass dkdomain=linux.alibaba.com dmarc=pass fromdomain=linux.alibaba.com); spf=pass (google.com: domain of linux-kernel+bounces-141869-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-141869-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 80F33286CF0 for ; Fri, 12 Apr 2024 03:27:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A4C7B18637; Fri, 12 Apr 2024 03:27:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b="XGElWPrJ" Received: from out30-113.freemail.mail.aliyun.com (out30-113.freemail.mail.aliyun.com [115.124.30.113]) (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 EECFC182A0 for ; Fri, 12 Apr 2024 03:27:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.113 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712892447; cv=none; b=ORe3fdjFxo4jLbotNQhhn4H+DVt2RKu71sJ155i9jq+aL2vjfMmjK8edO/8Iqi+JrUevQniLS3NijbuuMdAtl6SSH6VwqSetz7mwkK2LmhIPZwn6Mi9IFfX6BXAfKh1f+nbCoaNRf92DfczaSPtE8bG2XRXQ/bzCjtWteukrFJo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712892447; c=relaxed/simple; bh=GWOD0bD2dppJxnqtOWFxf0FDtRoj+5Os0vJNDbYJHQM=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=N/UQyF8TyNZy2r+TB3TkITvvP5/fClr01UbIuxUcT720r1+Z912oXsELUg/cDCqVD9GVAUDLyD6uym7LkCYqauUpAf9GU4wNcP6Ru76xLQe1x1vnpBiQSO5vlO3BUW8rkzIlnSvfzqbdn+A+FM858RGe19LB2P6fYlK0rwvoYbc= 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; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b=XGElWPrJ; arc=none smtp.client-ip=115.124.30.113 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 DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1712892437; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=2fkGS+MFyueb1gRjvWZU73/oYEQkBz+kgZl5y/+I3Ww=; b=XGElWPrJ8MeiROWQkTeP6Ey0U4Oeyjsfa+3FLQqJRvUqMpAvhXHZcvU+pdQybxLHR+E8GnXbQlwNJ5evKPcYQmojd04kw1lCwLUCezbpMo5RAVBw2ZYUnUciFRPk6FYDgSKsfEO9uojqaVxjW6HsdHSGUX1MrNG5uyvLPajgZw8= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R151e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046051;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=12;SR=0;TI=SMTPD_---0W4Mumqi_1712892435; Received: from localhost(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0W4Mumqi_1712892435) by smtp.aliyun-inc.com; Fri, 12 Apr 2024 11:27:16 +0800 From: Baolin Wang To: akpm@linux-foundation.org Cc: hannes@cmpxchg.org, mgorman@techsingularity.net, vbabka@suse.cz, 21cnbao@gmail.com, ryan.roberts@arm.com, david@redhat.com, ying.huang@intel.com, ziy@nvidia.com, baolin.wang@linux.alibaba.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH] mm: page_alloc: allowing mTHP compaction to capture the freed page directly Date: Fri, 12 Apr 2024 11:27:04 +0800 Message-Id: <8118a5d66a034736a48433beddaca60ed78577c4.1712892329.git.baolin.wang@linux.alibaba.com> 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 Currently, compaction_capture() does not allow lower-order allocations to directly capture the movable free pages, even though lower-order allocations might also be requesting movable pages, that can lead to more compaction scanning. And, with the enablement of mTHP, such situations will become more common. Thus allowing lower-order (mTHP) allocations of movable page types directly capture the movable free pages can avoid unnecessary compaction scanning, meanwhile that won't pollute the movable pageblock. With testing 1M mTHP compaction, it can be seen that compaction scanning is significantly reduced. mm-unstable patched Ops Compaction pages isolated 116598741.00 120946702.00 Ops Compaction migrate scanned 1764870054.00 1488621550.00 Ops Compaction free scanned 7707879039.00 4986299318.00 Ops Compact scan efficiency 22.90 29.85 Ops Compaction cost 73797.69 72933.48 Signed-off-by: Baolin Wang --- mm/page_alloc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index b51becf03d1e..33d4a1be927b 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -595,12 +595,14 @@ compaction_capture(struct capture_control *capc, struct page *page, return false; /* - * Do not let lower order allocations pollute a movable pageblock. + * Do not let lower order allocations pollute a movable pageblock + * unless compaction is also requesting movable pages. * This might let an unmovable request use a reclaimable pageblock * and vice-versa but no more than normal fallback logic which can * have trouble finding a high-order free page. */ - if (order < pageblock_order && migratetype == MIGRATE_MOVABLE) + if (order < pageblock_order && migratetype == MIGRATE_MOVABLE && + capc->cc->migratetype != MIGRATE_MOVABLE) return false; capc->page = page; -- 2.39.3