Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp2873101pxp; Tue, 8 Mar 2022 03:43:35 -0800 (PST) X-Google-Smtp-Source: ABdhPJwAS1Lii7cKCOoAyhgv7ALFWMFOsNirtvfLM81XHrkcLMtzf/VoFJ8cyXiJO/KMBHMuXuWu X-Received: by 2002:a63:1c7:0:b0:37c:4e86:25e9 with SMTP id 190-20020a6301c7000000b0037c4e8625e9mr13744541pgb.550.1646739815628; Tue, 08 Mar 2022 03:43:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646739815; cv=none; d=google.com; s=arc-20160816; b=wmaeWVIM6nVOjP6Z67Zky8byRbVSFjtAoAQnuQ7isSg7d3fr+ST48N1MQFdJlfmmk+ mR39eZwLU/y7ShH31y/+6MZ1HXAhMf+aWq3JqjVrnhpWYIQwZWOaJe1G1fCYvMy1jr0v VCCRSV600shimcedYzVGWHlrQi1qBZnpswl1MPKeB/O9ZPKfVW7ov/Er+x+Kt/hdFkmu iweDziuOg4ApGwrIpa8FPmCsfC+M4qivqCTGz95K2g3bkvCwRM6k//o1dtgA6osQre/f cs8G7In83W8Cpv31DHKkG1TsLKnAVyKFxhgRqVl6Tq3XBwQghCS5uRTHnjzIpTQ2BP0Z TDzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :mime-version:accept-language:in-reply-to:references:message-id:date :thread-index:thread-topic:subject:cc:to:from; bh=vzXW+FGtavglsChrDl2q6ulV3AMuJ/UkZeD6lRbwN38=; b=oWmZs9yQjEnKS3VC/dyNJ89TGwiqfprGB6mg7LUJwRWQU6fvztBCzXMZFuXQ/Ns9Se 7M4ZrRxp4hDBp1q7enAxT63s0Eelidis363P8MdgwQ8gFTuCbWOnTMYiLN/4iXm4FQRW UjUnGeciDDt0wB+24Z3H8hR45DCr6oZ5rEj9Fr+PeDYDhLN3HPkVHLOcPZG7j3sG+aJr KdU1Cl944sR9EFiElmGe2iRIFrkMczJkDGyX4Gf6zwkSeCtzEGvYlVGW3UrTqoOL5OJD s1yJkAcfnwuDgKXqeFw/nds8jK5rGL4IYssdznqDyI5LlzpkPUJ9oZZpRVAwt8OvGQIc oOFQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 23-20020a630217000000b0038074111db5si3802256pgc.233.2022.03.08.03.43.20; Tue, 08 Mar 2022 03:43:35 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239640AbiCGOdh convert rfc822-to-8bit (ORCPT + 99 others); Mon, 7 Mar 2022 09:33:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57034 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243228AbiCGOdf (ORCPT ); Mon, 7 Mar 2022 09:33:35 -0500 Received: from eu-smtp-delivery-151.mimecast.com (eu-smtp-delivery-151.mimecast.com [185.58.85.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D81622AE39 for ; Mon, 7 Mar 2022 06:32:40 -0800 (PST) Received: from AcuMS.aculab.com (156.67.243.121 [156.67.243.121]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id uk-mta-90-h5M8wZQmO6yot19GRlHRaQ-1; Mon, 07 Mar 2022 14:32:37 +0000 X-MC-Unique: h5M8wZQmO6yot19GRlHRaQ-1 Received: from AcuMS.Aculab.com (fd9f:af1c:a25b:0:994c:f5c2:35d6:9b65) by AcuMS.aculab.com (fd9f:af1c:a25b:0:994c:f5c2:35d6:9b65) with Microsoft SMTP Server (TLS) id 15.0.1497.28; Mon, 7 Mar 2022 14:32:34 +0000 Received: from AcuMS.Aculab.com ([fe80::994c:f5c2:35d6:9b65]) by AcuMS.aculab.com ([fe80::994c:f5c2:35d6:9b65%12]) with mapi id 15.00.1497.028; Mon, 7 Mar 2022 14:32:34 +0000 From: David Laight To: 'Jisheng Zhang' , Paul Walmsley , Palmer Dabbelt , Albert Ou CC: "linux-riscv@lists.infradead.org" , "linux-kernel@vger.kernel.org" Subject: RE: [PATCH v2] riscv: add irq stack support Thread-Topic: [PATCH v2] riscv: add irq stack support Thread-Index: AQHYMi3k+WYJFHSO9UyI1q+ElBcqo6yz+IIw Date: Mon, 7 Mar 2022 14:32:34 +0000 Message-ID: References: <20220307140804.1400-1-jszhang@kernel.org> In-Reply-To: <20220307140804.1400-1-jszhang@kernel.org> Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=C51A453 smtp.mailfrom=david.laight@aculab.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,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: Jisheng Zhang > Sent: 07 March 2022 14:08 > Currently, IRQs are still handled on the kernel stack of the current > task on riscv platforms. If the task has a deep call stack at the time > of interrupt, and handling the interrupt also requires a deep stack, > it's possible to see stack overflow. > ... I'd have thought that a single page is (probably) enough for the IRQ stack. Certainly its sizing isn't really related to the normal thread stack size. > From another side, after this patch, it's possible to reduce the > THREAD_SIZE to 8KB for RV64 platforms. This is especially useful for > those systems with small memory size, e.g the Allwinner D1S platform > which is RV64 but only has 64MB DDR. Are you sure? Is the stack use likely to be very much less than that of x86-64? The real problem isn't the stack use of the test you are doing, but the horrid worst case stack of some path that has multiple 1k+ buffers on stack. Apart from compiler fubar (which usually hit KASAN) that stack is actually likely to be architecture independent. (The difference between 32bit and 64bit is also likely to be relatively small - unless there are on-stack arrays of 'long'.) For VMAP stacks is there a 'guard' KVA page allocated below all of the stacks? 64bit systems should have lots of KVA so this shouldn't be a problem. Then stack overruns will fault and panic rather than trashing another data area - which is really hard to debug. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)