Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp919713ybm; Fri, 29 May 2020 15:44:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyQ6RkpMXTEO6gmNege93Y+eNC1y0aOsPyi2YP2g9Q7NLFWdX98N78SLG2AUS4iDwmEkjcC X-Received: by 2002:a17:906:6d44:: with SMTP id a4mr10216548ejt.541.1590792240061; Fri, 29 May 2020 15:44:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590792240; cv=none; d=google.com; s=arc-20160816; b=xOpQTHuD1HV6BgHjtISwiQdZAbNj+Fh5nKFDcHsjN1RAbym/2b/e73QAmKu8ra0A6z zUm+DNaJOvcGP1tCct0GHAh0vbSUBseS7JKQM/CeAydjlNtEQMJHkVqasJ41H+SrgwCJ tE0npItpjmkdgzBiM0hGMujmUZfFpVCNsjtln2AV8GKn8dAWboAgFmJVMJBBdhPuFChq aTdZuGFFeXj3Kyz6GmS4LBlmbJ17iKsakzMwMGk3yguA0Hy31g/XPGLmcqb0kajo66i4 OqXP/UlYqULF8cCjdNNeavq8S+emohcE4wh8vrSLmAZvfwkPZoNbsG/Oxrna50TKLuz+ YpMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=3SvGI6+FW1/OhXjcYh+qu+PkvAZr4CU1sl+aHPi5BkI=; b=f5mPO60dJ5FRQ41001R6qALl9CypPtCZhpikHQSE9aNj3IIQu1vsBY+WidFzT4XoKJ k0hoPOEyCTXHWmsrnioAC79XBDWGva79GnI+Kz7SZISPicu+aKNdJWr/Bn2An7cCP/PR A4BG8IzME7CM1DOlLNfl9hRH3n2LVXcAwHNhjTO+iKN1aEG4S6fCNp6B2jCp2rC3AWXk vf7k6pc7JSBeE18swqmofKwDz8DbJx/rJ0nD+9QT83tOVYK82HYBftFPOsDtHcwwIzgF iu1sEGV4Zv6GptdWaO8FrzhwH4H7pHS9He+wsf53XHU6k5SZKWN1CFksGPIgGiYdp044 NdvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel-dk.20150623.gappssmtp.com header.s=20150623 header.b=nH1QiA+I; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 7si5434613edj.329.2020.05.29.15.43.35; Fri, 29 May 2020 15:44:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel-dk.20150623.gappssmtp.com header.s=20150623 header.b=nH1QiA+I; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728486AbgE2Wjd (ORCPT + 99 others); Fri, 29 May 2020 18:39:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60606 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727947AbgE2Wja (ORCPT ); Fri, 29 May 2020 18:39:30 -0400 Received: from mail-pj1-x1041.google.com (mail-pj1-x1041.google.com [IPv6:2607:f8b0:4864:20::1041]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC9B3C08C5C9 for ; Fri, 29 May 2020 15:39:30 -0700 (PDT) Received: by mail-pj1-x1041.google.com with SMTP id q24so2050226pjd.1 for ; Fri, 29 May 2020 15:39:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=3SvGI6+FW1/OhXjcYh+qu+PkvAZr4CU1sl+aHPi5BkI=; b=nH1QiA+IRSDYm41wzzYncwFaM+lrDNn8Ti2XFcAi4YlaUw9LztwixK0pLNSdeHIyB7 8bS61hIRSiOulx1iuyKF9nP4gpzLATvREps1+Y8sUHCTsMZ0rY+c1fgY5DukBD+Uegin 1lLKtDr7RDXHpyWblpi+B9d4Ujuc4xdGVonklbCjbzvYQPtHToJufcxLYyR+p+Kh98lg 7xb/aOq4xXK0qPSUlE/HFQp1mG3daOYUEb9TuOa7ktkFpy+7p82qFHo7IYkgx6GUZGuH 8zk1bdAi4lwNOoqsXYgm3MyTYkenX/Q/gJXp2zUQOgLiLCvj9OzabgNt4M4CpTJUiGsP 5U5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=3SvGI6+FW1/OhXjcYh+qu+PkvAZr4CU1sl+aHPi5BkI=; b=oXbXcwSdmvD/wfpLmhH2W03sWdFhc6s34reFOmtD8heYYm3ZStFpTibfzryHq/q3cO hIxvOnk0aTkDEoRxWQX06XC9kGYlBZ/2P30+K+vO6bi3/4X6Kf/aeWqYkpgP1ZAUFNGs Le9SXbAIXIPW09wsU051zVKFu2aAoBgSkPR01EdNWDRZu3lJk05Vo3BnZvZzl2jcy8nI odYss8huAf2S/0zaCzJuvwiCbDqNO/X6A/yAE9OUWi6/VVg4Vc7J1u2az7OkfQn+0b1P En16oIQ+u2I2aIgYDlnym8A9xTheFWvVDaghXXI41kbM28TGlFoOMtTmzIj/4kjHiSRT 7Onw== X-Gm-Message-State: AOAM532RSXjOIGlxSnia+CUgsVklxw6+H8v2zNT8Oewu0XGhsNYPbO32 i/7GZLWP6x44j6OP28K82efiKg== X-Received: by 2002:a17:90a:68cd:: with SMTP id q13mr11465889pjj.177.1590791970211; Fri, 29 May 2020 15:39:30 -0700 (PDT) Received: from [192.168.1.188] ([66.219.217.173]) by smtp.gmail.com with ESMTPSA id m22sm374695pjv.30.2020.05.29.15.39.27 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 29 May 2020 15:39:29 -0700 (PDT) Subject: Re: [PATCH v2] blkdev: Replace blksize_bits() with ilog2() To: Bart Van Assche , Matthew Wilcox , Kaitao Cheng Cc: hch@lst.de, sth@linux.ibm.com, viro@zeniv.linux.org.uk, clm@fb.com, jaegeuk@kernel.org, hch@infradead.org, mark@fasheh.com, dhowells@redhat.com, balbi@kernel.org, damien.lemoal@wdc.com, ming.lei@redhat.com, martin.petersen@oracle.com, satyat@google.com, chaitanya.kulkarni@wdc.com, houtao1@huawei.com, asml.silence@gmail.com, ajay.joshi@wdc.com, linux-kernel@vger.kernel.org, songmuchun@bytedance.com, hoeppner@linux.ibm.com, heiko.carstens@de.ibm.com, gor@linux.ibm.com, borntraeger@de.ibm.com, linux-s390@vger.kernel.org, sagi@grimberg.me, linux-nvme@lists.infradead.org, gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, josef@toxicpanda.com, dsterba@suse.com, linux-btrfs@vger.kernel.org, chao@kernel.org, linux-f2fs-devel@lists.sourceforge.net, darrick.wong@oracle.com, linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, jlbec@evilplan.org, joseph.qi@linux.alibaba.com, ocfs2-devel@oss.oracle.com, deepa.kernel@gmail.com References: <20200529141100.37519-1-pilgrimtao@gmail.com> <20200529202713.GC19604@bombadil.infradead.org> From: Jens Axboe Message-ID: Date: Fri, 29 May 2020 16:39:26 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 5/29/20 4:27 PM, Bart Van Assche wrote: > On 2020-05-29 13:27, Matthew Wilcox wrote: >> On Fri, May 29, 2020 at 10:11:00PM +0800, Kaitao Cheng wrote: >>> There is a function named ilog2() exist which can replace blksize. >>> The generated code will be shorter and more efficient on some >>> architecture, such as arm64. And ilog2() can be optimized according >>> to different architecture. >> >> We'd get the same benefit from a smaller patch with just: >> >> --- a/include/linux/blkdev.h >> +++ b/include/linux/blkdev.h >> @@ -1502,15 +1502,9 @@ static inline int blk_rq_aligned(struct request_queue *q, unsigned long addr, >> return !(addr & alignment) && !(len & alignment); >> } >> >> -/* assumes size > 256 */ >> static inline unsigned int blksize_bits(unsigned int size) >> { >> - unsigned int bits = 8; >> - do { >> - bits++; >> - size >>= 1; >> - } while (size > 256); >> - return bits; >> + return ilog2(size); >> } >> >> static inline unsigned int block_size(struct block_device *bdev) > > Hi Matthew, > > I had suggested to change all blksize_bits() calls into ilog2() calls > because I think that a single function to calculate the logarithm base 2 > is sufficient. I think this should be a two-parter: 1) Use the inode blkbits where appropriate 2) Then do this change I'm leaning towards just doing it in blksize_bits() instead of updating every caller, unless there aren't that many left once we've gone through patch 1. -- Jens Axboe