Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1974721rwb; Thu, 8 Dec 2022 18:19:32 -0800 (PST) X-Google-Smtp-Source: AA0mqf79i8Rzas2bDfvkRUdow2xxNjM5M2LyxoyEc8e+WbjX9LQkF4UcwPxwELXPp4RVmwcZDjfB X-Received: by 2002:a05:6a21:170c:b0:a4:829f:dd35 with SMTP id nv12-20020a056a21170c00b000a4829fdd35mr4728381pzb.34.1670552371856; Thu, 08 Dec 2022 18:19:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670552371; cv=none; d=google.com; s=arc-20160816; b=jbmEMG61ba9xt/vanVukSb+NrZZPV7zh4ZNmzYBYJqJD/wRXZO6R+eyv9REF8r6maK /QyUZSxU5me1l37PWPK+pJL6ZhR/5bBEv+OykSJPb+sTe99PV9GokainlCe3UbaTHpHv 12yJvTCnpdJAE4l97bvihl80ysF77Zcj48ZjNYtvwZsnUuD4VIGTDcWw/bUgw8jAeNRw wQL4mIwWdRyeIzuVtYyz2ynzj5+37AE8mCcORcpj7SpWYt9DvUZwDYI059mujkrMT41f ubQcldcmOMLyTOe9TkSqV2dBP0J0hHl8jAr3f19g953T1RKnfER+GZFboptuLxPi07xs SWBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=n2SwE8hvPKRbaIyAauGYmpLP9Qs9kbT85lBGE+R7LrQ=; b=LitaucDtFDK6YdQslB1LXAIMtydUMcD13J6LtwuxbrnAgxnYmAG/cBNRRKae+d4tp0 u5e7Ev95FnuFqI1sbN0ah3K7UMjysUXJRAEqkP4HZQ4gjaMf80+OjhbcDje3Jr5P6wGj On4ENFq5W6H/x4Amb6oflLa96slFDfaVxiPr9kAkGQbQJckDOsCwkSUGRlYg1DkJIRXu jMkRV0HuwxRkv1m2J9yFzWpY+8YqOTqxv+pA+VKtNQ4uVsu/XQcz3A0z0aRz0vdPt3ns Lxn+p/RVMuoiUCOtB8jUx5LXNVtoGlQojv/yBsIfUsuz4wM8pSaEONXNHN9W9OK35Iq0 NhZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=D9c2U83O; 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 130-20020a630088000000b00478ebd3d4d8si228208pga.633.2022.12.08.18.19.21; Thu, 08 Dec 2022 18:19:31 -0800 (PST) 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=D9c2U83O; 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 S229550AbiLICKH (ORCPT + 74 others); Thu, 8 Dec 2022 21:10:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40654 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229462AbiLICKF (ORCPT ); Thu, 8 Dec 2022 21:10:05 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 710A464EC; Thu, 8 Dec 2022 18:10:04 -0800 (PST) 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 DFB2762119; Fri, 9 Dec 2022 02:10:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4A56FC433B4; Fri, 9 Dec 2022 02:10:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1670551803; bh=Ia3V72Uk7M4KXmgjLjEt+8wDzqEqpUXfSTB4GcRrC0s=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=D9c2U83ObEmD3eWcNvD9nAYLfsSKLqytAljVRtOqFbLravBvSJh76EWTTYjb3xbSD 2A4mfWTkFJNHkKEdXkdov4ZXzkq570D2LIl/2YhhUcSE4rD1XDeasAAKlzr/ZYw1Ms xcNjmDJrnGmdrsHMbKmlTLOfbQ2f8sbDDAzgnC+lLRFMAg9q+wEEKnQfci5bK2vsg1 ZvB04ge3qN5XyTZQK/KH1t8Me+SZH6fp734MAeqIM7ifIrRxL2oh2/iAc5/uwEqqxo eyLLaRIp3GCjx0Us81ZS2VOuIL1z+/NYvrQvY/751t73Pj36ZAZ4CODEzak6BIjFOf 8MrjDP+tfFSxg== Received: by mail-ej1-f50.google.com with SMTP id b2so8289676eja.7; Thu, 08 Dec 2022 18:10:03 -0800 (PST) X-Gm-Message-State: ANoB5plaHusUJ9tYxSSQVf4kgrgIZao4wlaSHA5LDRUajYjr920HvBOU Gxqiue0zCAsOeTOuI1vejvvh+RZHwX5MUkyzFSY= X-Received: by 2002:a17:906:8309:b0:7c0:dab0:d722 with SMTP id j9-20020a170906830900b007c0dab0d722mr17095382ejx.353.1670551801415; Thu, 08 Dec 2022 18:10:01 -0800 (PST) MIME-Version: 1.0 References: <20221208025816.138712-1-guoren@kernel.org> <20221208025816.138712-10-guoren@kernel.org> <87o7sew6ey.fsf@all.your.base.are.belong.to.us> In-Reply-To: <87o7sew6ey.fsf@all.your.base.are.belong.to.us> From: Guo Ren Date: Fri, 9 Dec 2022 10:09:49 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH -next V10 09/10] riscv: stack: Support HAVE_SOFTIRQ_ON_OWN_STACK To: =?UTF-8?B?QmrDtnJuIFTDtnBlbA==?= Cc: arnd@arndb.de, palmer@rivosinc.com, tglx@linutronix.de, peterz@infradead.org, luto@kernel.org, conor.dooley@microchip.com, heiko@sntech.de, jszhang@kernel.org, lazyparser@gmail.com, falcon@tinylab.org, chenhuacai@kernel.org, apatel@ventanamicro.com, atishp@atishpatra.org, palmer@dabbelt.com, paul.walmsley@sifive.com, mark.rutland@arm.com, zouyipeng@huawei.com, bigeasy@linutronix.de, David.Laight@aculab.com, chenzhongjin@huawei.com, greentime.hu@sifive.com, andy.chiu@sifive.com, ben@decadent.org.uk, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, Guo Ren Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-7.1 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 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 Thu, Dec 8, 2022 at 6:12 PM Bj=C3=B6rn T=C3=B6pel wro= te: > > guoren@kernel.org writes: > > > From: Guo Ren > > > > Add the HAVE_SOFTIRQ_ON_OWN_STACK feature for the IRQ_STACKS config. Th= e > > irq and softirq use the same independent irq_stack of percpu by time > > division multiplexing. > > > > Tested-by: Jisheng Zhang > > Signed-off-by: Guo Ren > > Signed-off-by: Guo Ren > > --- > > arch/riscv/Kconfig | 7 ++++--- > > arch/riscv/kernel/irq.c | 33 +++++++++++++++++++++++++++++++++ > > 2 files changed, 37 insertions(+), 3 deletions(-) > > > > diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig > > index 0a9d4bdc0338..bd4c4ae4cdc9 100644 > > --- a/arch/riscv/Kconfig > > +++ b/arch/riscv/Kconfig > > @@ -447,12 +447,13 @@ config FPU > > If you don't know what to do here, say Y. > > > > config IRQ_STACKS > > - bool "Independent irq stacks" if EXPERT > > + bool "Independent irq & softirq stacks" if EXPERT > > default y > > select HAVE_IRQ_EXIT_ON_IRQ_STACK > > + select HAVE_SOFTIRQ_ON_OWN_STACK > > HAVE_IRQ_EXIT_ON_IRQ_STACK is used by softirq.c Shouldn't that be > selected introduced in this patch, instead of the previous one? This patch depends on the previous one. And the previous one could work separately. > > > help > > - Add independent irq stacks for percpu to prevent kernel stack o= verflows. > > - We may save some memory footprint by disabling IRQ_STACKS. > > + Add independent irq & softirq stacks for percpu to prevent kern= el stack > > + overflows. We may save some memory footprint by disabling IRQ_S= TACKS. > > Same comment from previous patch. Please use the same wording/config as > other archs. > > > endmenu # "Platform type" > > > > diff --git a/arch/riscv/kernel/irq.c b/arch/riscv/kernel/irq.c > > index 5d77f692b198..a6406da34937 100644 > > --- a/arch/riscv/kernel/irq.c > > +++ b/arch/riscv/kernel/irq.c > > @@ -11,6 +11,7 @@ > > #include > > #include > > #include > > +#include > > > > #ifdef CONFIG_IRQ_STACKS > > static DEFINE_PER_CPU(ulong *, irq_stack_ptr); > > @@ -38,6 +39,38 @@ static void init_irq_stacks(void) > > per_cpu(irq_stack_ptr, cpu) =3D per_cpu(irq_stack, cpu); > > } > > #endif /* CONFIG_VMAP_STACK */ > > + > > +#ifdef CONFIG_HAVE_SOFTIRQ_ON_OWN_STACK > > +void do_softirq_own_stack(void) > > +{ > > +#ifdef CONFIG_IRQ_STACKS > > + if (on_thread_stack()) { > > + ulong *sp =3D per_cpu(irq_stack_ptr, smp_processor_id()) > > + + IRQ_STACK_SIZE/sizeof(ulong); > > + __asm__ __volatile( > > + "addi sp, sp, -"RISCV_SZPTR "\n" > > + REG_S" ra, (sp) \n" > > + "addi sp, sp, -"RISCV_SZPTR "\n" > > + REG_S" s0, (sp) \n" > > + "addi s0, sp, 2*"RISCV_SZPTR "\n" > > + "move sp, %[sp] \n" > > + "call __do_softirq \n" > > + "addi sp, s0, -2*"RISCV_SZPTR"\n" > > + REG_L" s0, (sp) \n" > > + "addi sp, sp, "RISCV_SZPTR "\n" > > + REG_L" ra, (sp) \n" > > + "addi sp, sp, "RISCV_SZPTR "\n" > > + : > > + : [sp] "r" (sp) > > + : "a0", "a1", "a2", "a3", "a4", "a5", "a6", "a7", > > + "t0", "t1", "t2", "t3", "t4", "t5", "t6", > > + "memory"); > > Same as previous patch. Please avoid C&P and have a look at how > call_on_stack is done on x86. Okay. > > > Bj=C3=B6rn --=20 Best Regards Guo Ren