Received: by 2002:a05:7412:f584:b0:e2:908c:2ebd with SMTP id eh4csp1942479rdb; Tue, 5 Sep 2023 09:23:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFTMaZ10GrUrhUV81Cy6sScpB+idff/OSsrj2I50JCCRWODd5SfUkRzvhF2my/pHv+31PXD X-Received: by 2002:a17:906:32c7:b0:9a5:9038:b1e7 with SMTP id k7-20020a17090632c700b009a59038b1e7mr273427ejk.36.1693931038617; Tue, 05 Sep 2023 09:23:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693931038; cv=none; d=google.com; s=arc-20160816; b=luRhozxV5CHCsmLfz/h0PjOxBThP4ERqVBM9YHMDrgl+oU9nUbLoGz5jthtVezBOdu eXv8Xo2puVHeA1Gk4g25tQXoD5cieOZJMZSiomWvgt783s6eDYwSEOYvX9ub+P53wi2a j8wr/JI6XFWoJ9H3yCMqDfzLeGFfeJrVtvFoajnNWRKi48cfvZjhuMoeJ3mwkf22mWIZ DLAES9JrI36NQwFk+KoEdp1e8XV06LtwpxWsSq+WdTaqKHFT+U78fv+/O6bZlZJVT72D f2P0iatYivIrf9ONCjGEu3F+mUYZyxA1njdpJQaFLJieEu0FklDU5SYendjgKSFalZ+Z X0xQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=sR+D5V6w6Qq1SltI9MYKs11ulmOe+c77VyqwFo26gw4=; fh=IkinaX4Oc0HFScsjYhryzNMMzeVjouhw/+7LERRLM8M=; b=UEM9ACafrxX0+Oyx0VfCmdmlSYi5u/6zLZif9Oqps+uDT+dEhXwfXmxDkayXvzySvm GqbtrzlxxsC/BZWhb/GSDjTB6y0ThipfcxLYIfgf/5RZ1EuZ8PlfZQR7DTzLc/xr+PIi xy3d/ZmuU+43RcmutFNq5IUyEBGveG936HMZ6XoEUG8clW58E3NuXcatVm+up8JzavFl KENjriT+8mmzO0sovgrumU9ez9JZs2Xg91sxp7yUcj6qOOwupv0z8BcD+66+2J6YqXNj NGS7WID71ohef0S4aRmtgGE3EUd98L40WWSV3u84bnsXTGUbaC+8UKNoHVhmx4/Y8bJK Rr5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=HEIhvP9x; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n4-20020a170906840400b00988565fbf63si7950323ejx.437.2023.09.05.09.23.54; Tue, 05 Sep 2023 09:23:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=HEIhvP9x; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242648AbjHaRAQ (ORCPT + 8 others); Thu, 31 Aug 2023 13:00:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35950 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243201AbjHaRAO (ORCPT ); Thu, 31 Aug 2023 13:00:14 -0400 Received: from mail-ed1-x541.google.com (mail-ed1-x541.google.com [IPv6:2a00:1450:4864:20::541]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BA9E18F for ; Thu, 31 Aug 2023 10:00:10 -0700 (PDT) Received: by mail-ed1-x541.google.com with SMTP id 4fb4d7f45d1cf-52a4b62c2f5so1352704a12.1 for ; Thu, 31 Aug 2023 10:00:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1693501209; x=1694106009; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=sR+D5V6w6Qq1SltI9MYKs11ulmOe+c77VyqwFo26gw4=; b=HEIhvP9xY6GqahXqynHtDmy85Za7aO3G5kC39Nsi0v/UMWvK5XXXm8TxBSggY8vc8H eiN83DM6/rL+bEGkRf8M3Lh4q/WapWjbTw94odnrCm5WSY/cC5EuacTqGg3c8rFxNBZ7 ZeM/hW3ypl5NS8zxaepc8Fc0fAjtJEqUs+rC0ytstRFfTaob8vO2/AfYVhiC6cOpLR7r b55s1bTbvcq65lM+NSk8MyaeELRMbmrZlVqoyelkSnTGuG4YOcqFORJSR5vwqYB4ZQBB 1Y5kuNNQYfXZFBGfZxoHM4S0EzL/MnO44ilXQYiR9rHPTgwGP4Gx0Op3siWRb2KdQte7 qNgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693501209; x=1694106009; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=sR+D5V6w6Qq1SltI9MYKs11ulmOe+c77VyqwFo26gw4=; b=kJjNTyk0ecYG5It5kygs9WESQPZnS8ptl10wACbZfMC8cETyprpN1ZnXe/stV7XQg1 zat0Ey5wHRoEE9JjMH0YmuWaFwnKW3+gESKCX0TM1xLYlFNwHd9xTSEtN+d2hPNKXBAQ 2uWowLjKI5uxZdY5zO/OiO/NodYwYhlNHu/cgPiUq+CAECtUArZkSPNCMsH8/Kl1Qkvv NBPdZWWpbMDUJEYFK6yxK0TT5/OgNWbySWPzHiygt+bBIsKgi5tiaoTVHvWmlxJdsvnx 13y3W52mNOWUnsLxg9fv+aogGeWjAFYocxLYme1NUt3WUut2NJBFwoosmalOWJU46byI BIow== X-Gm-Message-State: AOJu0YyPdhuQ0qBhS+bFvd/GdyBx4FlyXBMU4c9Bof21xjJ2mysxgFx/ 2eP4hftgIxWUpwhtGhpsAdaYuQ== X-Received: by 2002:a17:906:530c:b0:9a2:16e2:35c with SMTP id h12-20020a170906530c00b009a216e2035cmr4168284ejo.31.1693501209084; Thu, 31 Aug 2023 10:00:09 -0700 (PDT) Received: from localhost (2001-1ae9-1c2-4c00-20f-c6b4-1e57-7965.ip6.tmcz.cz. [2001:1ae9:1c2:4c00:20f:c6b4:1e57:7965]) by smtp.gmail.com with ESMTPSA id e19-20020a1709067e1300b009a198078c53sm934928ejr.214.2023.08.31.10.00.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Aug 2023 10:00:08 -0700 (PDT) Date: Thu, 31 Aug 2023 19:00:07 +0200 From: Andrew Jones To: Anup Patel Cc: "Wang, Xiao W" , Conor Dooley , Anup Patel , "paul.walmsley@sifive.com" , "palmer@dabbelt.com" , "aou@eecs.berkeley.edu" , "ardb@kernel.org" , "Li, Haicheng" , "linux-riscv@lists.infradead.org" , "linux-efi@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH] RISC-V: Optimize bitops with Zbb extension Message-ID: <20230831-f0f847c5703875f1e67635c1@orel> References: <20230806024715.3061589-1-xiao.w.wang@intel.com> <20230830-breeze-washboard-ef496d5c9d5a@wendy> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS 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 On Thu, Aug 31, 2023 at 09:37:30PM +0530, Anup Patel wrote: > +Andrew > > On Thu, Aug 31, 2023 at 9:29 PM Wang, Xiao W wrote: > > > > > > > -----Original Message----- > > > From: Conor Dooley > > > Sent: Wednesday, August 30, 2023 2:59 PM > > > To: Wang, Xiao W > > > Cc: Anup Patel ; paul.walmsley@sifive.com; > > > palmer@dabbelt.com; aou@eecs.berkeley.edu; ardb@kernel.org; Li, Haicheng > > > ; linux-riscv@lists.infradead.org; linux- > > > efi@vger.kernel.org; linux-kernel@vger.kernel.org > > > Subject: Re: [PATCH] RISC-V: Optimize bitops with Zbb extension > > > > > > On Wed, Aug 30, 2023 at 06:14:12AM +0000, Wang, Xiao W wrote: > > > > Hi, > > > > > > > > > -----Original Message----- > > > > > From: Anup Patel > > > > > Sent: Tuesday, August 29, 2023 7:08 PM > > > > > To: Wang, Xiao W > > > > > Cc: paul.walmsley@sifive.com; palmer@dabbelt.com; > > > > > aou@eecs.berkeley.edu; ardb@kernel.org; Li, Haicheng > > > > > ; linux-riscv@lists.infradead.org; linux- > > > > > efi@vger.kernel.org; linux-kernel@vger.kernel.org > > > > > Subject: Re: [PATCH] RISC-V: Optimize bitops with Zbb extension > > > > > > > > > > On Sun, Aug 6, 2023 at 8:09 AM Xiao Wang > > > wrote: > > > > > > > > > > > > This patch leverages the alternative mechanism to dynamically optimize > > > > > > bitops (including __ffs, __fls, ffs, fls) with Zbb instructions. When > > > > > > Zbb ext is not supported by the runtime CPU, legacy implementation is > > > > > > used. If Zbb is supported, then the optimized variants will be selected > > > > > > via alternative patching. > > > > > > > > > > > > The legacy bitops support is taken from the generic C implementation as > > > > > > fallback. > > > > > > > > > > > > If the parameter is a build-time constant, we leverage compiler builtin to > > > > > > calculate the result directly, this approach is inspired by x86 bitops > > > > > > implementation. > > > > > > > > > > > > EFI stub runs before the kernel, so alternative mechanism should not be > > > > > > used there, this patch introduces a macro EFI_NO_ALTERNATIVE for this > > > > > > purpose. > > > > > > > > > > I am getting the following compile error with this patch: > > > > > > > > > > GEN Makefile > > > > > UPD include/config/kernel.release > > > > > UPD include/generated/utsrelease.h > > > > > CC kernel/bounds.s > > > > > In file included from /home/anup/Work/riscv- > > > > > test/linux/include/linux/bitmap.h:9, > > > > > from > > > > > /home/anup/Work/riscv- > > > test/linux/arch/riscv/include/asm/cpufeature.h:9, > > > > > from > > > > > /home/anup/Work/riscv-test/linux/arch/riscv/include/asm/hwcap.h:90, > > > > > > > > > > > > It looks there's a cyclic header including, which leads to this build error. > > > > I checked https://github.com/kvm-riscv/linux/tree/master and > > > > https://github.com/torvalds/linux/tree/master, but I don't see > > > > "asm/cpufeature.h" is included in asm/hwcap.h:90, maybe I miss > > > something, > > > > could you help point me to the repo/branch I should work on? > > > > > > From MAINTAINERS: > > > RISC-V ARCHITECTURE > > > ... > > > T: git git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux.git > > > > > > The for-next branch there is what you should be basing work on top of. > > > AFAICT, you've made bitops.h include hwcap.h while cpufeature.h includes > > > both bitops.h (indirectly) and hwcap.h. > > > > Thanks for the info, but I can't reproduce Anup's build error with this for-next branch, cpufeature.h is not included by hwcap.h there. > > Maybe Anup could help double check the test environment? > > I figured that cpufeature.h included in hwcap.h is added by > Drew's patch "RISC-V: Enable cbo.zero in usermode" I think we should probably split hwcap.h into two parts. The defines stay and the rest can move to cpufeature.h Thanks, drew > > I had tried this patch on-top-of dev-upstream branch of > https://github.com/ventanamicro/linux.git > > Regards, > Anup > > > > > BRs, > > Xiao > > > > > > > > > > Hope that helps, > > > Conor. > > > > > > > > from > > > > > /home/anup/Work/riscv-test/linux/arch/riscv/include/asm/bitops.h:26, > > > > > from > > > > > /home/anup/Work/riscv-test/linux/include/linux/bitops.h:68, > > > > > from /home/anup/Work/riscv-test/linux/include/linux/log2.h:12, > > > > > from /home/anup/Work/riscv-test/linux/kernel/bounds.c:13: > > > > > /home/anup/Work/riscv-test/linux/include/linux/find.h: In function > > > > > 'find_next_bit': > > > > > /home/anup/Work/riscv-test/linux/include/linux/find.h:64:30: error: > > > > > implicit declaration of function '__ffs' > > > > > [-Werror=implicit-function-declaration] > > > > > 64 | return val ? __ffs(val) : size; > > > > > > > > > > Regards, > > > > > Anup > > > > > > > > > > > > > > > > > > > > > > Signed-off-by: Xiao Wang > > > > > > --- > > > > > > arch/riscv/include/asm/bitops.h | 266 > > > +++++++++++++++++++++++++- > > > > > > drivers/firmware/efi/libstub/Makefile | 2 +- > > > > > > 2 files changed, 264 insertions(+), 4 deletions(-) > > > > > > > > > > > > diff --git a/arch/riscv/include/asm/bitops.h > > > > > b/arch/riscv/include/asm/bitops.h > > > > > > index 3540b690944b..f727f6489cd5 100644 > > > > > > --- a/arch/riscv/include/asm/bitops.h > > > > > > +++ b/arch/riscv/include/asm/bitops.h > > > > > > @@ -15,13 +15,273 @@ > > > > > > #include > > > > > > #include