From: Baolin Wang <baolin.wang@linux.alibaba.com>
To: Kemeng Shi <shikemeng@huaweicloud.com>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
akpm@linux-foundation.org, mgorman@techsingularity.net,
david@redhat.com, willy@infradead.org
Subject: Re: [PATCH v2 7/7] mm/compaction: factor out code to test if we should run compaction for target order
Date: Tue, 29 Aug 2023 11:48:59 +0800 [thread overview]
Message-ID: <940a7978-ebbb-f232-b536-7c8d16c0d1f1@linux.alibaba.com> (raw)
In-Reply-To: <20230826153617.4019189-8-shikemeng@huaweicloud.com>
On 8/26/2023 11:36 PM, Kemeng Shi wrote:
> We always do zone_watermark_ok check and compaction_suitable check
> together to test if compaction for target order should be runned.
> Factor these code out to remove repeat code.
>
> Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com>
> ---
> mm/compaction.c | 63 ++++++++++++++++++++++++++++---------------------
> 1 file changed, 36 insertions(+), 27 deletions(-)
>
> diff --git a/mm/compaction.c b/mm/compaction.c
> index 00b7bba6c72e..6f2b87b026b8 100644
> --- a/mm/compaction.c
> +++ b/mm/compaction.c
> @@ -2374,6 +2374,30 @@ bool compaction_zonelist_suitable(struct alloc_context *ac, int order,
> return false;
> }
>
> +/*
> + * Should we do compaction for target allocation order.
> + * Return COMPACT_SUCCESS if allocation for target order can be already
> + * satisfied
> + * Return COMPACT_SKIPPED if compaction for target order is likely to fail
> + * Return COMPACT_CONTINUE if compaction for target order should be runned
> + */
> +static inline enum compact_result
I think you should drop the 'inline' to let the compiler make the decision.
> +compaction_suit_allocation_order(struct zone *zone, unsigned int order,
> + int highest_zoneidx, unsigned int alloc_flags)
The changes look good to me. So please feel free to add:
Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com>
> +{
> + unsigned long watermark;
> +
> + watermark = wmark_pages(zone, alloc_flags & ALLOC_WMARK_MASK);
> + if (zone_watermark_ok(zone, order, watermark, highest_zoneidx,
> + alloc_flags))
> + return COMPACT_SUCCESS;
> +
> + if (!compaction_suitable(zone, order, highest_zoneidx))
> + return COMPACT_SKIPPED;
> +
> + return COMPACT_CONTINUE;
> +}
> +
> static enum compact_result
> compact_zone(struct compact_control *cc, struct capture_control *capc)
> {
> @@ -2399,19 +2423,11 @@ compact_zone(struct compact_control *cc, struct capture_control *capc)
> cc->migratetype = gfp_migratetype(cc->gfp_mask);
>
> if (!is_via_compact_memory(cc->order)) {
> - unsigned long watermark;
> -
> - /* Allocation can already succeed, nothing to do */
> - watermark = wmark_pages(cc->zone,
> - cc->alloc_flags & ALLOC_WMARK_MASK);
> - if (zone_watermark_ok(cc->zone, cc->order, watermark,
> - cc->highest_zoneidx, cc->alloc_flags))
> - return COMPACT_SUCCESS;
> -
> - /* Compaction is likely to fail */
> - if (!compaction_suitable(cc->zone, cc->order,
> - cc->highest_zoneidx))
> - return COMPACT_SKIPPED;
> + ret = compaction_suit_allocation_order(cc->zone, cc->order,
> + cc->highest_zoneidx,
> + cc->alloc_flags);
> + if (ret != COMPACT_CONTINUE)
> + return ret;
> }
>
> /*
> @@ -2917,14 +2933,10 @@ static bool kcompactd_node_suitable(pg_data_t *pgdat)
> if (!populated_zone(zone))
> continue;
>
> - /* Allocation can already succeed, check other zones */
> - if (zone_watermark_ok(zone, pgdat->kcompactd_max_order,
> - min_wmark_pages(zone),
> - highest_zoneidx, 0))
> - continue;
> -
> - if (compaction_suitable(zone, pgdat->kcompactd_max_order,
> - highest_zoneidx))
> + if (compaction_suit_allocation_order(zone,
> + pgdat->kcompactd_max_order,
> + highest_zoneidx, ALLOC_WMARK_MIN) ==
> + COMPACT_CONTINUE)
> return true;
> }
>
> @@ -2961,12 +2973,9 @@ static void kcompactd_do_work(pg_data_t *pgdat)
> if (compaction_deferred(zone, cc.order))
> continue;
>
> - /* Allocation can already succeed, nothing to do */
> - if (zone_watermark_ok(zone, cc.order,
> - min_wmark_pages(zone), zoneid, 0))
> - continue;
> -
> - if (!compaction_suitable(zone, cc.order, zoneid))
> + if (compaction_suit_allocation_order(zone,
> + cc.order, zoneid, ALLOC_WMARK_MIN) !=
> + COMPACT_CONTINUE)
> continue;
>
> if (kthread_should_stop())
next prev parent reply other threads:[~2023-08-29 3:49 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-26 15:36 [PATCH v2 0/7] Fixes and cleanups to compaction Kemeng Shi
2023-08-26 15:36 ` [PATCH v2 1/7] mm/compaction: use correct list in move_freelist_{head}/{tail} Kemeng Shi
2023-08-29 9:03 ` Mel Gorman
2023-08-26 15:36 ` [PATCH v2 2/7] mm/compaction: call list_is_{first}/{last} more intuitively " Kemeng Shi
2023-08-29 9:18 ` Mel Gorman
2023-08-26 15:36 ` [PATCH v2 3/7] mm/compaction: correctly return failure with bogus compound_order in strict mode Kemeng Shi
2023-08-29 3:27 ` Baolin Wang
2023-08-29 9:39 ` Mel Gorman
2023-08-30 6:50 ` Kemeng Shi
2023-08-26 15:36 ` [PATCH v2 4/7] mm/compaction: simplify pfn iteration in isolate_freepages_range Kemeng Shi
2023-08-29 15:01 ` Mel Gorman
2023-08-30 7:02 ` Kemeng Shi
2023-08-26 15:36 ` [PATCH v2 5/7] mm/compaction: remove repeat compact_blockskip_flush check in reset_isolation_suitable Kemeng Shi
2023-08-29 15:05 ` Mel Gorman
2023-08-30 7:07 ` Kemeng Shi
2023-08-26 15:36 ` [PATCH v2 6/7] mm/compaction: improve comment of is_via_compact_memory Kemeng Shi
2023-08-29 3:28 ` Baolin Wang
2023-08-29 15:06 ` Mel Gorman
2023-08-26 15:36 ` [PATCH v2 7/7] mm/compaction: factor out code to test if we should run compaction for target order Kemeng Shi
2023-08-29 3:48 ` Baolin Wang [this message]
2023-08-30 6:28 ` Kemeng Shi
2023-08-29 3:54 ` Matthew Wilcox
2023-08-30 6:45 ` Kemeng Shi
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=940a7978-ebbb-f232-b536-7c8d16c0d1f1@linux.alibaba.com \
--to=baolin.wang@linux.alibaba.com \
--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=shikemeng@huaweicloud.com \
--cc=willy@infradead.org \
/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
all inboxes | Powered by JetHome®