Received: by 2002:a05:7412:1e0b:b0:fc:a2b0:25d7 with SMTP id kr11csp1338702rdb; Fri, 16 Feb 2024 12:24:42 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVdA1iA4pSCvKtBK3bDO6eZBs1koQiCVq/0ycCI8M/Uce9unFHsr9YAOieXSqTK/+vKH7Wp9HU/xQYHmK5Z0vLW+OLG/+kYjM4PZ2SEaw== X-Google-Smtp-Source: AGHT+IGtKM9w/bS3Joto6VApEJ1/9rkBNOxuWcnCVhG9G5stwjFnOu6t4PwDaoeJ8UFCDxuNL7py X-Received: by 2002:a17:902:e5d0:b0:1db:2ab0:f3de with SMTP id u16-20020a170902e5d000b001db2ab0f3demr7364628plf.13.1708115082049; Fri, 16 Feb 2024 12:24:42 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708115082; cv=pass; d=google.com; s=arc-20160816; b=RnHzF+zl4ZjxcVukyZoJLRHFl9c0Pbl0SHuKs9Z7AMFe0q5yqrWFolXE1AdJYyKEmz Y/FsL9lxj+4Btq12lMQ89Cr3dfScbZ+idydtYIi8j54z2Jp/fj4BC9uqS1sT+fGeKhpY Ld/e3/k0NxBNdCywiiruMK+1woeTbs6RIxSSFx0czMTvt3FuWjfGIMR8h4PU6bPerGiq 0zYZIJTo22jD9XrFMjNNQnRDFCW9Qj1UlDKYjm62gSTcOUy2N0fJOxOtyop2JO3dLEdp vG4lGU/G7psxhEJEvLt1jSik3MwZPPpVv91bGOSRduHmo5OgycXtQVE5DkHQMwCh4f77 lXMQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=Oo9HBcLfH1N8g9ihc0+Bym+GK1so/hZIsswt3CwurtQ=; fh=PHw3cwNpb8q3MDTw4QDqnZoZeBb1CxYJNb1mDoQLG3Q=; b=OpkXiK2hInU4drPmeYpSUYP7e9mcWmShkxQnblMQ977PyErP8flykQF6c10l+keiTW tCMtkoC9A60vhjvYDPVkQm0tiSvNQh9WWQKEHejChgPMLtS60AmKXF10r8PNjtPM4r1K MuZc2/XzjJYYbc/pverIsxvn5ww5EwthcnNBv4rV5t1vQAUULqHna7/0nGbHERWmxVmE +QFbOKf8b+/NFO5D6Trzq8vO1arANnVNhkZRqv9AH6BWA0zQJNjnz3tgoegahgbnE+Vm oGyTaWHyhwhcXhigl1g0fDZVoCOWb4OWc5dbyVtMHWFI+FZgKUXN0XoWaqMlMPKWw/Us QxEA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=BREFQPUE; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-69291-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69291-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id q5-20020a170902dac500b001d9aa5d0a5dsi357051plx.364.2024.02.16.12.24.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 12:24:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-69291-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=BREFQPUE; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-69291-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69291-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id DE199B20A72 for ; Fri, 16 Feb 2024 20:24:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 08B55139595; Fri, 16 Feb 2024 20:24:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="BREFQPUE" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 2EF67135A6F; Fri, 16 Feb 2024 20:23:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708115039; cv=none; b=W/ZyNW0UflRYyP/hmXQHFwKevKoSJQBFZd4dYHrOPJYjYpqymjw9GkZzgW6IUMle+qlvhjTNaHqbRtN4kRpq1z4ClT9eEZ9t2oJ08J6FrfRCMbztZ1QiLcwGuh6tMTj5HROpeBLEJtcNk08qnUcL/oJopeVfwM0H/ScVeLTwnMU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708115039; c=relaxed/simple; bh=Sq/Mpf4CU1DDxAJaU5smyIB6OI93uNYISckA1rqgEqc=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=iB1ruXJJeSyQXtiVpWlmnoVzK6HCFHMjd4QBpMlOuamQeIvWRME/wgHBBDc17nUNExiTZ0Yc0DrdMtsoYC5p6HwA1LbeP6FVs4d0AQOhqcuH1j1CjmpdgCWEFJOYqNV9KcjGpEBgv/jAHRJ7/KC39Zx79RFpHrBv88yDA6IDe0E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=BREFQPUE; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id B9DD7C433C7; Fri, 16 Feb 2024 20:23:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708115038; bh=Sq/Mpf4CU1DDxAJaU5smyIB6OI93uNYISckA1rqgEqc=; h=From:To:Cc:Subject:Date:From; b=BREFQPUE+Lg3oFG94/XQbjW6/X+N9Fgw8T5AM64uUsoM72l6MQ59lraq2doPeAmw0 gDuJLNl+241uzB2b51z9SyZ4hC6DZvvm8yLd+PNsKAmnUOL68zlMmfjN0bfQWpM0pd Ars2RqyFjk6GCUfQyBKbiffJqgbSCHUu46VLLSCSBmyGaMUALsTwJlygoySG7izBUr 6eivxdVnqLOuY8O6W2m+xBwAjiQN5gdxr7EYCRV6hBsrzlx5tWGshcsXdz0XtpvgtM AepxHs04hMDnSrPQU+THAkdsqYO1fmCnnMVMRLhwc6uL3gfRhk411oeGOh0wolXfkP qZaPK+/EP9M6w== From: Arnd Bergmann To: Alexander Viro , Christian Brauner Cc: Arnd Bergmann , Jan Kara , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt , Kees Cook , Andrew Morton , Andi Kleen , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev Subject: [PATCH] fs/select: rework stack allocation hack for clang Date: Fri, 16 Feb 2024 21:23:34 +0100 Message-Id: <20240216202352.2492798-1-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Arnd Bergmann A while ago, we changed the way that select() and poll() preallocate a temporary buffer just under the size of the static warning limit of 1024 bytes, as clang was frequently going slightly above that limit. The warnings have recently returned and I took another look. As it turns out, clang is not actually inherently worse at reserving stack space, it just happens to inline do_select() into core_sys_select(), while gcc never inlines it. Annotate do_select() to never be inlined and in turn remove the special case for the allocation size. This should give the same behavior for both clang and gcc all the time and once more avoids those warnings. Fixes: ad312f95d41c ("fs/select: avoid clang stack usage warning") Signed-off-by: Arnd Bergmann --- fs/select.c | 2 +- include/linux/poll.h | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/fs/select.c b/fs/select.c index 11a3b1312abe..9515c3fa1a03 100644 --- a/fs/select.c +++ b/fs/select.c @@ -476,7 +476,7 @@ static inline void wait_key_set(poll_table *wait, unsigned long in, wait->_key |= POLLOUT_SET; } -static int do_select(int n, fd_set_bits *fds, struct timespec64 *end_time) +static noinline_for_stack int do_select(int n, fd_set_bits *fds, struct timespec64 *end_time) { ktime_t expire, *to = NULL; struct poll_wqueues table; diff --git a/include/linux/poll.h b/include/linux/poll.h index a9e0e1c2d1f2..d1ea4f3714a8 100644 --- a/include/linux/poll.h +++ b/include/linux/poll.h @@ -14,11 +14,7 @@ /* ~832 bytes of stack space used max in sys_select/sys_poll before allocating additional memory. */ -#ifdef __clang__ -#define MAX_STACK_ALLOC 768 -#else #define MAX_STACK_ALLOC 832 -#endif #define FRONTEND_STACK_ALLOC 256 #define SELECT_STACK_ALLOC FRONTEND_STACK_ALLOC #define POLL_STACK_ALLOC FRONTEND_STACK_ALLOC -- 2.39.2