From patchwork Thu Jan 8 18:51:27 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1353 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767898374; bh=j6/hmHdIdGVR6IaMpS7YvpngFkzu3m2MXnLpi/VRbp4=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=q5Vw0kME4o1s334zmLy4Cl5yh/+LagycyxooJfCfDs8c82RSmi1esKCRHHL+FPFDe 6RkqHufBbhcM0vDZ8BbjgGn0tCTaGQjB+zY/D5oSlt4WhR5C95oja5jzrd5iD5xKTR dNODBYkcFTKethFj0HaxNXvV5wKWfd43brL3rtBgAX5Dkxkk3ebg90u8ypp+LxYtJH AjdxZqcQyOcEwRUxdbTOgtkFX2ykvda98KDETMRlsnljI2AxTb2nU4KUnwQeO+1Bmh +0FGuDtDEqS07sFFA1LqC+9TtMRIz3C9ykW/zgXUhL5Kzg+OsuR0Myfza2C3Rzbaa/ SgOyO297G/ewg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 4B9E0691CC for ; Thu, 8 Jan 2026 11:52:54 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id IAwmkC8UWE4h for ; Thu, 8 Jan 2026 11:52:54 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767898374; bh=j6/hmHdIdGVR6IaMpS7YvpngFkzu3m2MXnLpi/VRbp4=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=q5Vw0kME4o1s334zmLy4Cl5yh/+LagycyxooJfCfDs8c82RSmi1esKCRHHL+FPFDe 6RkqHufBbhcM0vDZ8BbjgGn0tCTaGQjB+zY/D5oSlt4WhR5C95oja5jzrd5iD5xKTR dNODBYkcFTKethFj0HaxNXvV5wKWfd43brL3rtBgAX5Dkxkk3ebg90u8ypp+LxYtJH AjdxZqcQyOcEwRUxdbTOgtkFX2ykvda98KDETMRlsnljI2AxTb2nU4KUnwQeO+1Bmh +0FGuDtDEqS07sFFA1LqC+9TtMRIz3C9ykW/zgXUhL5Kzg+OsuR0Myfza2C3Rzbaa/ SgOyO297G/ewg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 3C123691C4 for ; Thu, 8 Jan 2026 11:52:54 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767898372; bh=pExGZwOVGGyu0ukP26JA/fgvySOkxyAJdx2HMUwGlA0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YLKC9yI5RU4z06rMv4G+Q1Jri4ixN1d2NY/lSCh/maBJokJOw5x79v2kKZia8SBcL 0Zmtjuw+Dyw7Xv7Ovk6G4eWrSMbYStjUEi2aRmmNR6RW25sKS96Dc1672RqBSFEy8b 5NGp+tiYRJdHLHLh1sVXlwlgkSKIge3Y1whSOmZb+XXOgQji5kwOjH4yNFLbc+QK2S tTOhyCP6OplZUPDiBg1ivjvW3d7ng1JaZwF6NwLnBRskvyCs37F++Pxpr2UM59AIsg DLizdEwdpM5fqVQg5Q2sywXD/D9gJhf986/wr3fbD3JbEtNpho/AAH87vHDaefhJdR Yk4+w4Yv6c8eQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 65D5169101; Thu, 8 Jan 2026 11:52:52 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id o8bIN5BXLBZ1; Thu, 8 Jan 2026 11:52:52 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767898368; bh=EKOv4mB6l6bWNnkphU9QJFaEz12X4a+pKzcXzGWRgC8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OZvVC4wkf1hYaSu7+MnVK/4T71nZa2JqJSq3y+W3kl0u9wKvgcl+J5tjLGh13rCvG yJ/7ixz38/dpMwHt3wknEgeowfMQSGMT1dBP1oI6pDfg3v0x7kcJy1JpZZm8asTIgM 2av2lmlMsOgt26a83JEK56HI5ImXcSdDvhrwOd2C16OJTDf+etbwcdlbyMER+ICyPu 21d+meSurr33dpXsuw5HLwpk0p+cLtPN7OI1JDZyDn+2HXWcaG+F3YAIlH6yGRrQrI HsB1HKnQpJ5fSIvLbwBgnEma9DH2sv519opKDS44gVYUOyOQELcfBvou1B9OSdPyIU Hl30uH0Y9w95A== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 0A17469057; Thu, 8 Jan 2026 11:52:47 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Thu, 8 Jan 2026 11:51:27 -0700 Message-ID: <20260108185149.1995917-13-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260108185149.1995917-1-sjg@u-boot.org> References: <20260108185149.1995917-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: AXHBJJVPDGKIVKHRUT3YQQVG4KDWZFDU X-Message-ID-Hash: AXHBJJVPDGKIVKHRUT3YQQVG4KDWZFDU X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass , Claude X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 12/21] ext4l: Add a CONFIG_EXT4_MBALLOC_PREFETCH option List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass Add a Kconfig option to make mballoc prefetch support optional. The prefetch functions (ext4_mb_prefetch, ext4_mb_prefetch_fini) are used in Linux to optimise read performance by pre-loading block bitmaps during lazy initialisation. When disabled, guard the calls with IS_ENABLED() checks so gc-sections can remove the prefetch code. This removes the prefetch functions from the binary, reducing the external references to mballoc. Disable this by default as U-Boot is unlikely to gain any performance from this feature. It saves about 300 bytes. Co-developed-by: Claude Signed-off-by: Simon Glass --- fs/ext4l/Kconfig | 15 +++++++++++++++ fs/ext4l/mballoc.c | 5 ++++- fs/ext4l/super.c | 3 ++- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/fs/ext4l/Kconfig b/fs/ext4l/Kconfig index e494c66e8dc..3d7578f5073 100644 --- a/fs/ext4l/Kconfig +++ b/fs/ext4l/Kconfig @@ -110,3 +110,18 @@ config EXT4_INDIRECT Filesystems without the extents feature will be rejected if this is disabled. Adds about 5K. If unsure, say N. + +config EXT4_MBALLOC_PREFETCH + bool "Enable ext4 block bitmap prefetch support" + depends on FS_EXT4L + help + Enable prefetching of block allocation bitmaps to improve + allocation performance. When enabled, the multiblock allocator + will read ahead block bitmaps during allocation and lazy + initialization. + + Disabling this saves space by allowing the multiblock allocator + prefetch code to be removed. Read performance may be slightly + reduced during lazy initialization. + + If unsure, say Y. diff --git a/fs/ext4l/mballoc.c b/fs/ext4l/mballoc.c index 1643fd54f27..86ab374d686 100644 --- a/fs/ext4l/mballoc.c +++ b/fs/ext4l/mballoc.c @@ -2858,6 +2858,9 @@ static void ext4_mb_might_prefetch(struct ext4_allocation_context *ac, { struct ext4_sb_info *sbi; + if (!IS_ENABLED(CONFIG_EXT4_MBALLOC_PREFETCH)) + return; + if (ac->ac_prefetch_grp != group) return; @@ -3069,7 +3072,7 @@ out: ac->ac_b_ex.fe_len, ac->ac_o_ex.fe_len, ac->ac_status, ac->ac_flags, ac->ac_criteria, err); - if (ac->ac_prefetch_nr) + if (IS_ENABLED(CONFIG_EXT4_MBALLOC_PREFETCH) && ac->ac_prefetch_nr) ext4_mb_prefetch_fini(sb, ac->ac_prefetch_grp, ac->ac_prefetch_nr); return err; diff --git a/fs/ext4l/super.c b/fs/ext4l/super.c index 4bad3677db3..98785935f19 100644 --- a/fs/ext4l/super.c +++ b/fs/ext4l/super.c @@ -3663,7 +3663,8 @@ static int ext4_run_li_request(struct ext4_li_request *elr) int nr = EXT4_SB(sb)->s_mb_prefetch; u64 start_time; - if (elr->lr_mode == EXT4_LI_MODE_PREFETCH_BBITMAP) { + if (IS_ENABLED(CONFIG_EXT4_MBALLOC_PREFETCH) && + elr->lr_mode == EXT4_LI_MODE_PREFETCH_BBITMAP) { elr->lr_next_group = ext4_mb_prefetch(sb, group, nr, &prefetch_ios); ext4_mb_prefetch_fini(sb, elr->lr_next_group, nr); trace_ext4_prefetch_bitmaps(sb, group, elr->lr_next_group, nr);