From patchwork Thu Dec 8 02:58:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guo Ren X-Patchwork-Id: 31135 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp535394wrr; Wed, 7 Dec 2022 19:16:09 -0800 (PST) X-Google-Smtp-Source: AA0mqf6/ObTaBLr9CEccRaFrI1hL0WvSRMvpVA7DI0cbIx/pdLH0TmjCpUUjyww1Ho947K/hw8xH X-Received: by 2002:a17:902:8f96:b0:189:3803:23e6 with SMTP id z22-20020a1709028f9600b00189380323e6mr74574424plo.77.1670469369466; Wed, 07 Dec 2022 19:16:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670469369; cv=none; d=google.com; s=arc-20160816; b=OflB7rWbTWd8VeHWaJoUkWIyDCUOSWYlQqdGXom1gvuoojwiLIATEcFVfCXSeRfumi j0Ql3hdj6bukf/vCUG0svMk/wQkwnUu9TP+YSpSmqME08CFjXALZxEeHApIJnkox+hvq FqbdwRpZ3M7WpNEEDotg1dojw0InmbXkgGulRJrC53/C43CHsPWGa6Phf/9MIRuzl5Kd xHWPO8BKC2CR3TXIjLv7VZBhFDr64fr/LP64whcHMm39bfYc6/O1dyJfVmuHctWDeaRQ xZ0cOxSq99A1Lx5vNJChQEEZaxe5RiwJJ2O42uPRejmpRAjnXG6jzZurYoiygKT2Uex/ CcdQ== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i2-20020a17090a974200b0021a04add441si3230234pjw.104.2022.12.07.19.15.55; Wed, 07 Dec 2022 19:16:09 -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 + 99 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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751614089784094099?= X-GMAIL-MSGID: =?utf-8?q?1751614089784094099?= 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) /*