Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp3194429lqo; Wed, 15 May 2024 02:33:39 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWyn/gzqbMQULvwVBnqsGovYUulxjq2pmWRWKe1BShOZxXEpzX/rCzHfx/xTMjdyL1z7vfxLCcKWbKDNIRIX06ey5XpGDt5ufxNk1LApQ== X-Google-Smtp-Source: AGHT+IGlMbC8/Ek3rJ65OAg8P8Vn9fb/W0pQzsyquyeFBPFF8crmA5EaKNok4yKTkiX+4sYJfGhU X-Received: by 2002:a05:6102:3f12:b0:47c:2a61:ec9 with SMTP id ada2fe7eead31-48077e7b8fcmr15617503137.25.1715765619240; Wed, 15 May 2024 02:33:39 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715765619; cv=pass; d=google.com; s=arc-20160816; b=N6bh3UW44ID4/wRyuVngK6coc0GGYWAzE1/yCWmOFxmVw+M59ZeaG2MpJfLMTFR1Xb uEP3JzlM1ZbzXcT7yINZn8ZYdyoN4yZQ6RHVNLsTbdLabqY9oGaBtHRyAtRIFFq/EE80 jnGiafLuSjxjDBSFiX2OGYCeU57OcY7o/lvT3vCXn/GDUzTSngYYQj8r5hYfFqNeQxuK qFHP0O72SsuAtEP2OCKVB3GcF1lNCvUo1nCVBWdpJJEjWXj+F0/5dh8WXLLlZjCg2JtI mHapwI8ALTDzPlHkxF7NOwz5H4WMFqOjq9FG1OWOoCc4vlIofr8LBfnhbrjF1WJE8FQz b7zg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=KUvgc+RoOjTWSPPfPwHvbyfpoM1YVdi0iNncGhqtudY=; fh=y88exYlilyS39lxBPJyisPhIsyrNXNhPGs1VAC60vtk=; b=bzRFhYniiXx/Dc+LNmC+iJz7hD8z7VG3+oIYvKGTmwXzbJz3yilcA8Q9JXQ+976Omn bX89myzyjlTaSXqk5z9xuBAkrOfz7fW2zqrC6A9Jd2zJ4RzY+RHIOsmHEoj1Ko2dlfui elMUXJ4G0p4qACJYRLusQumXAx6FqgTfRFaXmNLj6Lgji0gWyHgylGCMHeLeftFX7Dxu dcFSFRJfvUJCdEOrFXudurbPKI0he1d3q4mBVSrsTNh5Yy2eh45hV0XEYBS+6DGzyxiy PISgBwQquZfTs+GZF9k3vad28JOLVw/6bHK0n1hycMz04CidzbNW+oXphpdUROqIPvhk 8qaA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=bUYC661A; arc=pass (i=1 spf=pass spfdomain=microchip.com dkim=pass dkdomain=microchip.com dmarc=pass fromdomain=microchip.com); spf=pass (google.com: domain of linux-kernel+bounces-179708-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-179708-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microchip.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id 6a1803df08f44-6a15f29aa6bsi139460426d6.203.2024.05.15.02.33.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 May 2024 02:33:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-179708-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=bUYC661A; arc=pass (i=1 spf=pass spfdomain=microchip.com dkim=pass dkdomain=microchip.com dmarc=pass fromdomain=microchip.com); spf=pass (google.com: domain of linux-kernel+bounces-179708-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-179708-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microchip.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id DE3511C2290B for ; Wed, 15 May 2024 09:33:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EC0BA59162; Wed, 15 May 2024 09:33:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=microchip.com header.i=@microchip.com header.b="bUYC661A" Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A59035914A; Wed, 15 May 2024 09:33:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=68.232.154.123 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715765611; cv=none; b=mOQF4YDotweZ2veiTaIeF5tTFlFxbTav6c/8uxgeAi015EkJyVnsD3erzUMXjufPAojuYyG/niXLQpGw6nm28YgKc0sGACMldM1F0hPfmole5rnmIFti/2fUROl+uix8wtUUqXMP9bepTX1gF7UUnvPECbAk1yOMf2ASxRKt/ZU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715765611; c=relaxed/simple; bh=dD5AnFYbetluj6XetlnnIHMeaNCVVsisEY7gFCjJiBg=; h=Date:From:To:CC:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Ab9Znuw5mVUf2YGqzL1m60ldeOw6MUg3bUW3HX4/Zd750aKJ6t9Z0KCAzlqitWL7yXGfkXdapEl59Hhm6eOI80N+bN7JCtFkJrm/R/MuwepBQiSvkSpnovI0xjRXcV0Ez0Puaajj9iGZATsXjx0KBD1mPLtghOC4qfaUidBJ8WQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=microchip.com; spf=pass smtp.mailfrom=microchip.com; dkim=pass (2048-bit key) header.d=microchip.com header.i=@microchip.com header.b=bUYC661A; arc=none smtp.client-ip=68.232.154.123 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=microchip.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=microchip.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1715765608; x=1747301608; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=dD5AnFYbetluj6XetlnnIHMeaNCVVsisEY7gFCjJiBg=; b=bUYC661AfbvnFe4zThhx+IU7b9nBd5/YAKMiLGwNqcDkMcQJ5nDRBSuo pWm+ibmzLsGGFb0K8iedUaAo2l1hbZNw2zG7uT9kqyoWhnnjqZYu5BhKi YE3iSEYR5gstZ9KZBlmWWFR1MXQFpNFxlFC/IL7d0FF2YwpNo5NJUzFw0 cBVJfT/kyodnDblwO4wDoXfyhh0DGovTKWRB7qvV645Ka03CtYqDBCr7f iQw9CQcfcpNSyx0qKKdx9TY3nVsw6G5RSeskxmToAFlKueLLY7l0I4TsA aWDP4yIE53+xBTqia8jo1SRnxOGmK55/uI51tx8Gjtkqk+4G2+rZ9vhJ6 g==; X-CSE-ConnectionGUID: EKg2bsSIT56NOUa44W/qLA== X-CSE-MsgGUID: ceVrxNbyQTCf2k1m/fEfXA== X-IronPort-AV: E=Sophos;i="6.08,161,1712646000"; d="asc'?scan'208";a="192161291" X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa6.microchip.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 15 May 2024 02:33:24 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.85.144) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Wed, 15 May 2024 02:33:04 -0700 Received: from wendy (10.10.85.11) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35 via Frontend Transport; Wed, 15 May 2024 02:33:00 -0700 Date: Wed, 15 May 2024 10:32:46 +0100 From: Conor Dooley To: Andrew Jones CC: "Wang, Xiao W" , "paul.walmsley@sifive.com" , "palmer@dabbelt.com" , "aou@eecs.berkeley.edu" , "luke.r.nels@gmail.com" , "xi.wang@gmail.com" , "bjorn@kernel.org" , "ast@kernel.org" , "daniel@iogearbox.net" , "andrii@kernel.org" , "martin.lau@linux.dev" , "eddyz87@gmail.com" , "song@kernel.org" , "yonghong.song@linux.dev" , "john.fastabend@gmail.com" , "kpsingh@kernel.org" , "sdf@google.com" , "haoluo@google.com" , "jolsa@kernel.org" , "linux-riscv@lists.infradead.org" , "linux-kernel@vger.kernel.org" , "bpf@vger.kernel.org" , "pulehui@huawei.com" , "Li, Haicheng" , "conor@kernel.org" , Ben Dooks Subject: Re: [PATCH v2] riscv, bpf: Optimize zextw insn with Zba extension Message-ID: <20240515-jogger-pummel-19fe4e9e8314@wendy> References: <20240511023436.3282285-1-xiao.w.wang@intel.com> <20240513-5c6f04fb4a29963c63d09aa2@orel> <20240514-944dec90b2c531d8b6c783f7@orel> <20240515-cone-getting-d17037b51e97@wendy> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="es0X3vLG906/aXNt" Content-Disposition: inline In-Reply-To: <20240515-cone-getting-d17037b51e97@wendy> --es0X3vLG906/aXNt Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, May 15, 2024 at 09:19:46AM +0100, Conor Dooley wrote: > On Tue, May 14, 2024 at 03:37:02PM +0200, Andrew Jones wrote: > > On Tue, May 14, 2024 at 07:36:04AM GMT, Wang, Xiao W wrote: > > > > From: Andrew Jones > >> > > > +config RISCV_ISA_ZBA > > > > > + bool "Zba extension support for bit manipulation instructions" > > > > > + depends on TOOLCHAIN_HAS_ZBA > > > >=20 > > > > We handcraft the instruction, so why do we need toolchain support? > > >=20 > > > Good point, we don't need toolchain support for this bpf jit case. > > >=20 > > > >=20 > > > > > + depends on RISCV_ALTERNATIVE > > > >=20 > > > > Also, while riscv_has_extension_likely() will be accelerated with > > > > RISCV_ALTERNATIVE, it's not required. > > >=20 > > > Agree, it's not required. For this bpf jit case, we should drop these= two dependencies. > > >=20 > > > BTW, Zbb is used in bpf jit, the usage there also doesn't depend on t= oolchain and > > > RISCV_ALTERNATIVE, but the Kconfig for RISCV_ISA_ZBB has forced the d= ependencies > > > due to Zbb assembly programming elsewhere. > > > Maybe we could just dynamically check the existence of RISCV_ISA_ZB* = before jit code > > > emission? or introduce new config options for bpf jit? I prefer the f= irst method and > > > welcome any comments. > >=20 > > My preferences is to remove as much of the TOOLCHAIN_HAS_ stuff as > > possible. We should audit the extensions which have them to see if > > they're really necessary. >=20 > While I think it is reasonable to allow the "RISCV_ISA_ZBB" option to > control whether or not bpf is allowed to use it for optimisations, only > allowing bpf to do that if there's toolchain support feels odd to me.. > Maybe we need to sorta steal from Charlie's patchset and introduce > some hidden options that have the toolchain dep that are used by the > alternative macros etc? >=20 > I'll have a poke at how bad that looks I think. I don't love this, in particular my option naming, but it would allow the Zbb optimisations in the kernel to not depend on toolchain support while not muddying the Kconfig waters for users: https://git.kernel.org/pub/scm/linux/kernel/git/conor/linux.git/commit/?h= =3Driscv-zbb_split A similar model could be followed if there were to be some optimisations for Zba in the future that do require toolchain support: --es0X3vLG906/aXNt Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYIAB0WIQRh246EGq/8RLhDjO14tDGHoIJi0gUCZkSBPgAKCRB4tDGHoIJi 0nCmAQCsoI65PD/ah3I73wtpDrzK+PCNiu2WNVR/dUBJlyt29AD9Gw6ZED7Qb42h L7QgyIUuoEoC+s9FgNEV/wpZUPvx9Qo= =gTNF -----END PGP SIGNATURE----- --es0X3vLG906/aXNt--