Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp308715ybg; Mon, 1 Jun 2020 01:46:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzengUKAh8fGt0pvUA4g/YNmcnwjmSC4Vv1FnSpnI3ndQ5NPi2sgKPgMX7S3fiS210s1/ys X-Received: by 2002:a17:906:c187:: with SMTP id g7mr15361567ejz.446.1591001197922; Mon, 01 Jun 2020 01:46:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591001197; cv=none; d=google.com; s=arc-20160816; b=kHQBxqAyBRNYjQp98YeWG9Sf+wisSBXhnPxlW8tRBDYz2wzdCtLSVH1mR/L93E5LIB YiagT1WLhUC5uqagMVdP95gq44HLzbhpZmYAYZIlQY30D9bnCL37halbAJEOljMEqOs7 zpQLaDSNXBJ6CwbuLPmDgXBAgHzjjyQdFB4CqBNXspfghDQ83xc5oGc7Grj9pWrXSYyv Urkfhm/JKk2iNENQ6ERRdmUB8SD9tcgLt+jfYvB/jqAcNqApVmeRlJelUCeYLFGsmZ6W OVlZu6/NlFpJkFsI8FIif7twxmbIMhkrlXljdAgDnBFZLy/0cKB9eDoKtWnVFsW3Qh+M Jf9g== 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=LUeDKl9lu4Ts/3E6O2r0fpaff2XnrGzDNWCZFZrIToY=; b=F6ahU2gawTBwdQtJKqxPQbngnV7nPgp7ATTKhikk0FyKIf44j3yB+OUUZMPjKWvdyv 610WrzRoSzPliXen44/oYbGEZyKGLqEuxYs+MTJIa5z7NSSIpsPvTh+tKl1Zrr3JPw/Y CgpWKbxe2N+TGZM5vPxCGRS2P6BV3PfTpOoDAnAvEqRclvKLE/dKRx2YN2XFN/bw8p/Q sEk4vQ6Mq7oNTdO5LS7/nBQsRDDu0EY4gZ5qDUazcFblRIbVXXzBPaGMuMH/R0fbjAOr tT5k7WnxghZcLkU2D9PmVB3r4mbJLYaLEa1ZQZAsyBq5ylaZAcfXKxHBa40fDNxR0Rz0 BdOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=wVfow37n; 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 dr16si13688962ejc.320.2020.06.01.01.46.14; Mon, 01 Jun 2020 01:46:37 -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.org header.s=default header.b=wVfow37n; 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 S1728282AbgFAIoa (ORCPT + 99 others); Mon, 1 Jun 2020 04:44:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:38832 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726142AbgFAIo3 (ORCPT ); Mon, 1 Jun 2020 04:44:29 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B0D94206E2; Mon, 1 Jun 2020 08:44:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591001068; bh=++2cB/ePJhne1YRp0fru1zBYoji5d1nprT5N9O4udpk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=wVfow37nJUctQuczEjtuvdKVbO338MPrWmtxn6qzZZHMLNELwOQlIvzJoFUuF/1kq q5DWi1Wf0naUXbCdA1uSgSP2CWJRK7dS8k1Y+Djaw8xRkHX+tVonEUHstDVdezlly+ CKUb/UU3oTLuSzgUFnUcgt1pHUYemwJpSNjNMHJk= Date: Mon, 1 Jun 2020 10:44:26 +0200 From: Greg KH To: Tao pilgrim Cc: Jens Axboe , hch@lst.de, sth@linux.ibm.com, viro@zeniv.linux.org.uk, clm@fb.com, jaegeuk@kernel.org, hch@infradead.org, Mark Fasheh , 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, Muchun Song , 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, linux-usb@vger.kernel.org, Josef Bacik , 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: <20200601084426.GB1667318@kroah.com> References: <20200529141100.37519-1-pilgrimtao@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 01, 2020 at 03:22:01PM +0800, Tao pilgrim wrote: > On Fri, May 29, 2020 at 10:13 PM Jens Axboe wrote: > > > > On 5/29/20 8:11 AM, 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. > > > > When you posted this last time, I said: > > > > "I like the simplification, but do you have any results to back up > > that claim? Is the generated code shorter? Runs faster?" > > > > Hi Jens Axboe: > > I did a test on ARM64. > unsigned int ckt_blksize(int size) > { > return blksize_bits(size); > } > unsigned int ckt_ilog2(int size) > { > return ilog2(size); > } > > When I compiled it into assembly code, I got the following result, > > 0000000000000088 : > 88: 2a0003e8 mov w8, w0 > 8c: 321d03e0 orr w0, wzr, #0x8 > 90: 11000400 add w0, w0, #0x1 > 94: 7108051f cmp w8, #0x201 > 98: 53017d08 lsr w8, w8, #1 > 9c: 54ffffa8 b.hi 90 > a0: d65f03c0 ret > a4: d503201f nop > > 00000000000000a8 : > a8: 320013e8 orr w8, wzr, #0x1f > ac: 5ac01009 clz w9, w0 > b0: 4b090108 sub w8, w8, w9 > b4: 7100001f cmp w0, #0x0 > b8: 5a9f1100 csinv w0, w8, wzr, ne > bc: d65f03c0 ret > > The generated code of ilog2 is shorter , and runs faster But does this code path actually show up anywhere that is actually measurable as mattering? If so, please show that benchmark results. thanks, greg k-h