Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp911880ybm; Fri, 29 May 2020 15:30:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxjSEKYVHr+XaBSkVoHQe3T/4nUYpEYWYFbnXuOW9ABHoZWHh+perGAMYY4o4hbeEpVuOIC X-Received: by 2002:a05:6402:5:: with SMTP id d5mr10767454edu.247.1590791415936; Fri, 29 May 2020 15:30:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590791415; cv=none; d=google.com; s=arc-20160816; b=ruOykpgfzpgGw6ASepA58IzjFttkV5AexLSyzrJhDZPIx+d7Gr6MkMP4K8WlpmDwNt fUOhuyl3WuUxaUHEpUoJ7LAyBXkyOM3bOCVRlAABX2qq72MrljaZVaKaiqnLawEI3IE5 Kmt6Cspy67eLiq2aRTxOb95r3HAGHNE48vTakPjGAsK0UGJZqwxC6u6x/s3MAEHqRYCj /wQuJHbQbMv/zbyOeuzEaB5s6VG+bvcPQgUnG+SOQhoZaQk0Rsi2nmdPK9Ti+AHp4f0A H6KDGiVALB4AP/GebSqScpcNNlCC4hztUOW3MAj7AkxLMpLp7oSxcYaC5HjEVTgIysZN JXTw== 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:autocrypt:from:references:cc:to:subject; bh=uj3jOfu9sZgVkoy6z1bnGkhIhe/u5i7DZ1LHuEhUq4k=; b=Mc6m9OcnuCvhllM9VtpCoRH4RdIIZheiDtttPcQwKgK4vqbqyzGfT99190CeXNaMfw ADGdmkLMkYYpy5gzH+l34HPcjSGM3/0I8bV1a2iKif7QE35bY+lVwf2baA6YmvQ9/9vO 3s3C0i4zJmScO2sv4crd1EcRE8Sztp1XARm9vYJT40VhfT+qyHddCDWDOTocT1n5We8t eHPlCzwglUN2Lrp/ZGry9IEgEd0A9YozBSVXyTq0c3o0St1X+3XKBpogvtkOiIPX8uju Gf+2zgb6bE+ZR+x3BkG5SKoQJdta6V42jn0FyRkGJUtdqYud0hHPzAyJj3B2zZR5P+Oy fEZA== ARC-Authentication-Results: i=1; mx.google.com; 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 d17si5811906edr.224.2020.05.29.15.29.53; Fri, 29 May 2020 15:30:15 -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; 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 S1728443AbgE2W1g (ORCPT + 99 others); Fri, 29 May 2020 18:27:36 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:42618 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726555AbgE2W1f (ORCPT ); Fri, 29 May 2020 18:27:35 -0400 Received: by mail-pg1-f194.google.com with SMTP id 124so561987pgi.9; Fri, 29 May 2020 15:27:34 -0700 (PDT) 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:autocrypt :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=uj3jOfu9sZgVkoy6z1bnGkhIhe/u5i7DZ1LHuEhUq4k=; b=Zp84W9YBhzEuQVDht4RT4Bgh/LegkpN/NpaoFU1txX1eIk3LKYzAF38afS1381uh5Q fLJhTe4uk8bkN27mCxvDrcYKNNoQz64TsqSUnB5cuvsCTxP8btXVBLQeZJZUDXV0Iwoi LrnNbBG1sk2vhyDr3t9nK6Xqcx/W+cqtkKjClxqAgJU4kreJIOS1bLvkMxUnduQJ4gtS FCvKUxftRRm+mrOcABGy9dns5dTQbdLaPB9X1tari6aivXcb1OO8xM59sSDPEAYFRPug HsYQ9cXcY3h3SEZwJlLurgwkVqalLtu+vR9BeZPZbM6MTEmIPQjuP8M4rnT5FYdnf3L8 CDCw== X-Gm-Message-State: AOAM530oMJf8Wy40qTW1/tpYNFRLtWdA05LkE4MgdC102vx5UXua7aBB DOOhwgvcQvwiia+opHb7ssk= X-Received: by 2002:a63:1312:: with SMTP id i18mr10339525pgl.142.1590791254159; Fri, 29 May 2020 15:27:34 -0700 (PDT) Received: from ?IPv6:2601:647:4000:d7:9d55:11e:7174:3ec6? ([2601:647:4000:d7:9d55:11e:7174:3ec6]) by smtp.gmail.com with ESMTPSA id g7sm349470pjs.48.2020.05.29.15.27.31 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 29 May 2020 15:27:33 -0700 (PDT) Subject: Re: [PATCH v2] blkdev: Replace blksize_bits() with ilog2() To: Matthew Wilcox , 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, 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: Bart Van Assche Autocrypt: addr=bvanassche@acm.org; prefer-encrypt=mutual; keydata= mQENBFSOu4oBCADcRWxVUvkkvRmmwTwIjIJvZOu6wNm+dz5AF4z0FHW2KNZL3oheO3P8UZWr LQOrCfRcK8e/sIs2Y2D3Lg/SL7qqbMehGEYcJptu6mKkywBfoYbtBkVoJ/jQsi2H0vBiiCOy fmxMHIPcYxaJdXxrOG2UO4B60Y/BzE6OrPDT44w4cZA9DH5xialliWU447Bts8TJNa3lZKS1 AvW1ZklbvJfAJJAwzDih35LxU2fcWbmhPa7EO2DCv/LM1B10GBB/oQB5kvlq4aA2PSIWkqz4 3SI5kCPSsygD6wKnbRsvNn2mIACva6VHdm62A7xel5dJRfpQjXj2snd1F/YNoNc66UUTABEB AAG0JEJhcnQgVmFuIEFzc2NoZSA8YnZhbmFzc2NoZUBhY20ub3JnPokBOQQTAQIAIwUCVI67 igIbAwcLCQgHAwIBBhUIAgkKCwQWAgMBAh4BAheAAAoJEHFcPTXFzhAJ8QkH/1AdXblKL65M Y1Zk1bYKnkAb4a98LxCPm/pJBilvci6boefwlBDZ2NZuuYWYgyrehMB5H+q+Kq4P0IBbTqTa jTPAANn62A6jwJ0FnCn6YaM9TZQjM1F7LoDX3v+oAkaoXuq0dQ4hnxQNu792bi6QyVdZUvKc macVFVgfK9n04mL7RzjO3f+X4midKt/s+G+IPr4DGlrq+WH27eDbpUR3aYRk8EgbgGKvQFdD CEBFJi+5ZKOArmJVBSk21RHDpqyz6Vit3rjep7c1SN8s7NhVi9cjkKmMDM7KYhXkWc10lKx2 RTkFI30rkDm4U+JpdAd2+tP3tjGf9AyGGinpzE2XY1K5AQ0EVI67igEIAKiSyd0nECrgz+H5 PcFDGYQpGDMTl8MOPCKw/F3diXPuj2eql4xSbAdbUCJzk2ETif5s3twT2ER8cUTEVOaCEUY3 eOiaFgQ+nGLx4BXqqGewikPJCe+UBjFnH1m2/IFn4T9jPZkV8xlkKmDUqMK5EV9n3eQLkn5g lco+FepTtmbkSCCjd91EfThVbNYpVQ5ZjdBCXN66CKyJDMJ85HVr5rmXG/nqriTh6cv1l1Js T7AFvvPjUPknS6d+BETMhTkbGzoyS+sywEsQAgA+BMCxBH4LvUmHYhpS+W6CiZ3ZMxjO8Hgc ++w1mLeRUvda3i4/U8wDT3SWuHcB3DWlcppECLkAEQEAAYkBHwQYAQIACQUCVI67igIbDAAK CRBxXD01xc4QCZ4dB/0QrnEasxjM0PGeXK5hcZMT9Eo998alUfn5XU0RQDYdwp6/kMEXMdmT oH0F0xB3SQ8WVSXA9rrc4EBvZruWQ+5/zjVrhhfUAx12CzL4oQ9Ro2k45daYaonKTANYG22y //x8dLe2Fv1By4SKGhmzwH87uXxbTJAUxiWIi1np0z3/RDnoVyfmfbbL1DY7zf2hYXLLzsJR mSsED/1nlJ9Oq5fALdNEPgDyPUerqHxcmIub+pF0AzJoYHK5punqpqfGmqPbjxrJLPJfHVKy goMj5DlBMoYqEgpbwdUYkH6QdizJJCur4icy8GUNbisFYABeoJ91pnD4IGei3MTdvINSZI5e Message-ID: Date: Fri, 29 May 2020 15:27:30 -0700 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: <20200529202713.GC19604@bombadil.infradead.org> 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 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. Thanks, Bart.