Message ID | 20240212163510.859822-4-zi.yan@sent.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-61995-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp34472dyb; Mon, 12 Feb 2024 08:42:09 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV07LXfWE3mCt9KHMx/X/HOoiwik6V8/dH5HIzK8058bPjHcJbcGU1K2ZY6F0CPf0P9PDzb65vIYwZfU+FDPF2xIL8TAQ== X-Google-Smtp-Source: AGHT+IER2cmob1Vr9HIG3a54uRv0IVkAxnRypaba1gWmAdhFBdosIHuaqe0UdRt9CpAw3/lA4Yzd X-Received: by 2002:a05:620a:4051:b0:785:c8ba:81e0 with SMTP id i17-20020a05620a405100b00785c8ba81e0mr8135671qko.57.1707756129199; Mon, 12 Feb 2024 08:42:09 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707756129; cv=pass; d=google.com; s=arc-20160816; b=xIreJ/hTsuxL18ofy+xScpOukmRlEFexiYjPDlr1WaLqO/wDsmLxfPVYkakowN9LzX rdUboLlXLrjXDHYmLl2AZ3L1g3o1NiHmU5XsUCbpw4J5w8syQAjaNvVpKFFo5/VcaQPR wfFnu0CSJtz9JVPeZIQ7qaj5QDNz47U6jF/tyv5xEa0IYe2eR6LsLaumuUnEA3qz+i+w Tms9Kct2MKi8BfbiFp9jdsTB30fmDwR3P+xvobYAZ+YjWfK0Gr1YY8vGRx7sXN1ugsVt V0Rydu9s9r8myqzrRUiR++xZq1tn4JIxsP7lCdLFgYqCv4o3NYV2nCo1e5/4nsmwprjm uYfw== 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:reply-to:references:in-reply-to :message-id:date:subject:cc:to:from:feedback-id:dkim-signature :dkim-signature; bh=/EqPdua3wUu7egs9hj3joQyCeB5KILvG5+17pYfAKJw=; fh=jjsXbedxMiKxzxBkRbLidSxRW5XFRE5oHCTJV/+xFn0=; b=0tCHM6JzwfMP2H0r1Gwj1sZtPHcDOoeCJxYVsg5TcETF5nCdDUcSlL8ThohOlMplfL j4MB77MNlu4wVBiunYq4VWIP7Mo1mfmknbz5iMmxSPa4cD8XyzlB+62Gg8iAJwmERiV3 DMGAipOeRkj5x/x5tdezodwk1FHNSlCpL0XduNxHqaOo6ya/HjmVyFJSfcuBzeNGLnZc WisdIdrvsL3jKtWYc5VA2+wNhL8Qmv1HnVQCEXdMNKDGWgGioMiyscIN4fac8B7/vwnw I7qH8kfjNbLk1VHZC+VhbfLE4uHISCbSBiFNzZGyXZED3s+H8xkVVTZ/PFRcdDrRDZ4x MHMQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@sent.com header.s=fm3 header.b=HlmOQr9q; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=J2YOywBV; arc=pass (i=1 spf=pass spfdomain=sent.com dkim=pass dkdomain=sent.com dkim=pass dkdomain=messagingengine.com dmarc=pass fromdomain=sent.com); spf=pass (google.com: domain of linux-kernel+bounces-61995-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61995-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sent.com X-Forwarded-Encrypted: i=2; AJvYcCVHl1hI5XGJAXn9y4ct/LBQoZILDE3ZCs2LMKi/TxoK2OWbkI74OmMRYOX6KI/4HbcTUyZkMf3jb8cckZrmTzWyR3G1gA== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id m8-20020a05620a290800b0078717e581aasi146675qkp.711.2024.02.12.08.42.09 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 08:42:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-61995-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@sent.com header.s=fm3 header.b=HlmOQr9q; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=J2YOywBV; arc=pass (i=1 spf=pass spfdomain=sent.com dkim=pass dkdomain=sent.com dkim=pass dkdomain=messagingengine.com dmarc=pass fromdomain=sent.com); spf=pass (google.com: domain of linux-kernel+bounces-61995-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61995-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sent.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 ny.mirrors.kernel.org (Postfix) with ESMTPS id E77F51C218D0 for <ouuuleilei@gmail.com>; Mon, 12 Feb 2024 16:42:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7BCCC481D0; Mon, 12 Feb 2024 16:35:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sent.com header.i=@sent.com header.b="HlmOQr9q"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="J2YOywBV" Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) (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 8901B182C5 for <linux-kernel@vger.kernel.org>; Mon, 12 Feb 2024 16:35:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=66.111.4.27 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707755720; cv=none; b=RlfhgeFm4mlLH1otL2UVwD9jEzLWs/G3EB5UHdD8K9LAEvUDDZXgHbG0ADJZMw+2FPxib6+36P4wplzlsN9C5t2AFgcp783Zjx2cSj4zKZhcqkHz/kh7ZCAFCTMP089XFKs1o9NmgtTPSQCKRD6zZyWBcs91/OMEv69xP31xphg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707755720; c=relaxed/simple; bh=IDzhkY1a4910plU/Bf1p6UotGfhcV2qh2ZuJcavuoW4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=kn0EfuQR50fBqOK/VLaq53O6NRfz8Lq1onJ3BId08Vgzbpuawm8XlkfkaDLMi+HDXpeL9+1HplMQqwms5ezg08HSzg24RwakwfPDW898764WbzZahU+SiviAKbeLVtLoFqFLaSTS6TrTNngCHfRdvliz8eh2S60qR/hxrdZQK7E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sent.com; spf=pass smtp.mailfrom=sent.com; dkim=pass (2048-bit key) header.d=sent.com header.i=@sent.com header.b=HlmOQr9q; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=J2YOywBV; arc=none smtp.client-ip=66.111.4.27 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sent.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sent.com Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 8F20A5C00CA; Mon, 12 Feb 2024 11:35:17 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Mon, 12 Feb 2024 11:35:17 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sent.com; h=cc :cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:reply-to:subject:subject:to:to; s=fm3; t= 1707755717; x=1707842117; bh=/EqPdua3wUu7egs9hj3joQyCeB5KILvG5+1 7pYfAKJw=; b=HlmOQr9qvHE0N6b7r3vJLZNcb3UVrG8RUx4z6QwPWhLBya5sAT9 V/S8Zqpwle9MkAqKRpupK3V2y9nYsva6hSKmft+SWN0zTIoSACDHPIyodradZMjy g+GChb5rZTZ44gfLzd7CUhTC0ssGdm7FJ4mYXHBBtjFA0hDoYMWCuOFobhFSSMaK my8JWVzC16TrYyZO0HNWwVqcee9zpknq/X4JA2fQlF2BU5e2k/PCfbhgTnkzNt2i 2hZBq9/vVwdpRqc9Jw3Ba02aMdxcuP6xjPriauzPyPw+VO5OH8Q9t/KqKNte/okX gxJiwWJoFaUX3BdyN2TVc42jIOZnVCM3oNg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:reply-to:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t= 1707755717; x=1707842117; bh=/EqPdua3wUu7egs9hj3joQyCeB5KILvG5+1 7pYfAKJw=; b=J2YOywBVYcHvZh7SL9Ztx6GaM3mrxWauzT0f5e3Y4/dspDxc67z 0VnElepBVZ/VU9ofd0CW9IdSk+E7tGKMbk72o8MDHt4nIP/V3BV1+7XRh8zkGLZi Qwjkb6t/nNlSuJseIqlikcvWUbzFbWnXQJ+MheLqK7u1DlXuf28jrhHStz07sqFi 0GW/1LGHaNq5478fa5nBMOQpSzr6nmCKNpj7n/tRqAbB07H0Iwze+SKx5tyt2Blm H0L4gRsQaUbjFFUNrwbG1TrzHq5cqxNGBkLFKaCIgBOOftaOWtNkzNsfxoiCkguE JICNz/Blga59c1UaxavgBIMUYrtQMc6AtlA== X-ME-Sender: <xms:xUjKZW19TcXlYp1OWqkFk1aHf6XmhvY3ozWfISZLR3GFdWHkFFn0tg> <xme:xUjKZZFxIA8lrTbUqCso1VyWk8GcYS4D39llvE_pgcinOXEUmog3HUNuHn_SQ2bGj 6l9sZ8mdGC7lwvGVQ> X-ME-Received: <xmr:xUjKZe745P32t8fSTQHQbkGkPADHwFvcv6_x2ChbvJ9z-hmQSncZkRYjiFMshBC34M5zPbsURgREvq_MV7PY7plXtpj6f2X1lqIiq-U-cS0AczBKY5FnL0_G> X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrudefgdekkecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvfevufffkffojghfrhggtgfgsehtkeertdertdejnecuhfhrohhmpegkihcu jggrnhcuoeiiihdrhigrnhesshgvnhhtrdgtohhmqeenucggtffrrghtthgvrhhnpeejke etkeffleelkeduffdtfedvtdejjeeutdeutdetgeejgfevtdefudejkeeiveenucevlhhu shhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpeiiihdrhigrnhessh gvnhhtrdgtohhm X-ME-Proxy: <xmx:xUjKZX09b_Z0b7LBqXtu-UsXl5mZ62eleEsmniGdmZz7gNAJ28_TlA> <xmx:xUjKZZFAGzBJJmZD2dofOUdsIndBrXGwhqCuGYOlCvbqYDV5UoSEjQ> <xmx:xUjKZQ9gL7y10Chg0dmi4lf-AdaoBVHlFBmxO9_3rUihPP7Ds1xjXg> <xmx:xUjKZX9vRLw49H2efiaiekvsz-gEoMdvyUna-_VZZqqtyBIx9PBB1w> Feedback-ID: iccd040f4:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 12 Feb 2024 11:35:16 -0500 (EST) From: Zi Yan <zi.yan@sent.com> To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Zi Yan <ziy@nvidia.com>, "Huang, Ying" <ying.huang@intel.com>, Ryan Roberts <ryan.roberts@arm.com>, Andrew Morton <akpm@linux-foundation.org>, "Matthew Wilcox (Oracle)" <willy@infradead.org>, David Hildenbrand <david@redhat.com>, "Yin, Fengwei" <fengwei.yin@intel.com>, Yu Zhao <yuzhao@google.com>, Vlastimil Babka <vbabka@suse.cz>, "Kirill A . Shutemov" <kirill.shutemov@linux.intel.com>, Johannes Weiner <hannes@cmpxchg.org>, Baolin Wang <baolin.wang@linux.alibaba.com>, Kemeng Shi <shikemeng@huaweicloud.com>, Mel Gorman <mgorman@techsingularity.net>, Rohan Puri <rohan.puri15@gmail.com>, Mcgrof Chamberlain <mcgrof@kernel.org>, Adam Manzanares <a.manzanares@samsung.com>, "Vishal Moola (Oracle)" <vishal.moola@gmail.com> Subject: [PATCH v4 3/3] mm/compaction: optimize >0 order folio compaction with free page split. Date: Mon, 12 Feb 2024 11:35:10 -0500 Message-ID: <20240212163510.859822-4-zi.yan@sent.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240212163510.859822-1-zi.yan@sent.com> References: <20240212163510.859822-1-zi.yan@sent.com> Reply-To: Zi Yan <ziy@nvidia.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790712090794469085 X-GMAIL-MSGID: 1790712090794469085 |
Series |
[v4,1/3] mm/compaction: enable compacting >0 order folios.
|
|
Commit Message
Zi Yan
Feb. 12, 2024, 4:35 p.m. UTC
From: Zi Yan <ziy@nvidia.com> During migration in a memory compaction, free pages are placed in an array of page lists based on their order. But the desired free page order (i.e., the order of a source page) might not be always present, thus leading to migration failures and premature compaction termination. Split a high order free pages when source migration page has a lower order to increase migration successful rate. Note: merging free pages when a migration fails and a lower order free page is returned via compaction_free() is possible, but there is too much work. Since the free pages are not buddy pages, it is hard to identify these free pages using existing PFN-based page merging algorithm. Signed-off-by: Zi Yan <ziy@nvidia.com> Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com> Tested-by: Baolin Wang <baolin.wang@linux.alibaba.com> Cc: Adam Manzanares <a.manzanares@samsung.com> Cc: David Hildenbrand <david@redhat.com> Cc: Huang Ying <ying.huang@intel.com> Cc: Johannes Weiner <hannes@cmpxchg.org> Cc: Kemeng Shi <shikemeng@huaweicloud.com> Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> Cc: Luis Chamberlain <mcgrof@kernel.org> Cc: Matthew Wilcox (Oracle) <willy@infradead.org> Cc: Mel Gorman <mgorman@techsingularity.net> Cc: Ryan Roberts <ryan.roberts@arm.com> Cc: Vishal Moola (Oracle) <vishal.moola@gmail.com> Cc: Vlastimil Babka <vbabka@suse.cz> Cc: Yin Fengwei <fengwei.yin@intel.com> Cc: Yu Zhao <yuzhao@google.com> --- mm/compaction.c | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-)
Comments
On Mon, Feb 12, 2024 at 9:35 AM Zi Yan <zi.yan@sent.com> wrote: > > From: Zi Yan <ziy@nvidia.com> > > During migration in a memory compaction, free pages are placed in an array > of page lists based on their order. But the desired free page order > (i.e., the order of a source page) might not be always present, thus > leading to migration failures and premature compaction termination. Split > a high order free pages when source migration page has a lower order to > increase migration successful rate. > > Note: merging free pages when a migration fails and a lower order free > page is returned via compaction_free() is possible, but there is too much > work. Since the free pages are not buddy pages, it is hard to identify > these free pages using existing PFN-based page merging algorithm. > > Signed-off-by: Zi Yan <ziy@nvidia.com> > Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com> > Tested-by: Baolin Wang <baolin.wang@linux.alibaba.com> > Cc: Adam Manzanares <a.manzanares@samsung.com> > Cc: David Hildenbrand <david@redhat.com> > Cc: Huang Ying <ying.huang@intel.com> > Cc: Johannes Weiner <hannes@cmpxchg.org> > Cc: Kemeng Shi <shikemeng@huaweicloud.com> > Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> > Cc: Luis Chamberlain <mcgrof@kernel.org> > Cc: Matthew Wilcox (Oracle) <willy@infradead.org> > Cc: Mel Gorman <mgorman@techsingularity.net> > Cc: Ryan Roberts <ryan.roberts@arm.com> > Cc: Vishal Moola (Oracle) <vishal.moola@gmail.com> > Cc: Vlastimil Babka <vbabka@suse.cz> > Cc: Yin Fengwei <fengwei.yin@intel.com> > Cc: Yu Zhao <yuzhao@google.com> > --- > mm/compaction.c | 36 +++++++++++++++++++++++++++++++----- > 1 file changed, 31 insertions(+), 5 deletions(-) > > diff --git a/mm/compaction.c b/mm/compaction.c > index d0a05a621b67..25908e36b97c 100644 > --- a/mm/compaction.c > +++ b/mm/compaction.c > @@ -1832,15 +1832,41 @@ static struct folio *compaction_alloc(struct folio *src, unsigned long data) > struct compact_control *cc = (struct compact_control *)data; > struct folio *dst; > int order = folio_order(src); > + bool has_isolated_pages = false; > + int start_order; > + struct page *freepage; > + unsigned long size; > + > +again: > + for (start_order = order; start_order < NR_PAGE_ORDERS; start_order++) > + if (!list_empty(&cc->freepages[start_order])) > + break; > > - if (list_empty(&cc->freepages[order])) { > - isolate_freepages(cc); > - if (list_empty(&cc->freepages[order])) > + /* no free pages in the list */ > + if (start_order == NR_PAGE_ORDERS) { > + if (!has_isolated_pages) { > + isolate_freepages(cc); > + has_isolated_pages = true; > + goto again; > + } else > return NULL; Nit: remove the "else" above, or just: if (has_isolated_pages) return NULL; isolate_freepages(cc); has_isolated_pages = true; goto again;
On 12 Feb 2024, at 13:27, Yu Zhao wrote: > On Mon, Feb 12, 2024 at 9:35 AM Zi Yan <zi.yan@sent.com> wrote: >> >> From: Zi Yan <ziy@nvidia.com> >> >> During migration in a memory compaction, free pages are placed in an array >> of page lists based on their order. But the desired free page order >> (i.e., the order of a source page) might not be always present, thus >> leading to migration failures and premature compaction termination. Split >> a high order free pages when source migration page has a lower order to >> increase migration successful rate. >> >> Note: merging free pages when a migration fails and a lower order free >> page is returned via compaction_free() is possible, but there is too much >> work. Since the free pages are not buddy pages, it is hard to identify >> these free pages using existing PFN-based page merging algorithm. >> >> Signed-off-by: Zi Yan <ziy@nvidia.com> >> Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com> >> Tested-by: Baolin Wang <baolin.wang@linux.alibaba.com> >> Cc: Adam Manzanares <a.manzanares@samsung.com> >> Cc: David Hildenbrand <david@redhat.com> >> Cc: Huang Ying <ying.huang@intel.com> >> Cc: Johannes Weiner <hannes@cmpxchg.org> >> Cc: Kemeng Shi <shikemeng@huaweicloud.com> >> Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> >> Cc: Luis Chamberlain <mcgrof@kernel.org> >> Cc: Matthew Wilcox (Oracle) <willy@infradead.org> >> Cc: Mel Gorman <mgorman@techsingularity.net> >> Cc: Ryan Roberts <ryan.roberts@arm.com> >> Cc: Vishal Moola (Oracle) <vishal.moola@gmail.com> >> Cc: Vlastimil Babka <vbabka@suse.cz> >> Cc: Yin Fengwei <fengwei.yin@intel.com> >> Cc: Yu Zhao <yuzhao@google.com> >> --- >> mm/compaction.c | 36 +++++++++++++++++++++++++++++++----- >> 1 file changed, 31 insertions(+), 5 deletions(-) >> >> diff --git a/mm/compaction.c b/mm/compaction.c >> index d0a05a621b67..25908e36b97c 100644 >> --- a/mm/compaction.c >> +++ b/mm/compaction.c >> @@ -1832,15 +1832,41 @@ static struct folio *compaction_alloc(struct folio *src, unsigned long data) >> struct compact_control *cc = (struct compact_control *)data; >> struct folio *dst; >> int order = folio_order(src); >> + bool has_isolated_pages = false; >> + int start_order; >> + struct page *freepage; >> + unsigned long size; >> + >> +again: >> + for (start_order = order; start_order < NR_PAGE_ORDERS; start_order++) >> + if (!list_empty(&cc->freepages[start_order])) >> + break; >> >> - if (list_empty(&cc->freepages[order])) { >> - isolate_freepages(cc); >> - if (list_empty(&cc->freepages[order])) >> + /* no free pages in the list */ >> + if (start_order == NR_PAGE_ORDERS) { >> + if (!has_isolated_pages) { >> + isolate_freepages(cc); >> + has_isolated_pages = true; >> + goto again; >> + } else >> return NULL; > > Nit: remove the "else" above, or just: > > if (has_isolated_pages) > return NULL; > isolate_freepages(cc); > has_isolated_pages = true; > goto again; Will do. Thanks. -- Best Regards, Yan, Zi
diff --git a/mm/compaction.c b/mm/compaction.c index d0a05a621b67..25908e36b97c 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -1832,15 +1832,41 @@ static struct folio *compaction_alloc(struct folio *src, unsigned long data) struct compact_control *cc = (struct compact_control *)data; struct folio *dst; int order = folio_order(src); + bool has_isolated_pages = false; + int start_order; + struct page *freepage; + unsigned long size; + +again: + for (start_order = order; start_order < NR_PAGE_ORDERS; start_order++) + if (!list_empty(&cc->freepages[start_order])) + break; - if (list_empty(&cc->freepages[order])) { - isolate_freepages(cc); - if (list_empty(&cc->freepages[order])) + /* no free pages in the list */ + if (start_order == NR_PAGE_ORDERS) { + if (!has_isolated_pages) { + isolate_freepages(cc); + has_isolated_pages = true; + goto again; + } else return NULL; } - dst = list_first_entry(&cc->freepages[order], struct folio, lru); - list_del(&dst->lru); + freepage = list_first_entry(&cc->freepages[start_order], struct page, + lru); + size = 1 << start_order; + + list_del(&freepage->lru); + + while (start_order > order) { + start_order--; + size >>= 1; + + list_add(&freepage[size].lru, &cc->freepages[start_order]); + set_page_private(&freepage[size], start_order); + } + dst = (struct folio *)freepage; + post_alloc_hook(&dst->page, order, __GFP_MOVABLE); if (order) prep_compound_page(&dst->page, order);