Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp371952rwb; Wed, 7 Dec 2022 19:44:48 -0800 (PST) X-Google-Smtp-Source: AA0mqf7jefxJy9hWmLwlKGFGQ5lqSmTrtu3FRUron7kc0f/9VBTBHFL1/J9oXB2G3Kv3W7hGRu3w X-Received: by 2002:a05:6402:3203:b0:46c:fabe:8372 with SMTP id g3-20020a056402320300b0046cfabe8372mr10090952eda.347.1670471088349; Wed, 07 Dec 2022 19:44:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670471088; cv=none; d=google.com; s=arc-20160816; b=QYTMxrlR87yLQ4UE7hMw+5K2Cm4FoTvpVt/cxxpur6wrZ7jYIpbCGAaZm/lgRmcccw 0c+LAZ8Od5OtXJL2tHhaQeJxMFspn03qQM70ehYmRaVnFmObkQfyZB+og9b5jGWQ4Qff nFNHNnMWfiGMzU/DJZ1psIXKZkPNYkqkiURORO+16Qy4es/EibEygEMz4XopI5leG+LJ GoLThvhcIyG0zSfYRo1zNndG6zf/EmKUadlGwZDJGP18rJ5u9uDr+WrcKyLiU7N1d9LP CGSnDOOnQuIlSX6EEBZPFqg6K096i64iAjCELYvWiZRSvCyop+YlMciOe+ECgKQpQ6GF 2Xvw== 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=h5weLoP/eesVBq+SM9RzHsN7EKhJnVrwlNC7ExQgk3c=; b=T8j0YxelYxTHjfddJ8ocO7q5EiK6xRLtletKhwyxa7mgqtPjNot/Cm+DPjcvldz9Ns Ed6HwP8fl/3nF8/xv99UfTeKE/L/swyzJA92c2xRuw7pRhJ6BZ2dQ/gr1H0KDBCunAOL RQn8bMrNQAo+31MhoKET9n/CeJyWtoZ1yVoDdYBcEcZYpZHkFI6DZCDnh1tHByCsY5aY 4pq8hItLo9tLhGBOCV2bdcF07Auynabh1X+zaarGE8bg3BI07zmR/jG3Hzm1BHdW97Tf g1JaKUv71Dq2Tadq0QuyelnzdboTwD2+SHjxboIavOGki8Ip5h327UgtH3XbP85Hf7da F2zQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=YFAi76HG; 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 hw9-20020a170907a0c900b0078de83a052csi19275822ejc.483.2022.12.07.19.44.20; Wed, 07 Dec 2022 19:44:48 -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=YFAi76HG; 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 S230059AbiLHDBb (ORCPT + 74 others); Wed, 7 Dec 2022 22:01:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47124 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229939AbiLHDAX (ORCPT ); Wed, 7 Dec 2022 22:00:23 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F77D98973; Wed, 7 Dec 2022 19:00:11 -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 ams.source.kernel.org (Postfix) with ESMTPS id E5628B82204; Thu, 8 Dec 2022 03:00:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B407EC433D7; Thu, 8 Dec 2022 02:59:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1670468408; bh=gadY8OsNJ4C2VcA97+/Vkul7uDTqq5k2F2atJx1sXvg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YFAi76HGyGTdi7lktBkHSY1g6SZf+ann7tXwZVW6yd82aeQmn+xz/Agxr7oSXTaAa k4JmHfN/a/sLVt3trtEt+14jyfSDZ6l/aLd6iYPEkCSR8eOqzyggFaXqTfCx7hRAPm f4Ibe11TAfHHVuUDPcEmsmqECyDdP4Q/xDwbKQ+/jHK0T59GDNvE+ehGBfHJJyD+hO JJnt2kb3Y8Xa/yIidadbT5XuobtF/A3WyLkFz58sQHv56xrZS+Kznn1el9h/R7NaNC Iu5pHxhH5j7xLJ2SL097aIpOYhQ00J4xZrCXfhgThkk2gE1ikOnybb9eSRP7QQQu5m WYUhvGJklYRLg== 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, 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, bjorn@kernel.org Cc: linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, Guo Ren Subject: [PATCH -next V10 10/10] riscv: stack: Add config of thread stack size Date: Wed, 7 Dec 2022 21:58:16 -0500 Message-Id: <20221208025816.138712-11-guoren@kernel.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20221208025816.138712-1-guoren@kernel.org> References: <20221208025816.138712-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 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 0cac21b02ba5 ("risc v: use 16KB kernel stack on 64-bit") increase the thread size mandatory, but some scenarios, such as D1 with a small memory footprint, would suffer from that. After independent irq stack support, let's give users a choice to determine their custom stack size. Link: https://lore.kernel.org/linux-riscv/5f6e6c39-b846-4392-b468-02202404de28@www.fastmail.com/ Suggested-by: Arnd Bergmann Tested-by: Jisheng Zhang Signed-off-by: Guo Ren Signed-off-by: Guo Ren --- arch/riscv/Kconfig | 10 ++++++++++ arch/riscv/include/asm/thread_info.h | 12 +----------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index bd4c4ae4cdc9..60202cd5c5ae 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -455,6 +455,16 @@ config IRQ_STACKS Add independent irq & softirq stacks for percpu to prevent kernel stack overflows. We may save some memory footprint by disabling IRQ_STACKS. +config THREAD_SIZE_ORDER + int "Kernel stack size (in power-of-two numbers of page size)" if VMAP_STACK && EXPERT + range 0 4 + default 1 if 32BIT && !KASAN + default 3 if 64BIT && KASAN + default 2 + help + Specify the Pages of thread stack size (from 4KB to 64KB), which also + affects irq stack size, which is equal to thread stack size. + endmenu # "Platform type" menu "Kernel features" diff --git a/arch/riscv/include/asm/thread_info.h b/arch/riscv/include/asm/thread_info.h index 043da8ccc7e6..c970d41dc4c6 100644 --- a/arch/riscv/include/asm/thread_info.h +++ b/arch/riscv/include/asm/thread_info.h @@ -11,18 +11,8 @@ #include #include -#ifdef CONFIG_KASAN -#define KASAN_STACK_ORDER 1 -#else -#define KASAN_STACK_ORDER 0 -#endif - /* thread information allocation */ -#ifdef CONFIG_64BIT -#define THREAD_SIZE_ORDER (2 + KASAN_STACK_ORDER) -#else -#define THREAD_SIZE_ORDER (1 + KASAN_STACK_ORDER) -#endif +#define THREAD_SIZE_ORDER CONFIG_THREAD_SIZE_ORDER #define THREAD_SIZE (PAGE_SIZE << THREAD_SIZE_ORDER) /* -- 2.36.1