Received: by 2002:a05:7412:40d:b0:e2:908c:2ebd with SMTP id 13csp440556rdf; Tue, 21 Nov 2023 06:56:58 -0800 (PST) X-Google-Smtp-Source: AGHT+IHA0AAlgV2EbHsqAC2lD9KtcREEIE3gjOSqX4GoROfjJSYmxonKLsO57eqA7n1V1My4l8sK X-Received: by 2002:a17:902:8341:b0:1cc:3ae2:493f with SMTP id z1-20020a170902834100b001cc3ae2493fmr7867009pln.65.1700578617694; Tue, 21 Nov 2023 06:56:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700578617; cv=none; d=google.com; s=arc-20160816; b=dUS5yaoDQPe4L5J3nk/1BHYsX3Vq2M2NP3vkomlZFzx5acPd2CUIcXmgLre+LeFZKe ZAjQInDcUPKRCyXMAJjdmHqxww5IOdoxzVR/7/YTewK4uVVeG+Kv+p7uquF5kM41rHRj Rh6ioanW45SfckRm7dm+5UrzlpJvFke7rGDVyLG9FqjS3WWk/g7S8qxk3d0yW3MJRudl 68T6a7BUbf2z19U9YPLPvQPP2TF2/4PS6X00u7mZ2iqfoYEjbU3CQVXLbXNTci19cM/2 9xPGslR8CLut1UtDJ9G9mZv3774XViWgeT7jdQJ7k/pMVN4JGJ/kiGZHahkp5l9XS8Et SxoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=voscgaTtk8mmx5YY9RtNu+L2Yxf8hTOcpm6IodI57Ys=; fh=srb/EijQIrMEdOeqn3qQX6qrsAGyqHAqeSFkl/qDdLM=; b=lvqNME2DhGTKZwMo82V6xcblFx++RtaLACtmCuyqkRU8++QvOcncHKcDq5dwcwTjLA G2ma09WoUbq21UFdmk9IUN/gNWNvt7dB9q+f0ck67K0nNfUsCUT3ordoVYsUTOA8XCx2 gtz6J/ciw89sxoL7vqF1aQcdrKubtyHQ3VN1y0IR1FLBoDVzksmHFSwOlUnXiq3Gvpbn WEzPy47piDgbL6fyvWtVvDb3baJI9+Oa+pvV2ttv1nyk0YShVnfE3FkQ5XNtjOjOlyLo qt2yZLUsLiHOaRNa9JwjyW48j9tdv4UyKCfU4w6906TUXOysi7FWIkuVEElAmE/vbf2M SydQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="Vb3OCJ/b"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id y2-20020a170902864200b001c9d7d8860fsi10089889plt.485.2023.11.21.06.56.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 06:56:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="Vb3OCJ/b"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 623FF80A283E; Tue, 21 Nov 2023 06:56:28 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234023AbjKUO4R (ORCPT + 99 others); Tue, 21 Nov 2023 09:56:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230202AbjKUO4Q (ORCPT ); Tue, 21 Nov 2023 09:56:16 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F085A98 for ; Tue, 21 Nov 2023 06:56:12 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 598F7C433C8; Tue, 21 Nov 2023 14:56:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700578572; bh=goyE925j68b1sxQIGmM2p3n/Pv4DT5HZh2Zf6o8Dplk=; h=From:To:Cc:Subject:Date:From; b=Vb3OCJ/bzT++FdX+q066N3VO4wDu8sqSY6geuAKT9GNoRGC9D1r6P1G1TcZAA/I+f dr0Nv4SXyTP0TEH7MQWZjh3O8c8i3WguLumLdc2fnIHHKub12hMuywxBioal0TdnNg Ws1NOMoabop79fPpC4iO4jbBvpqDqz/n/DcR2366tYfx1M+7MIAJHgHBy9rT9nUJwJ GtUirmde6czIQGiAZ+n8cyktLgVq6A3bdVYp7fqhfjgIz8YMUnsBuDJEFgN9uUksxB BAW94RhNifuLk1BB3/hOw+gCG+0VZdKeWQvT8k712EKVWS/F7dTu8JsYlUppPuj0y1 FUKn9URfOxx/w== From: Jisheng Zhang To: Paul Walmsley , Palmer Dabbelt , Albert Ou Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] riscv: select ARCH_HAS_FAST_MULTIPLIER Date: Tue, 21 Nov 2023 22:43:40 +0800 Message-Id: <20231121144340.3492-1-jszhang@kernel.org> X-Mailer: git-send-email 2.40.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Tue, 21 Nov 2023 06:56:28 -0800 (PST) Currently, riscv linux requires at least IMA, so all platforms have a multiplier. And I assume the 'mul' efficiency is comparable or better than a sequence of five or so register-dependent arithmetic instructions. Select ARCH_HAS_FAST_MULTIPLIER to get slightly nicer codegen. Refer to commit f9b4192923fa ("[PATCH] bitops: hweight() speedup") for more details. In a simple benchmark test calling hweight64() in a loop, it got: about 14% preformance improvement on JH7110, tested on Milkv Mars. about 23% performance improvement on TH1520 and SG2042, tested on Sipeed LPI4A and SG2042 platform. a slight performance drop on CV1800B, tested on milkv duo. Among all riscv platforms in my hands, this is the only one which sees a slight performance drop. It means the 'mul' isn't quick enough. However, the situation exists on x86 too, for example, P4 doesn't have fast integer multiplies as said in the above commit, x86 also selects ARCH_HAS_FAST_MULTIPLIER. So let's select ARCH_HAS_FAST_MULTIPLIER which can benefit almost riscv platforms. Signed-off-by: Jisheng Zhang --- arch/riscv/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index 95a2a06acc6a..e4834fa76417 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -23,6 +23,7 @@ config RISCV select ARCH_HAS_DEBUG_VIRTUAL if MMU select ARCH_HAS_DEBUG_VM_PGTABLE select ARCH_HAS_DEBUG_WX + select ARCH_HAS_FAST_MULTIPLIER select ARCH_HAS_FORTIFY_SOURCE select ARCH_HAS_GCOV_PROFILE_ALL select ARCH_HAS_GIGANTIC_PAGE -- 2.42.0