Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp1824979iog; Sat, 25 Jun 2022 22:07:04 -0700 (PDT) X-Google-Smtp-Source: AGRyM1voQEsEx7ZYaazwZHD2oGv4gnS328PbbYOO7cGcPjMmOy5uD0U2qDHlBWA8x4J3Ns+OVyLN X-Received: by 2002:a17:906:72cf:b0:722:e1a4:25 with SMTP id m15-20020a17090672cf00b00722e1a40025mr6653472ejl.205.1656220024170; Sat, 25 Jun 2022 22:07:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656220024; cv=none; d=google.com; s=arc-20160816; b=HjEd0LDPw8K5kiRt1uIDsqQECcDuiazCCjxaf8N6Q5ytqP5ElU+e1G+hEcIrUuT5sd gHxxSQzM+bSogqPWfTS+TuXJ+S7QzIPOXBz5krEVDHKBm2o38CiJuLWfaqNmIGdnur93 z1AfpOb/BBfESyhGnZrXkSMcEImPjTnvxOH+27tMEK+jtxYmui1dXORl32+YNdhFob57 LJMT9VMgSO/ibWBIRR3LC6ENSExLnr1BnTT1E9c2KpUDA1P05McyMn421DMeiOFrrOqA jD8r+9/xhcXsl/9naiZF5kJ/2M5w5QcQAuntW5ZCkjTcyupqgDN8iZpFphoicQuLbfOo Zx/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=2kWtI1K8FBljQi8An/wyVTdiQqFYwSP32gsF9BQJ03c=; b=dGDEAYpCFsCe5a3sgSb8RXwvBhF/Y5JEXZS7Pae01Cmv8cIAPsmb1VV6hF4WkWF051 EU1bhzqhQdpQrUnf1eNFqFPsBnq6sIAbbzXOYE2MnP87twRHs7cy1o7PISNB3Svu1jUy QknJkoNH8rYe2msRomZTVFxyRy/UK66YRDPjieZmTj8Y3Xp0n/x7BvSan1Fn4sBdahBF hDE57XUCAs/a3ujraHPTZwUcH/A9l4f4zqKEXGIc/W6RJ56DJ/YvpZ63THQuSHzAXZ/6 QXTa/k6IgQKbLCRuVD1MD68Q61czCEJfTYTXbHZDRqocjckK5CL2vVZY7lsSWTM2nMW7 q5YA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@brainfault-org.20210112.gappssmtp.com header.s=20210112 header.b=FrZZoDyu; 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 gn19-20020a1709070d1300b007121bfeedb8si8284922ejc.665.2022.06.25.22.06.09; Sat, 25 Jun 2022 22:07:04 -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=@brainfault-org.20210112.gappssmtp.com header.s=20210112 header.b=FrZZoDyu; 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 S233907AbiFZEdY (ORCPT + 99 others); Sun, 26 Jun 2022 00:33:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229481AbiFZEdX (ORCPT ); Sun, 26 Jun 2022 00:33:23 -0400 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 14E5EE009 for ; Sat, 25 Jun 2022 21:33:21 -0700 (PDT) Received: by mail-wm1-x334.google.com with SMTP id l126-20020a1c2584000000b0039c1a10507fso3670176wml.1 for ; Sat, 25 Jun 2022 21:33:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brainfault-org.20210112.gappssmtp.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=2kWtI1K8FBljQi8An/wyVTdiQqFYwSP32gsF9BQJ03c=; b=FrZZoDyueMWB46rAlqAH1OYPceblyGuoIYSuiJh9AP7soufPKW1Jm2zZlInD7vPgfI NdGX3xp4zNoqaACVAwsX+sYkPJm2kTFMCDSR2Ble7RTZVx4h5yM9Jw3Ne9acSpNBuH9a pOpSHXejHqY/PixidKUtyNYZ2wsP77du0gW5ht7HC/sE3XMHwI5ks7yjJVy8tNZRRnxp nuAYvLzeZTEeBv/e9XwsTzNXD+GY5Svw2Gqe0rRRmur2BeMr1Y6eEKv/zqvBj0HQta4H djnLpYv0J0I1qlh3c4tQJKQuPXbyVejuRk9BzjOClEUAiH/eUHlQ342iTEhIRspr6YYU 0mEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=2kWtI1K8FBljQi8An/wyVTdiQqFYwSP32gsF9BQJ03c=; b=hcoCPF+6ySbBsqj1q0DEFonyw/YoDyJS5+7DjPn00XLEUtPxha4jG3CbiMdfrkI9YU xHObsWcSKCJmh67gqiI3VXZLK5IYZo9me7SP6Rh1aQbyppoBharZZcKhqQ56KGThcS8X 4rd3KVlKX+95XuA6D7qdgBb51zdGFxYxA5X79H0+hvajf7+/9wYZBZn8f+KX91jbAkAW R/DK+yx29cYqCg6aZjLQFU/OCaPvpjwnyiqv9Cm6gN24MwOS9Dd9hif1sYsoto+XKCQD 0HYsdXCiK1k/NhVNubU6ouvOvfMHmZ+j6rM2fHyeKPgfeaZFcrIphHVRWKPF35wQYcKe XJQQ== X-Gm-Message-State: AJIora+C02LoxajKzvHyBs47wSqlgr7Wt4hDqwJRRWjYzxT8V+G3MzXE K6s4pVPW7IGoyy+VBsXxhG9PSddSd7o8spkGfVlO4Q== X-Received: by 2002:a05:600c:1d0b:b0:3a0:3ab8:924 with SMTP id l11-20020a05600c1d0b00b003a03ab80924mr7671319wms.137.1656217999456; Sat, 25 Jun 2022 21:33:19 -0700 (PDT) MIME-Version: 1.0 References: <20220521143456.2759-1-jszhang@kernel.org> In-Reply-To: <20220521143456.2759-1-jszhang@kernel.org> From: Anup Patel Date: Sun, 26 Jun 2022 10:03:07 +0530 Message-ID: Subject: Re: [PATCH v4 0/2] use static key to optimize pgtable_l4_enabled To: Jisheng Zhang Cc: Paul Walmsley , Palmer Dabbelt , Albert Ou , Andrey Ryabinin , Alexander Potapenko , Andrey Konovalov , Dmitry Vyukov , Vincenzo Frascino , Alexandre Ghiti , Atish Patra , linux-riscv , "linux-kernel@vger.kernel.org List" , kasan-dev@googlegroups.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE, 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 On Sat, May 21, 2022 at 8:13 PM Jisheng Zhang wrote: > > 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 performance issue[1]. > > An unified way static key was introduced in [2], but it 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 now. > > patch1 fixes 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 v3: > - fix W=1 call to undeclared function 'static_branch_likely' error > > 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 I have tested both these patches on QEMU RV64 and RV32. Tested-by: Anup Patel Thanks, Anup > > arch/riscv/include/asm/pgalloc.h | 16 ++++---- > arch/riscv/include/asm/pgtable-32.h | 3 ++ > arch/riscv/include/asm/pgtable-64.h | 60 ++++++++++++++++++--------- > 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, 104 insertions(+), 66 deletions(-) > > -- > 2.34.1 >