From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtpout-04.galae.net (smtpout-04.galae.net [185.171.202.116]) (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 D1C6F1A6822 for ; Mon, 27 Apr 2026 15:38:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.171.202.116 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777304319; cv=none; b=MsHLF0coTZxwXyjMQj3iYy4qjOgYfMr24QmUq5WSP1R4RnxhffzGuqriMOHSDLJLeeW1HMznxW9UBdBKaPlnsjRLW5wKQLsQVF5f8KoOW2dj28Pysg+MF4d2xAD04WGp3JM1xMSuw30EytHAJJYDdmPu1JUuJRcqQa3Hvpv8tCQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777304319; c=relaxed/simple; bh=AtpBNlpagQTu690xRZJwJwxMw6bxReRQBRhQgB6yqSQ=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=kiE4WHXTGrsEb7vy7EKA2oTSSM5Thd1r5WgLyQeMf1rbTBGtoKMvtGiWhEt5zrc1fAo/uYpcgHmoZGY4oSUUTkPOqyBOgCTNmo+obVgFZo3pFj3izoQcqN7a3YcUbEe/nemYQ2HiSLBfEkjL5fC4ibfGyefut6jwo2ov+Rln2Ig= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=Q1EJCOu0; arc=none smtp.client-ip=185.171.202.116 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="Q1EJCOu0" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-04.galae.net (Postfix) with ESMTPS id 5DE63C5CD4A; Mon, 27 Apr 2026 15:39:18 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 079D0600D1; Mon, 27 Apr 2026 15:38:35 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id A9EE710728068; Mon, 27 Apr 2026 17:38:30 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1777304314; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=h4EAmgSRIF0VbCoFpzON8QNgX3RE3NgJm+NruHt7Das=; b=Q1EJCOu0FMQP1X4wvVFZHxOXP8OKLGxy9qs38SL/7FhKV+FYApEaxNJq9hvY4xUbZRrrlJ WxXbwNeuOlPLkJb3lmd4D6Nvy+o18yEynHh8QpsX1srdiWabjePSSNCzdHGwzsNIc3yzpq IwvP2TbOvdSAetCJ/oxU4mcMugZz47ERxhrMMD0+YR2fP6vxttXSdbfPZy42zlpocT35ww A64Hi2mgpNpxAnMV3KYs3fKDYkvy7rvyb+A0q+VUmyjmLOdb4oA0IQhKlBFw0QKRhHYD98 sBdf+rWcLSNXLGxUXVXmAWDl/ag+hrulZXy95MMpIm7vsOeJV8lChRA0/siurQ== From: Miquel Raynal To: Andy Shevchenko Cc: David Laight , Lukas Wunner , linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, 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 In-Reply-To: (Andy Shevchenko's message of "Tue, 14 Apr 2026 15:38:38 +0300") References: <20260408211407.2295175-1-andriy.shevchenko@linux.intel.com> <20260409082611.73fac9ab@pumpkin> <20260409122846.7d08d2b4@pumpkin> User-Agent: mu4e 1.12.7; emacs 30.2 Date: Mon, 27 Apr 2026 17:38:31 +0200 Message-ID: <87ik9cfm6g.fsf@bootlin.com> 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=utf-8 Content-Transfer-Encoding: quoted-printable X-Last-TLS-Session-Version: TLSv1.3 Hello, On 14/04/2026 at 15:38:38 +03, Andy Shevchenko wrote: > On Thu, Apr 09, 2026 at 12:28:46PM +0100, David Laight wrote: >> On Thu, 9 Apr 2026 09:58:28 +0200 >> Lukas Wunner wrote: >> > 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:=20=20 >> > > > Compiler is not happy about used stack frame: >> > > >=20 >> > > > 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=3Dframe-larger-than=3D] >> > > >=20 >> > > > Fix this by factoring out do_write_buffer_locked().=20=20 >> > >=20 >> > > Does this just split the large stack frame between two nested functi= ons? >> > > 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.= =20=20 >> >=20 >> > The error occurs for an allmodconfig build on arm, which implies >> > CONFIG_KASAN_STACK=3Dy and thus increases stack usage vis-=C3=A0-vis a >> > "regular" build. >> >=20 >> > 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. >>=20 >> Ugg - that code is horrid. >> Returning structures by value isn't really a good idea. Looks like the primary reason for the stack over usage, no? Isn't playing with inline and refactoring just a tiny fix that prevents problem by just a couple of bytes? I haven't looked too carefully, but could we (Andy?) have a fix that reduces the number of map_word (as suggested, IIUC) and/or avoid passing them by value? I can also take this cleanup if enclosed in a bigger series, I don't mind because it may make the code easier to read as well, but I feel like this is not a proper fix. If it is, please explain to me again :-) Thanks, Miqu=C3=A8l