From mboxrd@z Thu Jan 1 00:00:00 1970 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 63EF92C026F; Wed, 4 Feb 2026 15:27:25 +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=1770218845; cv=none; b=OFgT1551NXR/RaBJBjSUD1rejuxyg9J8uTKfF40kS/yUzkTq5m5zPzXZLwUf04SrS2PjPelcoxpgaCyRoT5tWOX1JBzE4xz4XdaAS25gN6GTeDJ23hJGJwKcRbMKQ+VDnQV3FkpGadZfStoRPRyQCNvHfiNjCwWKHYcC9a5zmp0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770218845; c=relaxed/simple; bh=ykUMaf4sew9MiioIIcOuKMakV9/j2ED3Kp1pJ7SNDKc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=P0VUigi4u767omAwU4fmKfVhk3+RboA6OEB7PzV+nOeqD6e3U0OCnG+7pmAehT2fFKtCY3asm8NoRYNpCuQLKuz34njaDkJpswG610v/orlhAI97Jf2BhLnkZ/5pzYCEJkTCLJBkSdhbQs8vIKNgrxRwJkFg72dj2QslyZVMzk4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=UCPvLRkV; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="UCPvLRkV" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D3121C4CEF7; Wed, 4 Feb 2026 15:27:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1770218845; bh=ykUMaf4sew9MiioIIcOuKMakV9/j2ED3Kp1pJ7SNDKc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UCPvLRkV6/1ED79yX986LF/R8rO22leOrmdGh9PgDobKMtufVHIVXjvT2vlEqLuAT Iboia+KDbcIKY3bBh1SCvSo3O76HyMS+AulHB5QQhW7xGUabOS6a02hKmQGwVzLSuC AbeaWj2FFXwhPv2wzMOyXxsI4OqQfRRBnd4shsdA= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Jan Kara , Bernd Schubert , "Matthew Wilcox (Oracle)" , Joanne Koong , Miklos Szeredi , Andrew Morton Subject: [PATCH 6.12 51/87] flex_proportions: make fprop_new_period() hardirq safe Date: Wed, 4 Feb 2026 15:40:49 +0100 Message-ID: <20260204143848.753202836@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260204143846.906385641@linuxfoundation.org> References: <20260204143846.906385641@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jan Kara commit dd9e2f5b38f1fdd49b1ab6d3a85f81c14369eacc upstream. Bernd has reported a lockdep splat from flexible proportions code that is essentially complaining about the following race: run_timer_softirq - we are in softirq context call_timer_fn writeout_period fprop_new_period write_seqcount_begin(&p->sequence); ... blk_mq_end_request() blk_update_request() ext4_end_bio() folio_end_writeback() __wb_writeout_add() __fprop_add_percpu_max() if (unlikely(max_frac < FPROP_FRAC_BASE)) { fprop_fraction_percpu() seq = read_seqcount_begin(&p->sequence); - sees odd sequence so loops indefinitely Note that a deadlock like this is only possible if the bdi has configured maximum fraction of writeout throughput which is very rare in general but frequent for example for FUSE bdis. To fix this problem we have to make sure write section of the sequence counter is irqsafe. Link: https://lkml.kernel.org/r/20260121112729.24463-2-jack@suse.cz Fixes: a91befde3503 ("lib/flex_proportions.c: remove local_irq_ops in fprop_new_period()") Signed-off-by: Jan Kara Reported-by: Bernd Schubert Link: https://lore.kernel.org/all/9b845a47-9aee-43dd-99bc-1a82bea00442@bsbernd.com/ Reviewed-by: Matthew Wilcox (Oracle) Cc: Joanne Koong Cc: Miklos Szeredi Cc: Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman --- lib/flex_proportions.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) --- a/lib/flex_proportions.c +++ b/lib/flex_proportions.c @@ -64,13 +64,14 @@ void fprop_global_destroy(struct fprop_g bool fprop_new_period(struct fprop_global *p, int periods) { s64 events = percpu_counter_sum(&p->events); + unsigned long flags; /* * Don't do anything if there are no events. */ if (events <= 1) return false; - preempt_disable_nested(); + local_irq_save(flags); write_seqcount_begin(&p->sequence); if (periods < 64) events -= events >> periods; @@ -78,7 +79,7 @@ bool fprop_new_period(struct fprop_globa percpu_counter_add(&p->events, -events); p->period += periods; write_seqcount_end(&p->sequence); - preempt_enable_nested(); + local_irq_restore(flags); return true; }