From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7F423CF45B0 for ; Mon, 12 Jan 2026 17:20:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D71C56B0088; Mon, 12 Jan 2026 12:20:40 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D11A46B0089; Mon, 12 Jan 2026 12:20:40 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C44E56B008C; Mon, 12 Jan 2026 12:20:40 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id B57CC6B0088 for ; Mon, 12 Jan 2026 12:20:40 -0500 (EST) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 81AD1140767 for ; Mon, 12 Jan 2026 17:20:40 +0000 (UTC) X-FDA: 84323976240.25.5764838 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by imf23.hostedemail.com (Postfix) with ESMTP id 02255140012 for ; Mon, 12 Jan 2026 17:20:37 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=Wtin3mX0; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=tMZ0cW9H; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=Wtin3mX0; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=tMZ0cW9H; spf=pass (imf23.hostedemail.com: domain of jack@suse.cz designates 195.135.223.130 as permitted sender) smtp.mailfrom=jack@suse.cz; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1768238438; 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-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=1PoHnkFvFVa85D90IbSeAH892zq7+97wrja4nCJtn2k=; b=zrQTUrGfcof6EG7uHNtNbqzS/Qvij3XX/l21qKSUznVFUe9Jhwidsb2x3xuTQsmqxtiu72 R31KO3bo+j5iRJ7LhCRyHe1b8NjTvlhAzx/cjD1lFdtyhe3JrQ8UoSrkp1cZgdYfFQ60dd R7WmOTJx1gzFGMKQ3HbJbRFztgRXcJQ= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=Wtin3mX0; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=tMZ0cW9H; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=Wtin3mX0; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=tMZ0cW9H; spf=pass (imf23.hostedemail.com: domain of jack@suse.cz designates 195.135.223.130 as permitted sender) smtp.mailfrom=jack@suse.cz; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1768238438; a=rsa-sha256; cv=none; b=pbfp0A3BvJRQt1Dod4IdTeOfPuUzarmpXr6s5OFnZ69sM6Y/u8XAVusLgeWuYo/RV2w1Sb QjmGGpdpW/jYQgJt+4s62TZXGoz0UQzW7fr5Os+OQwz5WPqlkNxKckdCxmkTK/pV0m9qPa 15vGpiQq5k4F2LfeXmQB8rl2tv02Rzk= 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 4044D3368F; Mon, 12 Jan 2026 17:20:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1768238436; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=1PoHnkFvFVa85D90IbSeAH892zq7+97wrja4nCJtn2k=; b=Wtin3mX0Ev7yYdelfKhLUxmjbtFSl4hsIDm6uQ4DYV50Q+w55Em/pEngJOOOW8VKj0kxox tQzY0RYwWga+TJ4cn/TGBNGosX9Hhw1cRHrK4mRrTg//BNGD7H96ngce+vljJUCg2oqu6D sXAt5D814qFW8Kc+f/4rZCI6E4E4PBQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1768238436; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=1PoHnkFvFVa85D90IbSeAH892zq7+97wrja4nCJtn2k=; b=tMZ0cW9HguNUeOf9mQzFGesnecprQvYJ3p20DA2XZO039FzTR18IwSNT4oiw+Tea9P28jY UWMDmJuNHhSlzEBg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1768238436; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=1PoHnkFvFVa85D90IbSeAH892zq7+97wrja4nCJtn2k=; b=Wtin3mX0Ev7yYdelfKhLUxmjbtFSl4hsIDm6uQ4DYV50Q+w55Em/pEngJOOOW8VKj0kxox tQzY0RYwWga+TJ4cn/TGBNGosX9Hhw1cRHrK4mRrTg//BNGD7H96ngce+vljJUCg2oqu6D sXAt5D814qFW8Kc+f/4rZCI6E4E4PBQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1768238436; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=1PoHnkFvFVa85D90IbSeAH892zq7+97wrja4nCJtn2k=; b=tMZ0cW9HguNUeOf9mQzFGesnecprQvYJ3p20DA2XZO039FzTR18IwSNT4oiw+Tea9P28jY UWMDmJuNHhSlzEBg== 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 302053EA63; Mon, 12 Jan 2026 17:20:36 +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 AGW4C2QtZWkwEQAAD6G6ig (envelope-from ); Mon, 12 Jan 2026 17:20:36 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id D774AA09FC; Mon, 12 Jan 2026 18:20:35 +0100 (CET) Date: Mon, 12 Jan 2026 18:20:35 +0100 From: Jan Kara To: Bernd Schubert Cc: Jan Kara , Matthew Wilcox , Joanne Koong , Miklos Szeredi , Horst Birthelmer , "linux-fsdevel@vger.kernel.org" , Andrew Morton , "linux-mm@kvack.org" , "David Hildenbrand (Red Hat)" Subject: Re: __folio_end_writeback() lockdep issue Message-ID: References: <9b845a47-9aee-43dd-99bc-1a82bea00442@bsbernd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Queue-Id: 02255140012 X-Stat-Signature: oxzstebjheo8jouc1kg5wddn41fubu5x X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1768238437-378724 X-HE-Meta: U2FsdGVkX1/4J6O8rmfWPCfFx939XdbP1wqCw2ik9LZkBNp9Y8ZlGIQ3A2rZjEB9hVbvqwGuVM0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zGJWCSqzhIQMpwsJKDhkWxFKIuYCxQSxoMU8qdDuaYC+M1XAK70mtaLs3IUNPoSKMBztdGb1+V8JXF4T0iZwAdy6Gi0U876yHPFcX6Dpz5bbcRsF5QYY4P2PgfHDoIguKaD5T+KVESKKLFu4K/toqAUNptgGsAqTlZOeUpzUiGQ29h/EMdumLoaNMueZXI9T1GTXRoELLt5r0MugN4AuuFwJKPPgJ4PgbwyTMd5SAxv4I5782lkc5hSyHdsfuELx8= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Mon 12-01-26 14:13:26, Bernd Schubert wrote: > > > On 1/12/26 14:06, Jan Kara wrote: > > On Sat 10-01-26 16:30:28, Matthew Wilcox wrote: > >> On Sat, Jan 10, 2026 at 04:31:28PM +0100, Bernd Schubert wrote: > >>> [ 872.499480] Possible interrupt unsafe locking scenario: > >>> [ 872.499480] > >>> [ 872.500326] CPU0 CPU1 > >>> [ 872.500906] ---- ---- > >>> [ 872.501464] lock(&p->sequence); > >>> [ 872.501923] local_irq_disable(); > >>> [ 872.502615] lock(&xa->xa_lock#4); > >>> [ 872.503327] lock(&p->sequence); > >>> [ 872.504116] > >>> [ 872.504513] lock(&xa->xa_lock#4); > >>> > >>> > >>> Which is introduced by commit 2841808f35ee for all file systems. > >>> The should be rather generic - I shouldn't be the only one seeing > >>> it? > >> > >> Oh wow, 2841808f35ee has a very confusing commit message. It implies > >> that _no_ filesystem uses BDI_CAP_WRITEBACK_ACCT, but what it really > >> means is that no filesystem now _clears_ BDI_CAP_WRITEBACK_ACCT, so > >> all filesystems do use this code path and therefore the flag can be > >> removed. And that matches the code change. > >> > >> So you should be able to reproduce this problem with commit 494d2f508883 > >> as well? > >> > >> That tells me that this is something fuse-specific. Other filesystems > >> aren't seeing this. Wonder why ... > >> > >> __wb_writeout_add() or its predecessor __wb_writeout_inc() have been in > >> that spot since 2015 or earlier. > >> > >> The sequence lock itself is taken inside fprop_new_period() called from > >> writeout_period() which has been there since 2012, so that's not it. > >> > >> Looking at fprop_new_period() is more interesting. Commit a91befde3503 > >> removed an earlier call to local_irq_save(). It was then replaced with > >> preempt_disable() in 9458e0a78c45 but maybe removing it was just > >> erroneous? > >> > >> Anyway, that was 2022, so it doesn't answer "why is this only showing up > >> now and only for fuse?" But maybe replacing the preempt-disable with > >> irq-disable in fprop_new_period() is the right solution, regardless. > > > > So I don't have a great explanation why it is showing up only now and only > > for FUSE. It seems the fprop code is unsafe wrt interrupts because > > fprop_new_period() grabs > > > > write_seqcount_begin(&p->sequence); > > > > and if IO completion interrupt on this CPU comes while p->sequence is odd, > > the call to > > > > read_seqcount_begin(&p->sequence); > > > > in __folio_end_writeback() -> __wb_writeout_add() -> wb_domain_writeout_add() > > -> __fprop_add_percpu_max() -> fprop_fraction_percpu() will loop > > indefinitely. *However* this isn't in fact possible because > > fprop_new_period() is only called from a timer code and thus in softirq > > context and thus IO completion softirq cannot really preempt it. > > > > But for the same reason I don't think what lockdep complains about is > > really possible because xa_lock gets only used from IO completion softirq as > > well. Or can we really acquire it from some hard irq context? Based on > > lockdep report at least lockdep things IO completion runs in hardirq > > context but then I don't see why we're not seeing complaints like this all > > the time and even deadlocks I've described above. I guess I'll have to do > > some experimentation to refresh how these things behave these days... > > Is there anything that speaks about the patch I had posted? > __wb_writeout_add() doesn't need the xa lock? That's a bit hairy question :) because currently xa lock is what makes sure the wb we've got from the inode is still valid. Now that you've forced me to think about it: If we move __wb_writeout_add() from under xa lock, inode could be switched to different wb after we release xa lock and before we call __wb_writeout_add(). I don't think there is anything that would protect the wb from being freed in that case before __wb_writeout_add() and thus we could create UAF issue if I'm not mistaken. Honza -- Jan Kara SUSE Labs, CR