Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp2927835rdb; Mon, 4 Dec 2023 11:16:00 -0800 (PST) X-Google-Smtp-Source: AGHT+IHNc4zXJRiCMbVGkuav7bz14fV0e7USslcleYVT9dnCPMyGPr9T7Tp7i18qrVhvHETY/zhu X-Received: by 2002:a05:6a20:938a:b0:187:5a4d:7061 with SMTP id x10-20020a056a20938a00b001875a4d7061mr5953779pzh.44.1701717359736; Mon, 04 Dec 2023 11:15:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701717359; cv=none; d=google.com; s=arc-20160816; b=0RU/CjfBNl/qr5ziJbYCTCMcHncpeFf9BwNpQTIqRzujU8ILd173O7nWocCGniyG7G LWu3sPppdTGJZcXc3HE9LUcxmRkCxAc8NkeCCzPmRSlrkVty2YAj0zAAxt3MPJHBXLi1 WjCuqqEA4eRxx77tly6JCxOzxuBP0OTJ5DtcDzsWlLhXe3FiicmiuKScOJNRRjKIJpLg vyIHSwQDkqBgI2aqxt3w+sbp9WbGMI73q5ZhYO9m1YoB5CfgKjSpGDXhUOVZ8tmaUJZT BmwIZqAXsWtzNdZyhPflMSYd+Nk+e5BI8BwFdvavfxNMUsa4xNhQJ05TdAgnX/CuK1NN gvbw== 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-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=gLNCTARupzyNgRT6x18YzDTNwf+kcKqpIPYo+HCBokw=; fh=dSYYx3Rg9LpOGS2TtM4keeMsC4lId3wcKByJPICfG5M=; b=sM/092cVUJ+715XiotJxnqB6W+zZgqnKBFFsSAgCvaLnUJRm3UxEVp03B2r54HcdCJ fpR8YlU9cWYIhJd5Kse9Tw2BtIHbmH0cMsWumsAT0NKboG/OGFaJhBYBl9NL5tteV44L cYhhzc5iGCI48eM/FaTtd7JhtgeEJcNy0NXNqKisXmjfXqj1iL5bUvH4J2D1RLMDAA2H L+04wPSpzT/6d4/RWR4yhqTDBGGLpeo9qKQPUMvAH6SaVIKf3EqSuznnwSXliwkAxFf0 yCphUwtnwNdMAWncXCZfp05U+muhQz42a1Mh9ORFHN2kwrr42tzh2lL38AuGMt9zAc21 mm9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=Ff0SszFk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id l70-20020a639149000000b005c662c8da8csi4094613pge.210.2023.12.04.11.15.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 11:15:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=Ff0SszFk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 0A8C6805DEE4; Mon, 4 Dec 2023 11:15:46 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231463AbjLDTP1 (ORCPT + 99 others); Mon, 4 Dec 2023 14:15:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52088 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231462AbjLDTPZ (ORCPT ); Mon, 4 Dec 2023 14:15:25 -0500 Received: from mail-pl1-x633.google.com (mail-pl1-x633.google.com [IPv6:2607:f8b0:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 79BE0F0 for ; Mon, 4 Dec 2023 11:15:31 -0800 (PST) Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-1d08a924fcfso15053355ad.2 for ; Mon, 04 Dec 2023 11:15:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1701717331; x=1702322131; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=gLNCTARupzyNgRT6x18YzDTNwf+kcKqpIPYo+HCBokw=; b=Ff0SszFkRDHFuTfqGrKUu8hQOK7Psn8nGd2wZVcpKcdDbaNH6gMsMxR40SSVoFumnO jOM83kFfOTqUCajK3wdVPs7nXTtzJqWxQdq3VgC4PWSNsA6ozw8IDVtxSQ5MDwP3otWA pnqkaV9PPTm4V2fFnAI5rTfAaqDdLVQWndcipU4HTD0vPbeidHe5Pnzez1ZtN2RuQFuf tTMRZOPoWkN9C6vnCMIZxJF9/m9ZGBfxUe87+x1uy5v9M8VAzllo81tracMPmCrkDWx+ 5MFj4cuDEseksoZy2DSvEQIv0iZhPO+Tm3qvKoNqud/wuQMjL+7gCh4oxpT0vT3513OI aJqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701717331; x=1702322131; h=in-reply-to: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=gLNCTARupzyNgRT6x18YzDTNwf+kcKqpIPYo+HCBokw=; b=xCbgCE2T9yJsBS8UXius5xC4iWgYJPP82e6kdoq7ju/MFXn6K9oTmY1UxCuOk05oCt avkugjlXCLubFOaPAoVKhj+Xu7jJCTTvhqJRF0PmFqq3+Kal8Z0zQaC1Sck0zHdcPZ6V 4/WEYblx0fctZZtn7+Ve4Yq4cpucXeVd0O0O6NE1QSbayZq++TlR6FNacc00jHialFb4 g2meqeK+hOAGsvoUyskqInue5S+0n2EA7qcAIvtQDvU6iZPjoB6rqExiBZMLdHJo6ZJv o4VcMJslzlyOJbKtbbTBv9XncXA3WKU49zJOv+TX4cXe5QCeYxkRsoJQiD31y8KP9Q1+ bv6Q== X-Gm-Message-State: AOJu0YzD8OAX+YjAr4yxBykIs0HdJmmiG4PpGP9UxK8a80ZIhQosR3Z9 NzKlBHZDfh7VehcQ+avUbsXwfw== X-Received: by 2002:a17:902:e74f:b0:1d0:b503:2edb with SMTP id p15-20020a170902e74f00b001d0b5032edbmr1448349plf.69.1701717330853; Mon, 04 Dec 2023 11:15:30 -0800 (PST) Received: from ghost ([12.44.203.122]) by smtp.gmail.com with ESMTPSA id t11-20020a170902e84b00b001d076c2e346sm4731423plg.51.2023.12.04.11.15.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 11:15:30 -0800 (PST) Date: Mon, 4 Dec 2023 11:15:28 -0800 From: Charlie Jenkins To: Jisheng Zhang Cc: Paul Walmsley , Palmer Dabbelt , Albert Ou , Conor Dooley , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 1/2] riscv: introduce RISCV_EFFICIENT_UNALIGNED_ACCESS Message-ID: References: <20231203135753.1575-1-jszhang@kernel.org> <20231203135753.1575-2-jszhang@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231203135753.1575-2-jszhang@kernel.org> X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,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 pete.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 (pete.vger.email [0.0.0.0]); Mon, 04 Dec 2023 11:15:46 -0800 (PST) On Sun, Dec 03, 2023 at 09:57:52PM +0800, Jisheng Zhang wrote: > Some riscv implementations such as T-HEAD's C906, C908, C910 and C920 > support efficient unaligned access, for performance reason we want > to enable HAVE_EFFICIENT_UNALIGNED_ACCESS on these platforms. To > avoid performance regressions on other non efficient unaligned access > platforms, HAVE_EFFICIENT_UNALIGNED_ACCESS can't be globally selected. > > To solve this problem, runtime code patching based on the detected > speed is a good solution. But that's not easy, it involves lots of > work to modify vairous subsystems such as net, mm, lib and so on. > This can be done step by step. > > So let's take an easier solution: add support to efficient unaligned > access and hide the support under NONPORTABLE. > > Now let's introduce RISCV_EFFICIENT_UNALIGNED_ACCESS which depends on > NONPORTABLE, if users know during config time that the kernel will be > only run on those efficient unaligned access hw platforms, they can > enable it. Obviously, generic unified kernel Image shouldn't enable it. > > Signed-off-by: Jisheng Zhang > --- > arch/riscv/Kconfig | 12 ++++++++++++ > 1 file changed, 12 insertions(+) > > diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig > index 7f8aa25457ba..0a76209e9b02 100644 > --- a/arch/riscv/Kconfig > +++ b/arch/riscv/Kconfig > @@ -654,6 +654,18 @@ config RISCV_MISALIGNED > load/store for both kernel and userspace. When disable, misaligned > accesses will generate SIGBUS in userspace and panic in kernel. > > +config RISCV_EFFICIENT_UNALIGNED_ACCESS There already exists hwprobe for this purpose. If kernel code wants to leverage the efficient unaligned accesses of hardware, it can use static keys. I have a patch that will set this static key if the hardware was detected to have fast unaligned accesses: https://lore.kernel.org/linux-riscv/20231117-optimize_checksum-v11-2-7d9d954fe361@rivosinc.com/ - Charlie > + bool "Use unaligned access for some functions" > + depends on NONPORTABLE > + select HAVE_EFFICIENT_UNALIGNED_ACCESS > + default n > + help > + Say Y here if you want the kernel only run on hardware platforms which > + support efficient unaligned access, then unaligned access will be used > + in some functions for optimized performance. > + > + If unsure what to do here, say N. > + > endmenu # "Platform type" > > menu "Kernel features" > -- > 2.42.0 > > > _______________________________________________ > linux-riscv mailing list > linux-riscv@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-riscv