From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailout2.hostsharing.net (mailout2.hostsharing.net [83.223.78.233]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E922B38757A for ; Thu, 9 Apr 2026 07:58:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=83.223.78.233 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775721520; cv=none; b=Rb4+m/Ib3uhP0dqM6xwSQAcPUuXk6uIfgp4n4j7/mw9n2BIAhY18a9/hC9spMxu63A8uRSdwmNjkH697pSpM4iteRrwx2BlLrABSZSKZ8vg2AnmsCO9bxpARlEmwzxxq0mul1dxPN3zVJ7epTAj/hcRWcQzgZFHNayRzf6mbf3I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775721520; c=relaxed/simple; bh=COET22RBk1fJWEleYw2ONs2a1MqUxEU7uT43PBxhEFA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=pnldfgJ4wA39TRJfiNrzcriuLZz2xGlCSpXg8AIecDk3WO4+Fj9LKqVb8pNtQRxTuoelaMPVf6Z1HBzEtyKFe9BbmONmL67uNJU8bWX1696TqlRXlaFXheXNta+B8GWPbTX6TV0RC0wB44RlUwoCahUIImSaC8mf81jQGHmQAg4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=wunner.de; spf=pass smtp.mailfrom=wunner.de; arc=none smtp.client-ip=83.223.78.233 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=wunner.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=wunner.de Received: from h08.hostsharing.net (h08.hostsharing.net [83.223.95.28]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384 client-signature ECDSA (secp384r1) client-digest SHA384) (Client CN "*.hostsharing.net", Issuer "GlobalSign GCC R6 AlphaSSL CA 2025" (verified OK)) by mailout2.hostsharing.net (Postfix) with ESMTPS id 9C23910594; Thu, 09 Apr 2026 09:58:28 +0200 (CEST) Received: by h08.hostsharing.net (Postfix, from userid 100393) id 94086602E9E7; Thu, 9 Apr 2026 09:58:28 +0200 (CEST) Date: Thu, 9 Apr 2026 09:58:28 +0200 From: Lukas Wunner To: David Laight Cc: Andy Shevchenko , linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Andrew Morton Subject: Re: [PATCH v3 1/1] mtd: cfi_cmdset_0001: Factor out do_write_buffer_locked() to reduce stack frame Message-ID: References: <20260408211407.2295175-1-andriy.shevchenko@linux.intel.com> <20260409082611.73fac9ab@pumpkin> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20260409082611.73fac9ab@pumpkin> On Thu, Apr 09, 2026 at 08:26:11AM +0100, David Laight wrote: > On Wed, 8 Apr 2026 23:11:48 +0200 Andy Shevchenko wrote: > > Compiler is not happy about used stack frame: > > > > drivers/mtd/chips/cfi_cmdset_0001.c: In function 'do_write_buffer': > > drivers/mtd/chips/cfi_cmdset_0001.c:1887:1: error: the frame size of 1296 bytes is larger than 1280 bytes [-Werror=frame-larger-than=] > > > > Fix this by factoring out do_write_buffer_locked(). > > Does this just split the large stack frame between two nested functions? > I'd also expect the compiler to inline do_write_buffer_locked() so it > makes little difference. > OTOH I can't immediately see where the large stack frame comes from. The error occurs for an allmodconfig build on arm, which implies CONFIG_KASAN_STACK=y and thus increases stack usage vis-à-vis a "regular" build. Stack usage is high here because of the three "map_word" types, which can each be up to 256 unsigned longs (32 * 8), see the definitions of MAX_MAP_LONGS, MAX_MAP_BANKWIDTH, map_word in include/linux/mtd/map.h. Possible solutions: - Disable KASAN entirely for this file: https://lore.kernel.org/all/adX3SHYgazijahbG@wunner.de/ Not always a good option, particularly for stuff like lib/maple_tree.c where the same issue exists in mas_wr_spanning_store() and KASAN would certainly be good to have for that one. - Use heap instead of stack. - Split function in smaller chunks and mark them "noinline". Thanks, Lukas