Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="VtRBCOvJ" Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2EFB2CA for ; Tue, 5 Dec 2023 06:34:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=L8mYWXxlrXgsupSH2CXY7CTcm1b3JYzDyxWKSKXE7AQ=; b=VtRBCOvJXZaOm0qCWZ4nx2bDii OPYq0DP2A12j2OePosp4jQM0Z7MjE3XV1F4ZdK8atNcK+Xxws65+IYna4ScmREFXFqiQo/NoHLQ4H jz9sqnVk7EPlJE6m8OzVuIsquNq6VQgKf+mGKhimpM+RAHWcz4+gIdEEn+ebfFPf0Jv9babTiNN7d Blh6f7VdRocV+uUMo590Y94r/VfRnXRdvrNyAHQg9E3vYFQ0fmRc8ghCAXyt59HIcU+r1VyFrxYe/ mvvHMWCHvstddPypXhb62ZrstUsMFMBPxhBGah73uK+OS+5x1tWQCoizOSc01z0SCdJnhP/AvYlG8 RjxNh0rw==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1rAWUp-001xqw-Gb; Tue, 05 Dec 2023 14:33:59 +0000 Date: Tue, 5 Dec 2023 14:33:59 +0000 From: Matthew Wilcox To: John Sanpe Cc: linkinjeon@kernel.org, sj1557.seo@samsung.com, linux-fsdevel@vger.kernel.org, Andy.Wu@sony.com, Wataru.Aoyama@sony.com, cpgs@samsung.com Subject: Re: [PATCH v2] exfat/balloc: using hweight instead of internal logic Message-ID: References: <20231205043305.1557624-1-sanpeqf@gmail.com> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231205043305.1557624-1-sanpeqf@gmail.com> On Tue, Dec 05, 2023 at 12:33:05PM +0800, John Sanpe wrote: > Replace the internal table lookup algorithm with the hweight > library, which has instruction set acceleration capabilities. > > Use it to increase the length of a single calculation of > the exfat_find_free_bitmap function to the long type. Have you run sparse over this? "make C=2" will do it for you if you have sparse installed. I think it's going to complain about missing endianness annotations. > + for (i = 0; i < total_clus; i += BITS_PER_LONG) { > + bitmap = (void *)(sbi->vol_amap[map_i]->b_data + map_b); > + clu_bits = lel_to_cpu(*bitmap); I understand why you need to byteswap at the end, but I don't understand why you need to byteswap here. You're asking how many bits are set, and that's the same answer no matter whether you calculate it on 0x12345678 or on 0x78563412. > +++ b/fs/exfat/exfat_fs.h > @@ -136,6 +136,7 @@ enum { > #define BITMAP_OFFSET_BYTE_IN_SECTOR(sb, ent) \ > ((ent / BITS_PER_BYTE) & ((sb)->s_blocksize - 1)) > #define BITS_PER_BYTE_MASK 0x7 > +#define BITS_PER_LONG_MASK (BITS_PER_LONG - 1) I don't think this adds any value over just using (BITS_PER_LONG - 1) directly.