From: Geert Uytterhoeven <geert@linux-m68k.org>
To: Josef Bacik <josef@toxicpanda.com>
Cc: linux-btrfs@vger.kernel.org, kernel-team@fb.com,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] btrfs: fix 64bit mod compile error
Date: Thu, 27 Jan 2022 09:23:57 +0100 (CET) [thread overview]
Message-ID: <alpine.DEB.2.22.394.2201270913080.2760701@ramsan.of.borg> (raw)
In-Reply-To: <139a265095afb1b3103d58bd3c8e19a89014db13.1643230494.git.josef@toxicpanda.com>
Hi Josef,
On Wed, 26 Jan 2022, Josef Bacik wrote:
> kernelbuild test bot complained about a 64bit % operation in the patch
>
> btrfs: add support for multiple global roots
>
> Fix this using div64_u64_rem. This can be folded in to the original
> patch.
>
> Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Thanks, this fixes the build error for me.
Tested-by: Geert Uytterhoeven <geert@linux-m68k.org>
> --- a/fs/btrfs/block-group.c
> +++ b/fs/btrfs/block-group.c
> @@ -2452,6 +2452,7 @@ void btrfs_create_pending_block_groups(struct btrfs_trans_handle *trans)
> static u64 calculate_global_root_id(struct btrfs_fs_info *fs_info, u64 offset)
> {
> u64 div = SZ_1G;
> + u64 index;
>
> if (!btrfs_fs_incompat(fs_info, EXTENT_TREE_V2))
> return BTRFS_FIRST_CHUNK_TREE_OBJECTID;
> @@ -2460,7 +2461,9 @@ static u64 calculate_global_root_id(struct btrfs_fs_info *fs_info, u64 offset)
> if (btrfs_super_total_bytes(fs_info->super_copy) <= (SZ_1G * 10ULL))
> div = SZ_128M;
>
> - return (div_u64(offset, div) % fs_info->nr_global_roots);
> + offset = div64_u64(offset, div);
On 32-bit, this is not implemented as a plain division, hence gcc is not
smart enough to notice that div is a power-of-two, and this can be
optimized to a shift.
Hence please make this explicit:
if (btrfs_super_total_bytes(fs_info->super_copy) <= (SZ_1G * 10ULL))
offset >>= ilog2(SZ_128M);
else
offset >>= ilog2(SZ_1G);
> + div64_u64_rem(offset, fs_info->nr_global_roots, &index);
Does the number fs_info->nr_global_roots have special properties,
i.e. can this expensive modulo operation be replaced by a shift, too?
> + return index;
> }
>
> struct btrfs_block_group *btrfs_make_block_group(struct btrfs_trans_handle *trans,
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
parent reply other threads:[~2022-01-27 8:24 UTC|newest]
Thread overview: expand[flat|nested] mbox.gz Atom feed
[parent not found: <139a265095afb1b3103d58bd3c8e19a89014db13.1643230494.git.josef@toxicpanda.com>]
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=alpine.DEB.2.22.394.2201270913080.2760701@ramsan.of.borg \
--to=geert@linux-m68k.org \
--cc=josef@toxicpanda.com \
--cc=kernel-team@fb.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).