From: Yajun Deng <yajun.deng@linux.dev>
To: akpm@linux-foundation.org
Cc: ziy@nvidia.com, mgorman@techsingularity.net, david@redhat.com,
vbabka@suse.cz, rppt@linux.ibm.com, osalvador@suse.de,
rppt@kernel.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org, Yajun Deng <yajun.deng@linux.dev>
Subject: [PATCH] mm/page_alloc: optimize the loop in find_suitable_fallback()
Date: Thu, 9 Feb 2023 10:44:35 +0800 [thread overview]
Message-ID: <20230209024435.3392916-1-yajun.deng@linux.dev> (raw)
There is no need to execute the next loop if it not return in the first
loop. So add a break at the end of the loop.
There are only three rows in fallbacks, so reduce the first index size
from MIGRATE_TYPES to MIGRATE_PCPTYPES.
Signed-off-by: Yajun Deng <yajun.deng@linux.dev>
---
mm/page_alloc.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 1113483fa6c5..536e8d838fb5 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -2603,7 +2603,7 @@ struct page *__rmqueue_smallest(struct zone *zone, unsigned int order,
*
* The other migratetypes do not have fallbacks.
*/
-static int fallbacks[MIGRATE_TYPES][MIGRATE_PCPTYPES - 1] = {
+static int fallbacks[MIGRATE_PCPTYPES][MIGRATE_PCPTYPES - 1] = {
[MIGRATE_UNMOVABLE] = { MIGRATE_RECLAIMABLE, MIGRATE_MOVABLE },
[MIGRATE_MOVABLE] = { MIGRATE_RECLAIMABLE, MIGRATE_UNMOVABLE },
[MIGRATE_RECLAIMABLE] = { MIGRATE_UNMOVABLE, MIGRATE_MOVABLE },
@@ -2861,7 +2861,7 @@ int find_suitable_fallback(struct free_area *area, unsigned int order,
int i;
int fallback_mt;
- if (area->nr_free == 0)
+ if (area->nr_free == 0 || !migratetype_is_mergeable(migratetype))
return -1;
*can_steal = false;
@@ -2873,11 +2873,10 @@ int find_suitable_fallback(struct free_area *area, unsigned int order,
if (can_steal_fallback(order, migratetype))
*can_steal = true;
- if (!only_stealable)
- return fallback_mt;
-
- if (*can_steal)
+ if (!only_stealable || *can_steal)
return fallback_mt;
+ else
+ break;
}
return -1;
--
2.25.1
next reply other threads:[~2023-02-09 2:44 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-09 2:44 Yajun Deng [this message]
2023-02-09 8:12 ` Vlastimil Babka
2023-02-09 8:44 ` Yajun Deng
2023-02-09 9:22 ` Vlastimil Babka
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230209024435.3392916-1-yajun.deng@linux.dev \
--to=yajun.deng@linux.dev \
--cc=akpm@linux-foundation.org \
--cc=david@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mgorman@techsingularity.net \
--cc=osalvador@suse.de \
--cc=rppt@kernel.org \
--cc=rppt@linux.ibm.com \
--cc=vbabka@suse.cz \
--cc=ziy@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox