Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 66EE6577E3C for ; Wed, 9 Sep 2026 15:53:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788969199; cv=none; b=qj3HEnPrBzUxCjrMXt3Ku4g3k9gEaksjg7ir0pZXtpc7sTyN3BdPkBnocCMJmRu6atNkk80mqgR+0CGRCv1oIbAPibarvDB3vftT1N+KRQD61BSD0Lmx/tjkV06M44d6KjmpMdH5nN3HOUVxJ5s6pe5/Gy23mQXNYJi0sp/+4F0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788969199; c=relaxed/simple; bh=VYxoJM4ZyWv2icl3Agk7v+jigZxwhQU26XZFhQD9zfI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=cWXE0k5LakzA+oa4vDXRZNufuvLfHgUlvPSuj6nvOHEaMFCqhOXHU3oJ4X3aOmLPxy03X4+fEuMavPqAlAb3cvSv9dZhZV3yZ9/F4IG+JmA0vJbQxnuomi4B9FY6U8X3igcbBm9S27ApD83KUnGuAqr9oqL1MrqdC+XxtFEf8PY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=LwquVgn9; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="LwquVgn9" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9358C1F00A3A; Wed, 9 Sep 2026 15:53:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1788969197; bh=yEXteokSRECsqnrKrAfTi3nblzblGgp57JSqfC0yPgE=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=LwquVgn9IjWd8eSPewGUqewtt+ZeTXOqaogviW3Fxd8vqOVA5GE4upghiNM8R5Q81 mMliqQ1n3MXYl+eu2+Qq9oqP24yz+3anTvoQisp09dvSe8JZErx1QDE3uyCcV5mzPf Zx43nXGMA8lYpPiLho2WgbRDvLJqHPV7mS0CqE4tmaMvtcsMvJ/9s6oqtCSHxkwou4 b5K/oTvfg6q+Q9t9EZGOVA301zqAX84id5uvKaByPBiXOXLomimZsjFbitKJVt2N2h nClmWlWV7fHCc9ujI3/wEmkK4GbNOIYz9BQ8vGI4dkWL50wLjyeIZAsoj3+BLlNhE5 KPJ5kGR6nOiYg== From: Christian Brauner Date: Wed, 09 Sep 2026 17:52:50 +0200 Subject: [PATCH RFC v3 07/15] fs: make close_range() synchronous Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260909-work-coredump-unlock-self-v3-7-04f907687563@kernel.org> References: <20260909-work-coredump-unlock-self-v3-0-04f907687563@kernel.org> In-Reply-To: <20260909-work-coredump-unlock-self-v3-0-04f907687563@kernel.org> To: NeilBrown , Oleg Nesterov , linux-fsdevel@vger.kernel.org Cc: Jann Horn , Alexander Viro , Jan Kara , Xin Zhao , Mateusz Guzik , Jeff Layton , Jens Axboe , "Christian Brauner (Amutable)" X-Mailer: b4 0.17-dev-db0b7 X-Developer-Signature: v=1; a=openpgp-sha256; l=1129; i=brauner@kernel.org; h=from:subject:message-id; bh=VYxoJM4ZyWv2icl3Agk7v+jigZxwhQU26XZFhQD9zfI=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMWQtbLj6il3z2C7/yzbf1z24uevPC53odUY7Nkm1ftyXu s2a+f473Y5SFgYxLgZZMUUWh3aTcLnlPBWbjTI1YOawMoEMYeDiFICJPEtn+M3iV2Y2QfL9d91b nCtN+ioPntOyOvYp8927cKaNVadDolcy/K89N+O5jZPYZPaKTSu+1OaLRz3r3ZZiKXEk52vzvrv 6IjwA X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 __range_close() closes through filp_close() so every file the caller held the last reference to is punted to task work. That costs one cmpxchg per file plus a list entry for any later task_work_cancel() to search under ->pi_lock. close_range(2) exists to close many descriptors in one go fast. So convert it to the same synchronous treatment as close(2) and close_files(). Flush and put each file inline while ->file_lock is dropped. close_range(2) now behaves like close(2). Signed-off-by: Christian Brauner (Amutable) --- fs/file.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/file.c b/fs/file.c index b7deb4e634c1..82b17fe50d25 100644 --- a/fs/file.c +++ b/fs/file.c @@ -813,7 +813,8 @@ static inline void __range_close(struct files_struct *files, unsigned int fd, file = file_close_fd_locked(files, fd); if (file) { spin_unlock(&files->file_lock); - filp_close(file, files); + filp_flush(file, files); + fput_close_sync(file); cond_resched(); spin_lock(&files->file_lock); fdt = files_fdtable(files); -- 2.53.0