Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp4797091iob; Mon, 9 May 2022 01:42:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxnaMoL1k9KMw3zvrAsOrJgTmQc963tCnWiefFUqWH4LofOH4GWWUvKZn3yoz1SEZ0XO2lg X-Received: by 2002:a05:6a00:198a:b0:50e:a2a:32e9 with SMTP id d10-20020a056a00198a00b0050e0a2a32e9mr14688475pfl.82.1652085773119; Mon, 09 May 2022 01:42:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652085773; cv=none; d=google.com; s=arc-20160816; b=HM31E+5HCq5Jh7GW3pPZY2uzg8uP2I3z4qNXiGOm2NNOf7FrlfK0x5mzA03WGevbfw 2zzqYo9gZ+SPdKySVaoG6NIrzWXvSQrKGlA2tow0Ptanpq40ZwP+VFCdXCSleOS4/q/I ejXeOSoextJzn0S/V6zUZVACXJSBLqSiVJgVzMPKvmTv6JumdAxnwGTwYNWhovWTnhr6 eHygda1nNGc8WT0T7cD0Qcdrzn68YOdGjMk686wPGMdaP83ynrxyNB7lffBeS/ZFfrr+ +5mWTjwG6BK+8Nrw5ybsvl672MvMW6J6VwAkiwaqqVANT7I8sdxU4XHjqVqJCrLqOxpN KxcA== 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=B19DiMbLsCNNTRla+mHgo37faAgif0bXsP1qBO+fYf8=; b=g9sdEqDceBKPvEBV5YiM+79xuI2bWUiYHVKwt+w1Tq3xVhiL/ZBsbcQ6w6yGCWSPWR 20mPpVYTl4CxRrkYtLu6kT/7yhT2yJpwLnGip23GQ9qVXiv5bBFZq3R/WwJyfbequQrb wGXGuX4UgzD2Ey7kw6/o9sd0UbOIaLqWGr7iu0Qj73a0/A7qdNkE3iE2ObDbHjT3fOdQ Ngbh5X+2AhRkqmiE7iCXGpe86Y2/Nwu8OMjhGRbuWxdHsWRZSderpU0q+Khqn0xCVmQS GyXEGOn69PZBvPhe8IV0zEUWUmqJ8l3AlNSl+R66iVsiHkyaNJG7S1JNTXB1+/ZPpdS7 5vtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=JGdlu0gL; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id c123-20020a633581000000b003c208b3b945si12593026pga.651.2022.05.09.01.42.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 May 2022 01:42:53 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=JGdlu0gL; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 6E4442CC87; Mon, 9 May 2022 01:27:11 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235472AbiEHQUR (ORCPT + 99 others); Sun, 8 May 2022 12:20:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38904 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235317AbiEHQUO (ORCPT ); Sun, 8 May 2022 12:20:14 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3FFA6116B for ; Sun, 8 May 2022 09:16:24 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D513A61214 for ; Sun, 8 May 2022 16:16:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D21AFC385AC; Sun, 8 May 2022 16:16:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1652026583; bh=CkIfvyZhn3UwDJ95LJhpy4E2fC0AEDACS/lXd1lmtwM=; h=From:To:Cc:Subject:Date:From; b=JGdlu0gLkAb4XE6UFvVOrQL6j2fjO/l6RdQhmATeanZ1iTdtm2tZFccq3eWQB9q+E VFBx+xKbpKkvYmW6Ei4J1Xo4vKGUPPIPf2Hxh0w/uvM0LVhvj8T27N4NfRJ1xUTIli XV2fOkCDlnt+GhlYNh0WckeoeJYrMGD4JtoHexNPrYFiNHNzy38X0t0zSZeQiYIHL3 yvDv9UZZHwV6MkL4hIZfUl0K8HIMed3lvnE5TxrK1eKT6k0UCCU1R/YYVwvFwQyLVo bHxiTLDjYh2p/jwA6Yzpz+Wf0RXNKz4B2Mcmkaswo5bwDY1RePoM6CX/QnrDqFkwLk /1qwsgtP83pqw== From: Jisheng Zhang To: Paul Walmsley , Palmer Dabbelt , Albert Ou , Andrey Ryabinin , Alexander Potapenko , Andrey Konovalov , Dmitry Vyukov , Vincenzo Frascino , Alexandre Ghiti Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com Subject: [PATCH v2 0/4] unified way to use static key and optimize pgtable_l4_enabled Date: Mon, 9 May 2022 00:07:45 +0800 Message-Id: <20220508160749.984-1-jszhang@kernel.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,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 lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently, riscv has several features which may not be supported on all riscv platforms, for example, FPU, SV48, SV57 and so on. To support unified kernel Image style, we need to check whether the feature is suportted or not. If the check sits at hot code path, then performance will be impacted a lot. static key can be used to solve the issue. In the past, FPU support has been converted to use static key mechanism. I believe we will have similar cases in the future. For example, the SV48 support can take advantage of static key[1]. patch1 is a simple W=1 warning fix. patch2 introduces an unified mechanism to use static key for riscv cpu features. patch3 converts has_cpu() to use the mechanism. patch4 uses the mechanism to optimize pgtable_l4|[l5]_enabled. [1] http://lists.infradead.org/pipermail/linux-riscv/2021-December/011164.html Since v1: - Add a W=1 warning fix - Fix W=1 error - Based on v5.18-rcN, since SV57 support is added, so convert pgtable_l5_enabled as well. Jisheng Zhang (4): riscv: mm: init: make pt_ops_set_[early|late|fixmap] static riscv: introduce unified static key mechanism for CPU features riscv: replace has_fpu() with system_supports_fpu() riscv: convert pgtable_l4|[l5]_enabled to static key arch/riscv/Makefile | 3 + arch/riscv/include/asm/cpufeature.h | 110 ++++++++++++++++++++++++++++ arch/riscv/include/asm/pgalloc.h | 16 ++-- arch/riscv/include/asm/pgtable-64.h | 40 +++++----- arch/riscv/include/asm/pgtable.h | 5 +- arch/riscv/include/asm/switch_to.h | 9 +-- arch/riscv/kernel/cpu.c | 4 +- arch/riscv/kernel/cpufeature.c | 29 ++++++-- arch/riscv/kernel/process.c | 2 +- arch/riscv/kernel/signal.c | 4 +- arch/riscv/mm/init.c | 52 ++++++------- arch/riscv/mm/kasan_init.c | 16 ++-- arch/riscv/tools/Makefile | 22 ++++++ arch/riscv/tools/cpucaps | 7 ++ arch/riscv/tools/gen-cpucaps.awk | 40 ++++++++++ 15 files changed, 274 insertions(+), 85 deletions(-) create mode 100644 arch/riscv/include/asm/cpufeature.h create mode 100644 arch/riscv/tools/Makefile create mode 100644 arch/riscv/tools/cpucaps create mode 100755 arch/riscv/tools/gen-cpucaps.awk -- 2.34.1