Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1683113iob; Thu, 19 May 2022 11:52:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx3XaKxUyzsIS5MD/JwEjQWREqcTFn3RjuwM7hAlJbYa5AIjEVNcDFX92p76qPQApamavSg X-Received: by 2002:a17:907:6e11:b0:6fe:7e13:345c with SMTP id sd17-20020a1709076e1100b006fe7e13345cmr5579773ejc.588.1652986376522; Thu, 19 May 2022 11:52:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652986376; cv=none; d=google.com; s=arc-20160816; b=hh4paOevORqpZAX2L+RNfcVP+c1pvrhY6EHS5MNxOB75CLr4BIg0oioz1JuehqgUzy REKNxt5IZXvBQem5Kzy1dQWGvTTDV5+cEldtWF7btdO3ZAhurMTM+/3qGQStZkTpWlhA 2gvmHvsCoLr6tE6sc5Qgw2thak3jzUaYqT3pa3o4IQuMT/n59dOLNdA6Yw231INxIVcq 1D7yEf3KbGqh+f65cDvO/5tQwyxUMcZXf2V1lH8waU4mMY/1lwX9y7pSGBPbSRov8X7M KJctlkpm/JSsXkGZAphelyChZFdCGznf9W4SZN5HcAexrg89vPK2/kA/BCAVkLg7pKKX QsCg== 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=pELL0kvd/H5+lVPyZcUIFeqfgLmY5zx3cTb88OjHg+c=; b=matOguOlbdi/BclXmUO0zDBjouYg2Lqq9QSoFgdx2aD4oWlZWkqr+brUz0zXgkl2uz XpV8QMOAmTFAUak6YXeYMwYAeJdb5af/113Ext9iWe07a5cXHFmlMVZus4pG75tp3ih3 0ZiC42IGDBNGS9VqX5AQmafONvBfhJHCXPYbGLKy9v09Ey6JXM7EVM1J9GedTpL8GNGA QG2tVXGhiBkfbkTBCwqs0HJvVL0TWbvnrx0NFIVDekMgfC+/Jlh/CgEKYus0AMuR1yrW 7VJBZMfYbcGkpjPGg+Hp6FulVGMhfJ16q51GAoGgevVq5gQ9VJcCveAm4NBccMeF+gqH b2qg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=g26P3IuH; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id mp22-20020a1709071b1600b006f4a3a09585si7050478ejc.782.2022.05.19.11.52.30; Thu, 19 May 2022 11:52:56 -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=@kernel.org header.s=k20201202 header.b=g26P3IuH; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238443AbiESQIC (ORCPT + 99 others); Thu, 19 May 2022 12:08:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54672 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241737AbiESQH7 (ORCPT ); Thu, 19 May 2022 12:07:59 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E27334A3F6 for ; Thu, 19 May 2022 09:07:58 -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 ams.source.kernel.org (Postfix) with ESMTPS id 87D99B82520 for ; Thu, 19 May 2022 16:07:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 06A04C385AA; Thu, 19 May 2022 16:07:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1652976476; bh=jC9MZ56f6/y27GJlqudr3bwdHks9u/b7P6hjWSqT9ek=; h=From:To:Cc:Subject:Date:From; b=g26P3IuHY37nxhFCaqTOhYp/GEhMEQQhn/N/pE36Wbfp1AJ8D1gPD0Gx6H81PpzNo QsO0b/8lGWtzjC+3QO5y1Hj5EBu/7GgQW+CEXFA6Nx+HRnIZVUtfzaOVcqdfXKq2pz Mnb0FasGOQ34/dHbzc+nIowXPfnXr1weW61xJHcu+4JYlgEpHr3c0B8IasZ1A1wbHE dj48YH9X3qWtoV7U6KkyvRhYvUiZitKO+/dWc/Angsu2xeiqNbnNNyDjFCXoJsgv1T l0h13nMlVe6cqV8MT0Zkul7ubXXatoGz4MWQzRBySkfX6KXjiTGSoOgaNp77A+1gSB sqiwsvDPC+bcw== From: Jisheng Zhang To: Paul Walmsley , Palmer Dabbelt , Albert Ou , Andrey Ryabinin , Alexander Potapenko , Andrey Konovalov , Dmitry Vyukov , Vincenzo Frascino , Alexandre Ghiti , Anup Patel , Atish Patra Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com Subject: [PATCH v3 0/2] use static key to optimize pgtable_l4_enabled Date: Thu, 19 May 2022 23:59:16 +0800 Message-Id: <20220519155918.3882-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=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 The pgtable_l4|[l5]_enabled check sits at hot code path, performance is impacted a lot. Since pgtable_l4|[l5]_enabled isn't changed after boot, so static key can be used to solve the issue[1]. An unified way static key was introduced in [2], but it's only targets riscv isa extension. We dunno whether SV48 and SV57 will be considered as isa extension, so the unified solution isn't used for pgtable_l4[l5]_enabled. patch1 fix a NULL pointer deference if static key is used a bit earlier. patch2 uses the static key to optimize pgtable_l4|[l5]_enabled. [1] http://lists.infradead.org/pipermail/linux-riscv/2021-December/011164.html [2] https://lore.kernel.org/linux-riscv/20220517184453.3558-1-jszhang@kernel.org/T/#t Since v2: - move the W=1 warning fix to a separate patch - move the unified way to use static key to a new patch series. 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 (2): riscv: move sbi_init() earlier before jump_label_init() riscv: turn pgtable_l4|[l5]_enabled to static key for RV64 arch/riscv/include/asm/pgalloc.h | 16 ++++---- arch/riscv/include/asm/pgtable-32.h | 3 ++ arch/riscv/include/asm/pgtable-64.h | 59 +++++++++++++++++--------- arch/riscv/include/asm/pgtable.h | 5 +-- arch/riscv/kernel/cpu.c | 4 +- arch/riscv/kernel/setup.c | 2 +- arch/riscv/mm/init.c | 64 ++++++++++++++++++----------- arch/riscv/mm/kasan_init.c | 16 ++++---- 8 files changed, 103 insertions(+), 66 deletions(-) -- 2.34.1