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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 0552DC433E0 for ; Mon, 22 Mar 2021 15:12:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CC1B46199E for ; Mon, 22 Mar 2021 15:12:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231256AbhCVPML (ORCPT ); Mon, 22 Mar 2021 11:12:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231610AbhCVPLs (ORCPT ); Mon, 22 Mar 2021 11:11:48 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB101C061574; Mon, 22 Mar 2021 08:11:47 -0700 (PDT) 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=bWwMeij2Q8Z9ckhvEzwYdMKKVhuReAFZwXY42M3v8pY=; b=QHqf9Jaql6xFxojr6GQ10Pc+Ky paGncHPofAK6gMSBgB8PRlS0ehBLiHboidWgEfGYtoHUT/b6kuUO4Vn+sgEKa/ujftotzKrvZHmKD fCFC5LyTKeURZmUJGe2JaFVbvvshYWCPzkZaWKKMpnSPw5eXD2/tKD0QA0FkszkGpiP7LtkE0r+bE TPnttew8YgKRrnuN3tMCWCVxZhNhXKGBTGqh55ogenVyzY9Cj2KcSl9xY5A8toUI85HST5cTlJgzP DYoOlm4Um3Pt1SOR0bPDmoYyPBm2RT56CbK9J+4I6ltVKRtdZRHY7OU3ewp4XzHyyvn4Mb9etVrws QbiUk2mQ==; Received: from willy by casper.infradead.org with local (Exim 4.94 #2 (Red Hat Linux)) id 1lOMDE-008h9j-JS; Mon, 22 Mar 2021 15:11:29 +0000 Date: Mon, 22 Mar 2021 15:11:24 +0000 From: Matthew Wilcox To: Mikulas Patocka Cc: Alexander Viro , Jens Axboe , linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org Subject: Re: [PATCH] buffer: a small optimization in grow_buffers Message-ID: <20210322151124.GP1719932@casper.infradead.org> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org On Mon, Mar 22, 2021 at 10:05:05AM -0400, Mikulas Patocka wrote: > This patch replaces a loop with a "tzcnt" instruction. Are you sure that's an optimisation? The loop would execute very few times under normal circumstances (a maximum of three times on x86). Some numbers would be nice. > Signed-off-by: Mikulas Patocka > > Index: linux-2.6/fs/buffer.c > =================================================================== > --- linux-2.6.orig/fs/buffer.c > +++ linux-2.6/fs/buffer.c Are ... are you still using CVS?! > @@ -1020,11 +1020,7 @@ grow_buffers(struct block_device *bdev, > pgoff_t index; > int sizebits; > > - sizebits = -1; > - do { > - sizebits++; > - } while ((size << sizebits) < PAGE_SIZE); > - > + sizebits = PAGE_SHIFT - __ffs(size); > index = block >> sizebits; > > /* >