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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 55457C433EF for ; Tue, 21 Jun 2022 08:33:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E205B6B0072; Tue, 21 Jun 2022 04:33:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DD00F6B0073; Tue, 21 Jun 2022 04:33:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CBEF96B0074; Tue, 21 Jun 2022 04:33:42 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id BC84C6B0072 for ; Tue, 21 Jun 2022 04:33:42 -0400 (EDT) Received: from smtpin31.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 9644A60AA5 for ; Tue, 21 Jun 2022 08:33:42 +0000 (UTC) X-FDA: 79601579484.31.B0F818D Received: from mail-lj1-f182.google.com (mail-lj1-f182.google.com [209.85.208.182]) by imf25.hostedemail.com (Postfix) with ESMTP id 28F42A0017 for ; Tue, 21 Jun 2022 08:33:41 +0000 (UTC) Received: by mail-lj1-f182.google.com with SMTP id e4so14580885ljl.1 for ; Tue, 21 Jun 2022 01:33:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; h=message-id:date:mime-version:user-agent:subject:content-language:to :cc:references:from:in-reply-to:content-transfer-encoding; bh=HMKX9HopiKiPvhGo8pRtwogz/OTxkYemMdhWmz/2mng=; b=Qy2mzGsKIMehWP2l4RPCwSuNW+/nhWmw8gGlz2O7rBIkrT240/SyYyCXOPOPSc2jXQ hcvzdO1PoMRu6jnYKih17cqn8UEq6g28qgu8F5/Arna5pgwPtEkr+FZthih0/xMBosCF RTonsFPXUDXZ3GmXXTszStcZ/v+ulqFzTDOpQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=HMKX9HopiKiPvhGo8pRtwogz/OTxkYemMdhWmz/2mng=; b=fNQaGYYzdU9Nxtsb+lBX4TJou/44kXoM2feg7YGIVRnFpT5ixe0v6YXBF9ROeBaohc WKNZ7FecoNC5yIzoYjXVX8Sl5gTZPasVPqk4NW0CfMVd2jrwaC93dMH1AxwCTAeitTQR u09TCs3YpHrMf3p1GuPAs2V3BgyRfMYtdA1NSHJDWXyVHpjqtRkUhrHuyOYJ+haTkjf4 6tpSq3Zywx7NraON6Yv0udyk6nDWTxCvcPuDkqVSMrZ838t9K7PQDLmiVlkXrLAK9Z8n RWYYpV4eEef1LthtwR7HPCf6/zgVZtwGy6PmGU5NV+RHnuaZCCZMNa0UZmk3G0rIY2ap 38yw== X-Gm-Message-State: AJIora8TAXrLOjmZCRE0b+XJRLISCeZ6yi74KIXk/xdN56NVNyUsh41N RMVLe5zy3+11/yACMbTSXA5LZg== X-Google-Smtp-Source: AGRyM1tX4NfXPaR20sBdTb9CuobI/w5VS8VApwR8FCZHn6goqQEMtbYP6TXg974CHIdGDzMuVmycvg== X-Received: by 2002:a05:651c:50c:b0:25a:4504:95c with SMTP id o12-20020a05651c050c00b0025a4504095cmr13635771ljp.90.1655800419657; Tue, 21 Jun 2022 01:33:39 -0700 (PDT) Received: from [172.16.11.74] ([81.216.59.226]) by smtp.gmail.com with ESMTPSA id p12-20020ac24ecc000000b0047f7419de4asm605982lfr.180.2022.06.21.01.33.38 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 21 Jun 2022 01:33:38 -0700 (PDT) Message-ID: <82fb021d-31bb-4545-cbcc-a7622dbd2e0a@rasmusvillemoes.dk> Date: Tue, 21 Jun 2022 10:33:37 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: [PATCH v4 11/34] vsprintf: Improve number() Content-Language: en-US To: Kent Overstreet , linux-kernel@vger.kernel.org, linux-mm@kvack.org, pmladek@suse.com Cc: rostedt@goodmis.org, enozhatsky@chromium.org, willy@infradead.org References: <20220620004233.3805-1-kent.overstreet@gmail.com> <20220620004233.3805-12-kent.overstreet@gmail.com> From: Rasmus Villemoes In-Reply-To: <20220620004233.3805-12-kent.overstreet@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1655800421; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=HMKX9HopiKiPvhGo8pRtwogz/OTxkYemMdhWmz/2mng=; b=vz4s09PUcIAxek9aXQRdR5JdUkJ3q13Em3SNWW5yBhpn7v2ZHycVl1UWYEWAD2me9XmkT3 31a6pzs0jTSilEi+4tpxwVbP9Me/Hg3Jy0UA00s/rBc7jcw5DxDhjtduRSOvQ/ZAQ0aiiL SShpZr8VQi4R7EHP4TH2NPqJoXzIBko= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=rasmusvillemoes.dk header.s=google header.b=Qy2mzGsK; spf=pass (imf25.hostedemail.com: domain of linux@rasmusvillemoes.dk designates 209.85.208.182 as permitted sender) smtp.mailfrom=linux@rasmusvillemoes.dk; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655800421; a=rsa-sha256; cv=none; b=DU/soyEbIYyloXwLiCeY0YIJ59Sz3F2xiCsVi+3aeq/d33X5zi/b0gXi3nQoZhXh+cyQhn VT45/QIanFwyajVu55xgfFlomZb+WVtcZds9g2DLtKawdbKtI9QNtdlquBHPRLZhgeQiNc u2+pgVQ2KzQaBtFJYh2Ls6O+SfrNVvE= X-Stat-Signature: u5oz68bg1zxncodb6wj3upr18t8g3hhs X-Rspamd-Queue-Id: 28F42A0017 X-Rspamd-Server: rspam11 X-Rspam-User: Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=rasmusvillemoes.dk header.s=google header.b=Qy2mzGsK; spf=pass (imf25.hostedemail.com: domain of linux@rasmusvillemoes.dk designates 209.85.208.182 as permitted sender) smtp.mailfrom=linux@rasmusvillemoes.dk; dmarc=none X-HE-Tag: 1655800421-767997 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000001, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 20/06/2022 02.42, Kent Overstreet wrote: > /* generate full string in tmp[], in reverse order */ > - i = 0; > - if (num < spec.base) > - tmp[i++] = hex_asc_upper[num] | locase; Please don't remove that optimization in a patch titled "improve number()". > - else if (spec.base != 10) { /* 8 or 16 */ > + if (spec.base == 10) { > + nr_digits = put_dec(tmp, num) - tmp; > + } else { /* 8 or 16 */ > int mask = spec.base - 1; > - int shift = 3; > + int shift = ilog2((unsigned) spec.base); > > - if (spec.base == 16) > - shift = 4; So avoiding a branch here may be a good idea, but I'm not sure ilog2() is very efficient on all arches. Since we know that base is either 8 or 16, we could do "shift = (spec.base/8) + 2". Rasmus