From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9CF48606A320 for ; Tue, 1 Dec 2026 14:35:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.a=rsa-sha256 header.s=susede2_rsa header.b=JhTazfwQ; dkim=pass header.d=suse.cz header.i=@suse.cz header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=kGgTKb3L; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.a=rsa-sha256 header.s=susede2_rsa header.b=balG3TCR; dkim=neutral header.d=suse.cz header.i=@suse.cz header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=tWr6akCT Received: by kanga.kvack.org (Postfix) id D4DEE6B05D1; Tue, 1 Dec 2026 09:35:39 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id CFC646B05BF; Tue, 1 Dec 2026 09:35:39 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AB2AC6B05C4; Tue, 1 Dec 2026 09:35:39 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 6EEA96B05C5 for ; Tue, 1 Dec 2026 09:35:39 -0500 (EST) Received: from smtpin19.hostedemail.com (lb01a-stub [10.200.18.249]) by unirelay09.hostedemail.com (Postfix) with ESMTP id B5F3E80EA4 for ; Tue, 1 Dec 2026 14:35:38 +0000 (UTC) X-FDA: 85495662756.19.4F8ED34 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by imf28.hostedemail.com (Postfix) with ESMTP id 7AEE0C000D for ; Tue, 1 Dec 2026 14:35:36 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=JhTazfwQ; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=kGgTKb3L; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=balG3TCR; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=tWr6akCT; dmarc=none; spf=pass (imf28.hostedemail.com: domain of jack@suse.cz designates 195.135.223.130 as permitted sender) smtp.mailfrom=jack@suse.cz ARC-Seal: i=1; a=rsa-sha256; d=hostedemail.com; s=arc-20220608; cv=none; t=1796135736; b=k5rIfQLSAR/zENpk7lL2tNU18Cx2P/Uk57KalaWQAwRfwyIbIWqV0/e6kh7AiLlwXQZWRz F4+RqabeuWojULicfzI3ANiqPc0WKT15PZ1hGkfBgz0dF/spjjfJDAr0De50sFi1wJ3gGc NW7dCc+mDAPCz9NEGeYq1F/diNZfD9I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1796135736; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=1lajEFPbZglF/YQ0on/3zxKjvkfAmvhLd4bUIOjXAB0=; b=r2xXBtUoNqvaKWA5wmckeYOhFvCZjxb4n1ZzJJVKkXTZ1XOutBet33bcRwSBtq8qoeUywq gLKSb7gAS4hfEr3n48NhuzTCNfzgxeVu2v/U/A+/YngyEttLc0B2OxqBq8aS8lgyJnFH0Y oIe3vNKJuQR3g+XkxsZPF5jqq3kMoBw= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=JhTazfwQ; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=kGgTKb3L; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=balG3TCR; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=tWr6akCT; dmarc=none; spf=pass (imf28.hostedemail.com: domain of jack@suse.cz designates 195.135.223.130 as permitted sender) smtp.mailfrom=jack@suse.cz Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id A63FA222AA; Tue, 1 Dec 2026 14:35:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1796135734; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=1lajEFPbZglF/YQ0on/3zxKjvkfAmvhLd4bUIOjXAB0=; b=JhTazfwQs0mK1T+k8BhEItHMVbSBs/gMmXLmYhLM2tVqSaBEMsoRv+FRBxNNITvfaN3N5b dKztX4UgkaJ3kIl9XTvC1TNDBB/POM2+eNSLp7bJrtoJSmsKvUbwU7giChdS5ZIWkZzU8d JQ7aTaa3WZTUSQ6dmZPnnYQr0cZlDfo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1796135734; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=1lajEFPbZglF/YQ0on/3zxKjvkfAmvhLd4bUIOjXAB0=; b=kGgTKb3L96B4GQfqCWDG7ix/h5AYm9aPfBLGssi5eFYck8uvyqJlFY23otnkb/zAVyschl mW5xzJ+APaHtnXCA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1796135733; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=1lajEFPbZglF/YQ0on/3zxKjvkfAmvhLd4bUIOjXAB0=; b=balG3TCR0NeIzW8foDWqYl4eQnbW8kCX7rhpQ+bYOkWesNcG0pYYd4RQ4xvIT7uZUV9hA4 EohVTIik8aZKAH0zslyS/ooFcyNbyohyjqjXVlkBRyCC4jeTJ8zI4FuE7sE28RSOPvftjS Mpymxq/jFlElOvnVOvfW1Wq7SDL8srA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1796135733; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=1lajEFPbZglF/YQ0on/3zxKjvkfAmvhLd4bUIOjXAB0=; b=tWr6akCTpVvWUZza8z0DuvzSERstl4MiX53oQ5h+eaEM9EOHesi0O7VFKzC7fDhmCwHKFZ USoEER5/pbO0OnAA== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 72EDC134E9; Tue, 1 Dec 2026 14:35:33 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id nVMEFDXbDmvxVAAAD6G6ig (envelope-from ); Tue, 01 Dec 2026 14:35:33 +0000 Received: by quack.suse.cz (Postfix, from userid 1000) id 0375C5153B; Tue, 01 Dec 2026 15:35:32 +0100 (CET) From: Jan Kara To: Christian Brauner Cc: , Christoph Hellwig , , Mikhail Rudenko , Andreas Gruenbacher , Jan Kara Subject: [PATCH v5 0/8] fs: Deferred inode reclaim Date: Tue, 1 Dec 2026 15:35:02 +0100 Message-ID: <20261201105733.18997-1-jack@suse.cz> X-Mailer: git-send-email 2.53.0 X-Archived-By: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=5107; i=jack@suse.cz; h=from:subject:message-id; bh=ltb0X/POX2cFR6pjjUJklFMr3awvObJ8EDusmL7AOSQ=; b=owEBbQGS/pANAwAIAZydqgc/ZEDZAcsmYgBrDtsWFsRRGT1ni8GNVghC8I32Q6bky8MoAvtoA Hbb/SDeLlqJATMEAAEIAB0WIQSrWdEr1p4yirVVKBycnaoHP2RA2QUCaw7bFgAKCRCcnaoHP2RA 2W9kCACF/a1ShhC//tibnUDe4aHvA1YKOFTdUQ/PUveL8d/4oqcbAReg3/Drr1J4KGFOv78pa9T W2DtQennNv38iiaZfuQdV46jxK+iZzP0qxoAREcqKwSOPQxiVTuyCOSSChV4JI/zPNstYt4JK91 FH4SM0DGyGF9HBWraqKZ0Gmx7rCZ/Ph/75InNbBJgNkJwRsfa0+/613rshVmUALyOn9ppLas6Jl 2JAnnfTy2uflWjr4G3GxTKAp71RQrHgaMxudCK0OycFhL8URpJQpntBUrlKxP3ep7PPq7z77+e3 ipPBA49NoHcogeDctuEnD4ozT5SIriuii02iDbdGNw0zsuzT X-Developer-Key: i=jack@suse.cz; a=openpgp; fpr=93C6099A142276A28BBE35D815BC833443038D8C Content-Transfer-Encoding: 8bit X-Spam-Score: -11.80 X-Spam-Level: X-Stat-Signature: wu34mewxbrdc5yu9heh63nhfejhe4nc3 X-Rspam-User: X-Rspamd-Queue-Id: 7AEE0C000D X-Rspamd-Server: rspam12 X-Spam-Status: No, score=-8.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_PASS,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=4.0.1 X-HE-Tag: 1796135736-458501 X-HE-Meta: U2FsdGVkX19a2Wwq5R3hIyCTod021hNb2HgH4RFgdaVYJ8Fv5AVAJ4ZdL4MyhFoaGwXggtOv8dXnq2Q4Z/TjX4eLsHEE+s1yFfenWcmAygJUnazlpekQSoQd764T5VYlnKQs655/FnUO68ZdnsYKnE4ovUufL2rLMsQmIjnRUtP+DM6we1HhUA1cvNAK4/tHSz/NCSsPo/WETnDjxI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OMECIc71t+JmwiYAwOoTzJlz8XGv2p+3deAProFiHqwpPtAJR9MLNzsAqePQM4a9rblWAGwYxwWfuFuNg== Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 Hello, here is the fifth revision of my patches implementing deferred inode reclaim to deal with MM warnings due to GFP_NOFAIL allocations from reclaim paths. This happens because to reclaim some inodes, filesystems have to do IO including complex operations using journalling and forward progress of these depends on successful memory allocations (which is impossible to guarantee from reclaim context). There is one notable change since v4 - I've dropped the patch implementing protection of deferred inode reclaim from filesystem freezing. The reasons for that are: 1) Inode reclaim can hang on frozen fs now the same way as with deferred inode reclaim. So far nobody complained about kswapd being blocked like that and blocking deferred inode reclaim worker is going to have even lower impact on the system. So this apparently isn't a practical problem today. 2) Such blocking of inode eviction on frozen fs is rare (the only scenario I'm aware of is overlayfs dropping last reference of unlinked inode on lower fs from its ->evict method). 3) Protecting inode deferred inode reclaim from freezing (and blocking on frozen fs) would introduce much more visible stalls in reclaim on frozen fs with possible (userspace) deadlocks when somebody wants to read inode under reclaim back into memory. The patches have survived full fstests run on ext4 when marking all loaded ext4 inodes for deferred reclaim to stress the deferred reclaim paths. I have also tested (when marking all inodes for deferred reclaim) the patches by creating a memcg with 128m memory limit and then scanning from 10 processes 1m inodes in total which heavily exercises deferred inode reclaim paths. This also verified efficiency of throttling of marking of inodes for deferred reclaim. Basically we cannot guarantee any particular limit on the number of inodes queued for deferred reclaim as that is bound only by their number in memory and memory pressure. But as the number of queued inodes grows, the tasks creating them get slowed down so eventually some equilibrium is hit. In my VM this was at ~10k inodes (only slightly above the 8k limit when throttling kicks in) but this all very much depends on the reclaim pressure, speed of deferred reclaim etc. so I don't think this is some representative number. The first patch is a pure fix for a problem I've hit when running fstests, the second patch fixes queueing of inodes with only timestamps dirty into writeback lists. The third patch deals with lazy timestamp updates which I've decided to handle better directly inside the writeback infrastructure instead of deferring reclaim. The remaining patches implement the inode reclaim deferal. Ext4 use of deferred inode reclaim is there mostly as a demonstration. Other filesystems need to determine which inodes need deferred reclaim and mark them as such which generally requires good internal knowledge of the filesystem. I'm hoping that once the infrastructure is there, fs developers prompted by MM warnings will start using it :). I know for a fact that besides ext4 e.g. gfs2 wants to use this infrastructure. Honza Changes since v4: * Fix whitespace damage * Avoid pointless schedule on 0 delays in throttle_inode_deferred_reclaim() * Added fix for redirty_tail_locked() and process_inode_switch_wbs() to move inode to b_dirty_time list of only timestamps are dirty * Waking of workes now takes into account total number of queued inodes, not just the immedialy queued batch so that more workers are woken up for a storm of single-inode additions. * Removed freeze protection of reclaim workers Changes since v3: * Improve logic to expedite writeback of I_DIRTY_TIME inodes to handle also the case when inode is dirty or under writeback * Defer reclaim of I_METADATA_WRITEBACK inodes * Handle kernel workers when throttling deferred inode reclaim * Fix memory leak in throttling code * Fix synchronization between superblock teardown and deferred inode reclaim * Fix synchronization between superblock freezing and deferred inode reclaim Changes since v2: * Some cleanups and simplifications from Andreas Grunbacher * Fixed couple of bugs pointed out by Sashiko * Added support for auto-deferring eviction from iput() when inode has 0 link count and we are in reclaim path * Added protection of deferred reclaim from filesystem freezing * Throttling now doesn't happen directly in mark_inode_reclaim_deferred() but on exit to userspace Changes since v1: * Multiple workers to reclaim deferred inodes, related to that I've moved lists of deferred inodes from per-sb to global ones * Added missed lazytime sync fix Previous versions: Link: http://lore.kernel.org/r/20260429174850.18223-1-jack@suse.cz # v1 Link: http://lore.kernel.org/r/20260911081309.14137-1-jack@suse.cz # v2 Link: http://lore.kernel.org/r/20261009133253.20102-1-jack@suse.cz # v3 Link: http://lore.kernel.org/r/20261124113450.3451-1-jack@suse.cz # v4 Link: http://lore.kernel.org/r/20261201105048.19293-1-jack@suse.cz # v4