From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EBEFCC388F2 for ; Mon, 2 Nov 2020 15:10:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B61152074B for ; Mon, 2 Nov 2020 15:10:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726364AbgKBPKe (ORCPT ); Mon, 2 Nov 2020 10:10:34 -0500 Received: from mx2.suse.de ([195.135.220.15]:37124 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725817AbgKBPKc (ORCPT ); Mon, 2 Nov 2020 10:10:32 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 87C03B950; Mon, 2 Nov 2020 15:10:30 +0000 (UTC) Received: by ds.suse.cz (Postfix, from userid 10065) id 10558DA7D2; Mon, 2 Nov 2020 16:08:52 +0100 (CET) Date: Mon, 2 Nov 2020 16:08:51 +0100 From: David Sterba To: Johannes Thumshirn Cc: Qu Wenruo , David Sterba , "linux-btrfs@vger.kernel.org" Subject: Re: [PATCH 01/10] btrfs: use precalculated sectorsize_bits from fs_info Message-ID: <20201102150851.GD6756@twin.jikos.cz> Reply-To: dsterba@suse.cz Mail-Followup-To: dsterba@suse.cz, Johannes Thumshirn , Qu Wenruo , David Sterba , "linux-btrfs@vger.kernel.org" References: <5d586f76-7cad-b7be-60d3-44c8d3b67623@gmx.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23.1-rc1 (2014-03-12) Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org On Mon, Nov 02, 2020 at 02:31:35PM +0000, Johannes Thumshirn wrote: > On 02/11/2020 15:20, Qu Wenruo wrote: > > This may sounds like a nitpicking, but what about "ffs(4096) - 1"? > > IMHO it should be a little more faster than ilog2, especially when we > > have ensure all sector size is power of 2 already. > > Looking at the actual ilog2() implementation (and considering you're > passing 4096, a constant) you'll end up in const_ilog() which will > evaluate to 9. > > ffs() on the other hand on x86_64 will evaluate to a bfsl. So ffs() will > evaluated at runtime, while ilog2() at compile time. As the value is calculated only once for the whole filesystem lifetime, I'm not concerned about speed but readability.