Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp3856906rwb; Mon, 5 Sep 2022 21:02:10 -0700 (PDT) X-Google-Smtp-Source: AA6agR4+L0rNZmuwWOpfRRJB2EKJxV2p8ndpqCTRyXKd906hFJw6HkPZDcmoqurH+KunQI66FcR/ X-Received: by 2002:a17:906:8a52:b0:741:5a6e:adb5 with SMTP id gx18-20020a1709068a5200b007415a6eadb5mr29880952ejc.47.1662436929903; Mon, 05 Sep 2022 21:02:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662436929; cv=none; d=google.com; s=arc-20160816; b=EXO94RIkaAsvuOk5yA5lZZirtfma/rUHs194afnc2fewUVjhNnAkbTzCXO7zVaSrzF 92DcrQZu7Xmc4vhQOd1n+jdBT5OGYiT2XUctbMAvIoxgWcLJ48uQ0gTmTjhvkJf3WLCP SRubofPkWX6e1Fnbg20Zqm6w1/etgmvqZwnFvHfIFj5eBqXfksl/4rN5cC5nMDGW96OV oQP2TVU56z57iLUDwlYe7IJLdbth0PEDKvsinaYq57FvkOuWNiK0o8b3Q2xr2SH4IPOO kpJYjdcrKJOsNpMAt3GEsFlaBmOvSRgmV+IJpgnvNUoYm8+iL9HgPOMj9a3FudblD3Ep 0jow== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=gPUEEItAQtI+0CUGPataZGacVR3CL2VApt8jQ9R3CYk=; b=HLxusjtLVQlTQWOi5QkiqchkJweAz+0kUXz4bjZ89skNk2Ll1sSE4yiRfTl6NsvrGA I7BPcCKmAASWJfA/raOCoTCEb4VUmgsKOOhsAxM5KVHLZKcRtxS61iHsVOgWFnPg+cAz brj2s6stXHqB/WWA45dV+PJDXKP6B8d9iJX16xxuUsRNW7K+Eooqj3zyQMwcjGVtfd4t y9+Qe/E5z6NZm5Sv1VbkRHbtRDjkgpPSu9Ymvdn5/s801BEYDUk5QiYawbM7Dk2DLi25 Ce8FvHN26wBD7q2IPXJFTaTYL0VIWM9CPKDELVIo9b1weJV6xYxte7VXm1HKlPLAQkoW UAvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=SfPG+khf; 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 ho34-20020a1709070ea200b0073d8650d612si9946639ejc.374.2022.09.05.21.01.44; Mon, 05 Sep 2022 21:02:09 -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=SfPG+khf; 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 S237412AbiIFD4e (ORCPT + 99 others); Mon, 5 Sep 2022 23:56:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57702 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236847AbiIFDzd (ORCPT ); Mon, 5 Sep 2022 23:55:33 -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 9335A1B78A; Mon, 5 Sep 2022 20:55:19 -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 4660CB815FB; Tue, 6 Sep 2022 03:55:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E9116C433C1; Tue, 6 Sep 2022 03:55:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1662436517; bh=zdFYpvuTPe6RpWrIfdMW7NpG1CnfQ2kCKBqmLquyd8U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SfPG+khfb4XlIUR/FIVaqCHHDPvsnx6Sb1VRM6Hk6s5vsC4AF9UGyR4xKzPRKCuf1 E0gojBwnwJsnAfXM/n4cK60741Uug8h1K5dn54NY6zrx8NWOzOGdjRZUZ1FsZ6Ukyp U4B99KDfU9FGb2rFKPn/GUD/4LBte/PGrm8bjEOcYtaeOPKmMPTns0u2WsoiBS8wos ewKBnpETdC40Zy7g7XKqYHBxCLoAJX9bt5moJuSNTgMGh0f0ZGZL7DqzaI8Y+OpzwS ITk4YA3mfcpW8yxrVthne927+82I/NuIsvcRNXPpMQHXrPJi+bU6NmxLjCksLb1kx4 l+yFp29UGuaxQ== From: guoren@kernel.org To: arnd@arndb.de, guoren@kernel.org, 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, bigeasy@linutronix.de Cc: linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, Guo Ren Subject: [PATCH V3 6/7] riscv: Support HAVE_SOFTIRQ_ON_OWN_STACK Date: Mon, 5 Sep 2022 23:54:22 -0400 Message-Id: <20220906035423.634617-7-guoren@kernel.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220906035423.634617-1-guoren@kernel.org> References: <20220906035423.634617-1-guoren@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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,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 From: Guo Ren Add the HAVE_SOFTIRQ_ON_OWN_STACK feature for the IRQ_STACKS config. The irq and softirq use the same independent irq_stack of percpu by time division multiplexing. Signed-off-by: Guo Ren Signed-off-by: Guo Ren --- arch/riscv/Kconfig | 7 ++++--- arch/riscv/kernel/irq.c | 16 ++++++++++++++++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index a8a12b4ba1a9..da548ed7d107 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -434,12 +434,13 @@ config FPU If you don't know what to do here, say Y. config IRQ_STACKS - bool "Independent irq stacks" + bool "Independent irq & softirq stacks" default y select HAVE_IRQ_EXIT_ON_IRQ_STACK + select HAVE_SOFTIRQ_ON_OWN_STACK help - Add independent irq stacks for percpu to prevent kernel stack overflows. - We may save some memory footprint by disabling IRQ_STACKS. + Add independent irq & softirq stacks for percpu to prevent kernel stack + overflows. We may save some memory footprint by disabling IRQ_STACKS. endmenu # "Platform type" diff --git a/arch/riscv/kernel/irq.c b/arch/riscv/kernel/irq.c index 5ad4952203c5..c09cd4d28308 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,21 @@ static void init_irq_stacks(void) per_cpu(irq_stack_ptr, cpu) = per_cpu(irq_stack, cpu); } #endif /* CONFIG_VMAP_STACK */ + +#ifndef CONFIG_PREEMPT_RT +static void do_riscv_softirq(struct pt_regs *regs) +{ + __do_softirq(); +} + +void do_softirq_own_stack(void) +{ + ulong *sp = per_cpu(irq_stack_ptr, smp_processor_id()); + + call_on_stack(NULL, sp, do_riscv_softirq, 0); +} +#endif /* CONFIG_PREEMPT_RT */ + #else static void init_irq_stacks(void) {} #endif /* CONFIG_IRQ_STACKS */ -- 2.36.1