From: Jan Kara <jack@suse.cz>
To: Kemeng Shi <shikemeng@huaweicloud.com>
Cc: tytso@mit.edu, adilger.kernel@dilger.ca,
linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org,
jack@suse.cz, ojaswin@linux.ibm.com, ritesh.list@gmail.com
Subject: Re: [PATCH v2 5/5] ext4: open coding repeated check in next_linear_group
Date: Tue, 23 Apr 2024 23:46:51 +0200 [thread overview]
Message-ID: <20240423214651.v7veh2x2pmkpxti4@quack3> (raw)
In-Reply-To: <20240423124046.974134-6-shikemeng@huaweicloud.com>
On Tue 23-04-24 20:40:46, Kemeng Shi wrote:
> Open coding repeated check in next_linear_group.
>
> Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com>
Looks good. Feel free to add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
> ---
> fs/ext4/mballoc.c | 31 +++++++++++++++----------------
> 1 file changed, 15 insertions(+), 16 deletions(-)
>
> diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
> index 71b2f9a18875..4afe5bb94bf4 100644
> --- a/fs/ext4/mballoc.c
> +++ b/fs/ext4/mballoc.c
> @@ -1076,23 +1076,11 @@ static inline int should_optimize_scan(struct ext4_allocation_context *ac)
> }
>
> /*
> - * Return next linear group for allocation. If linear traversal should not be
> - * performed, this function just returns the same group
> + * Return next linear group for allocation.
> */
> static ext4_group_t
> -next_linear_group(struct ext4_allocation_context *ac, ext4_group_t group,
> - ext4_group_t ngroups)
> +next_linear_group(ext4_group_t group, ext4_group_t ngroups)
> {
> - if (!should_optimize_scan(ac))
> - goto inc_and_return;
> -
> - if (ac->ac_groups_linear_remaining) {
> - ac->ac_groups_linear_remaining--;
> - goto inc_and_return;
> - }
> -
> - return group;
> -inc_and_return:
> /*
> * Artificially restricted ngroups for non-extent
> * files makes group > ngroups possible on first loop.
> @@ -1118,8 +1106,19 @@ static void ext4_mb_choose_next_group(struct ext4_allocation_context *ac,
> {
> *new_cr = ac->ac_criteria;
>
> - if (!should_optimize_scan(ac) || ac->ac_groups_linear_remaining) {
> - *group = next_linear_group(ac, *group, ngroups);
> + if (!should_optimize_scan(ac)) {
> + *group = next_linear_group(*group, ngroups);
> + return;
> + }
> +
> + /*
> + * Optimized scanning can return non adjacent groups which can cause
> + * seek overhead for rotational disks. So try few linear groups before
> + * trying optimized scan.
> + */
> + if (ac->ac_groups_linear_remaining) {
> + *group = next_linear_group(*group, ngroups);
> + ac->ac_groups_linear_remaining--;
> return;
> }
>
> --
> 2.30.0
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
prev parent reply other threads:[~2024-04-23 21:46 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-23 12:40 [PATCH v2 0/5] Minor improvements and cleanups to ext4 mballoc Kemeng Shi
2024-04-23 12:40 ` [PATCH v2 1/5] ext4: keep "prefetch_grp" and "nr" consistent Kemeng Shi
2024-04-23 12:40 ` [PATCH v2 2/5] ext4: add test_mb_mark_used_cost to estimate cost of mb_mark_used Kemeng Shi
2024-04-23 12:40 ` [PATCH v2 3/5] ext4: call ext4_mb_mark_free_simple to free continuous bits in found chunk Kemeng Shi
2024-04-23 12:40 ` [PATCH v2 4/5] ext4: use correct criteria name instead stale integer number in comment Kemeng Shi
2024-04-23 21:43 ` Jan Kara
2024-04-24 1:20 ` Kemeng Shi
2024-04-23 12:40 ` [PATCH v2 5/5] ext4: open coding repeated check in next_linear_group Kemeng Shi
2024-04-23 21:46 ` Jan Kara [this message]
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=20240423214651.v7veh2x2pmkpxti4@quack3 \
--to=jack@suse.cz \
--cc=adilger.kernel@dilger.ca \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ojaswin@linux.ibm.com \
--cc=ritesh.list@gmail.com \
--cc=shikemeng@huaweicloud.com \
--cc=tytso@mit.edu \
/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