Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp2546733rdh; Sun, 29 Oct 2023 23:29:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IERQbDqyropr7r8pllzW0DXe8XCd6swVJzUD5DSC4h1ymHgjbk2z4dSVGUJU/xG0z+i/m6/ X-Received: by 2002:a05:6a20:3d82:b0:16b:9886:7eda with SMTP id s2-20020a056a203d8200b0016b98867edamr11061899pzi.35.1698647378314; Sun, 29 Oct 2023 23:29:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698647378; cv=none; d=google.com; s=arc-20160816; b=ZS7h+ulOMKe2MqTfrg+fYV8GqefC4ymd3QC6RkN48Od/+ECvgEJg8W5a/vrEjuj5ce btEgi4apF0MdaZN6PssimUcTkROensViImxqrEVG7jN/cL2LgVI9Xyp65lC4+JXP1f0R +AhVfSJW5mVxiJZij9LLBZg5kncqC4ZlDimq+BXFsMQLEgHjGavoqeKh6dFJEn8Xryvl zbcqPdifSlY6HEKA0aas8/HpsRaaown057KJ6JU16zIxtPYS0Mu3Z6pzLvIzK1pfLeLt MUyJof+7BelzkOHdvYN9FGd7MsbhTuxc3Bp5oc6Jui6MTnLrIlRG2LHKoAJ9CIkiiVi+ EAxw== 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=6Gn21Mj6/k+TSxiG2+ws+Et7kAJhlcOMYGbhOqBtOJY=; fh=RkeGhuPfJLw3dOdz/TW3CR/XPxSdgTwCG50xRVzq3IQ=; b=ZryA0u6dJkVuFRoenl1Rq1792tHMQKfJmX6a61puv/A2ZAcgIc4XfYE/F8NdpDqYFu wlZxezZjM7kEaspBlCdC7P//Q6RoVa38nOBejQ+FG9XR5EHTmSAVkv4YGLs5hwpthUdH unFBDabrVMt5SshCar8muMULNenkpawrM9Yu48ylQXqbxPbgCCWKNqML+0lV09bSZDUz torkHqI9Ru7RU7FelbR3yn4Jl4paLHgvMax5QENc5rKVLToJC3dauCX8XRcciigTz7i1 ka3NCXSMQksP+NNOnqXs/5Rnv7klVzRvWYnQJXbYHb25Ro2X0I2GRs1Qvv1adznAw25A srYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=KkzMygMp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id ks11-20020a170903084b00b001c9dfd47959si4627311plb.602.2023.10.29.23.29.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Oct 2023 23:29:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=KkzMygMp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 00CC380B5A00; Sun, 29 Oct 2023 23:29:36 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231395AbjJ3G3c (ORCPT + 99 others); Mon, 30 Oct 2023 02:29:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41980 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229514AbjJ3G33 (ORCPT ); Mon, 30 Oct 2023 02:29:29 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3DFF8C0; Sun, 29 Oct 2023 23:29:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1698647367; x=1730183367; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=EOx93d6rorzC+eSitj0kGZenM894c+BPrPvevSZ3o3Y=; b=KkzMygMpUft4VPXfdgss6dqrPlqbgzwm2FD4YVbvVoa/9tEVekb1jvyu dYgK5+u+OJ/vn9yoDt359k0FmUro90JMaRjdqD56YuNojfkTwyWV5t3v/ 4dren/HaxYW2mopAFalF7Uhh4TdId/6sW1ag831BYs6NlnYjOQKT3zoYT 1N8CXOQRAbTv0S8mVNQdczA+69LTjYVBF/Ozxir6TG9nbm53P+YhNxLZO EAFcCNex7wcRPoIuO5DmyMp5DnrqFb7CrLqRHbnuO5pof6r9Jwelnu+BD yMpnGAmjKfxAUVwCekdJ4z+ERREkwnPWKYfHqvoMHh4oO+p25wBIQd8ZW g==; X-IronPort-AV: E=McAfee;i="6600,9927,10878"; a="452277976" X-IronPort-AV: E=Sophos;i="6.03,262,1694761200"; d="scan'208";a="452277976" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Oct 2023 23:29:26 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10878"; a="903893068" X-IronPort-AV: E=Sophos;i="6.03,262,1694761200"; d="scan'208";a="903893068" Received: from xiao-desktop.sh.intel.com ([10.239.46.158]) by fmsmga001.fm.intel.com with ESMTP; 29 Oct 2023 23:29:22 -0700 From: Xiao Wang To: paul.walmsley@sifive.com, palmer@dabbelt.com, aou@eecs.berkeley.edu, ardb@kernel.org Cc: anup@brainfault.org, haicheng.li@intel.com, ajones@ventanamicro.com, yujie.liu@intel.com, charlie@rivosinc.com, linux-riscv@lists.infradead.org, linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org, Xiao Wang Subject: [PATCH v4 0/2] riscv: Optimize bitops with Zbb extension Date: Mon, 30 Oct 2023 14:39:02 +0800 Message-Id: <20231030063904.2116277-1-xiao.w.wang@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Sun, 29 Oct 2023 23:29:37 -0700 (PDT) Bitops optimization with specialized instructions is common practice in popular ISAs, this patch set uses RISC-V Zbb extension to optimize four bitops: __ffs, __fls, ffs and fls. The first patch rearranges the content in hwcap.h and cpufeature.h, it helps to avoid a cyclic header including issue for patch 2. The second patch leverages the alternative mechanism to dynamically apply this optimization. Thanks, Xiao v4: - Simplify the asm code in ffs() and fls() by moving general logic into C implementation. (Charlie) - Add a comment to decorating the large #ifdef block. (Charlie) - Link to v3: https://lore.kernel.org/all/20230926094655.3102758-1-xiao.w.wang@intel.com/ v3: - Fix riscv32 build issue reported by kernel test robot. V3 changes "hwcap.h" to "cpufeature.h" for files where cpu feature detection APIs are used. (Yujie) - Link to v2: https://lore.kernel.org/all/20230920074653.2509631-1-xiao.w.wang@intel.com/ v2: - Remove the "EFI_" prefix from macro name "EFI_NO_ALTERNATIVE" to make it generic. (Ard) - patch-1 is added, it's based on "RISC-V: Enable cbo.zero in usermode". (Andrew) - Link to v1: https://lore.kernel.org/all/20230806024715.3061589-1-xiao.w.wang@intel.com/ Xiao Wang (2): riscv: Rearrange hwcap.h and cpufeature.h riscv: Optimize bitops with Zbb extension arch/riscv/include/asm/bitops.h | 255 +++++++++++++++++++++++++- arch/riscv/include/asm/cpufeature.h | 83 +++++++++ arch/riscv/include/asm/elf.h | 2 +- arch/riscv/include/asm/hwcap.h | 91 --------- arch/riscv/include/asm/pgtable.h | 1 + arch/riscv/include/asm/switch_to.h | 2 +- arch/riscv/include/asm/vector.h | 2 +- arch/riscv/kvm/aia.c | 2 +- arch/riscv/kvm/main.c | 2 +- arch/riscv/kvm/tlb.c | 2 +- arch/riscv/kvm/vcpu_fp.c | 2 +- arch/riscv/kvm/vcpu_onereg.c | 2 +- arch/riscv/kvm/vcpu_vector.c | 2 +- drivers/bitopstest/Kconfig | 1 + drivers/clocksource/timer-riscv.c | 2 +- drivers/firmware/efi/libstub/Makefile | 2 +- drivers/perf/riscv_pmu_sbi.c | 2 +- 17 files changed, 349 insertions(+), 106 deletions(-) -- 2.25.1