Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp839721ybm; Fri, 29 May 2020 13:32:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwl3guJeIw1XdivG+MVuDu2uV3ohfz1qmTOYGtdMSXDky38+RTJoAKNm4up6jd4PBzfKPU8 X-Received: by 2002:a17:906:6a92:: with SMTP id p18mr9091582ejr.233.1590784358443; Fri, 29 May 2020 13:32:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590784358; cv=none; d=google.com; s=arc-20160816; b=C0smS7W63BdnUsp6A0HdICYoH14Eoo+pza9lYeMig8YsAJph7dU6S6AMocXgDNFDUD TPOE3hNVwZ8XuW8SFntL9bAePuAHBdujjO7+CyGpRIeiQu5mJT3JEaKNBkyLd1x4IJ7b FFt8NguIs2pMtXUI/WEs80oQQkHNFZUQrnxHN8CxRx5U2iFYjDDJGspHKhlAbffsQX6Z sFjBkG90bxJbf2V5vZpDm+yI2QW7ryS7gQk8Fl9dwUSWE3S5WGjiDqb1LHA3VzNVvQOs e5SpPTlpIRO7GlTVHPzCNISbZGuJxIS5ff0Pg2hqvfZ7bkZAPNrwQhgokvhWtNT0Q7DH ymbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=zPMXHGinvpmbOO2uHJoJ8DYwUQB9G7uW/4dEVS7cJ0I=; b=hgA2e5Em2H5ztGy6wUHjlgtMGzkI/Tg3lMlccJeCM0orQBJKC9lreryiNy3/zDvCKR MZEOojJZKOCFjU3rJ3Q9V7j4PpmNQh7pbSFAmzlMQa+dcQTRB90JHLwgdunWLkg5MoD4 pecKV9S10BtXSbzEOwTYKIGHaRmLrtosXmu2Of4LxwejKWy0DdJrOc+Pp4Q1rWFsh8Xx 18zEx6ZJJqCUcscZD433WERY8p4pqhek5MTmCkeJbAGHOPZB3S1rUJxB/sfSf/RgfT1t svlREH4DgeWy38FfrRd0ED1enFTZcYqvGtQ/4unloevHkQv00rQ+bYfCEePsL6UhoWqP eNjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=XqOxZivM; 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 k12si6458398ejx.675.2020.05.29.13.32.14; Fri, 29 May 2020 13:32:38 -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=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=XqOxZivM; 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 S1728138AbgE2U1e (ORCPT + 99 others); Fri, 29 May 2020 16:27:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726926AbgE2U1e (ORCPT ); Fri, 29 May 2020 16:27:34 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F0137C03E969; Fri, 29 May 2020 13:27:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.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=zPMXHGinvpmbOO2uHJoJ8DYwUQB9G7uW/4dEVS7cJ0I=; b=XqOxZivMEezkHFFqWL9Ubo1yCp jYuOb6sadXa65JFn7RehjWvI6opK1yjZQNHP+FDKbzLYVhzNUNA0D7wftRwkHW+pgbPcxnB0sEqaL sJhErbLN7ury7gOpdmM/R/bMc1mCd5cQQnOMfSMcdISKzShPzjyGTcZUh+Ep89jaovMmp1tWEn9ct kRirdyfCQoBe/cDzS1Xc/MQRw4h5hxdPUopYIEJ0glXskivBMitIDKEJj39t9CkkbIZdGp+f9dJXh +2HTf7n8uxWwyxrZuZN981ukwk2fuHPhi1ap6J+VubHIq6FfJrVSsQf4pMRUdII6H59MXDlDUQOJd a14fe67A==; Received: from willy by bombadil.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1jelaz-0008Ci-I1; Fri, 29 May 2020 20:27:13 +0000 Date: Fri, 29 May 2020 13:27:13 -0700 From: Matthew Wilcox To: Kaitao Cheng Cc: axboe@kernel.dk, 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, bvanassche@acm.org, 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 Subject: Re: [PATCH v2] blkdev: Replace blksize_bits() with ilog2() Message-ID: <20200529202713.GC19604@bombadil.infradead.org> References: <20200529141100.37519-1-pilgrimtao@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200529141100.37519-1-pilgrimtao@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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)