linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kemeng Shi <shikemeng@huaweicloud.com>
To: tytso@mit.edu, adilger.kernel@dilger.ca, ritesh.list@gmail.com,
	ojaswin@linux.ibm.com, linux-ext4@vger.kernel.org,
	linux-kernel@vger.kernel.org
Cc: shikemeng@huaweicloud.com
Subject: [PATCH 04/10] ext4: use is_power_of_2 helper in ext4_mb_regular_allocator
Date: Sat, 22 Jul 2023 01:10:01 +0800	[thread overview]
Message-ID: <20230721171007.2065423-5-shikemeng@huaweicloud.com> (raw)
In-Reply-To: <20230721171007.2065423-1-shikemeng@huaweicloud.com>

Use intuitive is_power_of_2 helper in ext4_mb_regular_allocator.

Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com>
---
 fs/ext4/mballoc.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index 4031f8e2a660..b838944b5f09 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -2795,10 +2795,7 @@ ext4_mb_regular_allocator(struct ext4_allocation_context *ac)
 	 * requests upto maximum buddy size we have constructed.
 	 */
 	if (i >= sbi->s_mb_order2_reqs && i <= MB_NUM_ORDERS(sb)) {
-		/*
-		 * This should tell if fe_len is exactly power of 2
-		 */
-		if ((ac->ac_g_ex.fe_len & (~(1 << (i - 1)))) == 0)
+		if (is_power_of_2(ac->ac_g_ex.fe_len))
 			ac->ac_2order = array_index_nospec(i - 1,
 							   MB_NUM_ORDERS(sb));
 	}
-- 
2.30.0


  parent reply	other threads:[~2023-07-21  9:09 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-21 17:09 [PATCH 00/10] A few fixes and cleanups to mballoc Kemeng Shi
2023-07-21 15:55 ` Ritesh Harjani
2023-07-25  2:09   ` Kemeng Shi
2023-07-21 17:09 ` [PATCH 01/10] ext4: correct grp validation in ext4_mb_good_group Kemeng Shi
2023-07-21 15:22   ` Ritesh Harjani
2023-07-21 17:09 ` [PATCH 02/10] ext4: avoid potential data overflow in next_linear_group Kemeng Shi
2023-07-21 15:26   ` Ritesh Harjani
2023-07-21 17:10 ` [PATCH 03/10] ext4: return found group directly in ext4_mb_choose_next_group_p2_aligned Kemeng Shi
2023-07-21 15:31   ` Ritesh Harjani
2023-07-21 17:10 ` Kemeng Shi [this message]
2023-07-21 15:37   ` [PATCH 04/10] ext4: use is_power_of_2 helper in ext4_mb_regular_allocator Ritesh Harjani
2023-07-21 17:10 ` [PATCH 05/10] ext4: remove unnecessary return for void function Kemeng Shi
2023-07-21 15:43   ` Ritesh Harjani
2023-07-21 17:10 ` [PATCH 06/10] ext4: replace the traditional ternary conditional operator with with max()/min() Kemeng Shi
2023-07-21 15:44   ` Ritesh Harjani
2023-07-21 17:10 ` [PATCH 07/10] ext4: remove unused ext4_{set}/{clear}_bit_atomic Kemeng Shi
2023-07-21 15:45   ` Ritesh Harjani
2023-07-21 17:10 ` [PATCH 08/10] ext4: return found group directly in ext4_mb_choose_next_group_goal_fast Kemeng Shi
2023-07-21 15:45   ` Ritesh Harjani
2023-07-21 17:10 ` [PATCH 09/10] ext4: return found group directly in ext4_mb_choose_next_group_best_avail Kemeng Shi
2023-07-21 15:48   ` Ritesh Harjani
2023-07-21 17:10 ` [PATCH 10/10] ext4: correct some stale comment of criteria Kemeng Shi
2023-07-21 15:49   ` Ritesh Harjani

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=20230721171007.2065423-5-shikemeng@huaweicloud.com \
    --to=shikemeng@huaweicloud.com \
    --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=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;
as well as URLs for NNTP newsgroup(s).