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 A01FB29AB1D; Wed, 4 Feb 2026 15:19:17 +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=1770218357; cv=none; b=fdMzSRkyLN4Wvyx8W3X415xNB7b6X1HJLxg+s1Nxg4+p/wMpSBzbRyYGxMHPck7GAVBLGhZWfh4wHccO0r7C/QwwwrzDDwSOa9Eym4HFS07VIH/xxSj6QzulLF8VZvou/KsFwjPcRFbA2q8z7/ABWDNpLP9980KI8GDESWEt1YI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770218357; c=relaxed/simple; bh=sAsxKTxKPfun+eUmNbL+7JJpMtrx528E2vH36nHw8II=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=o7afco+V00s6oMJryhm1vn02bszoH6XiqjbJ51Hr1bFMK+iPp/uhvRrXP6EYZzDOc1WdpJ0OH82xSCZc3ZDP9XG4tIp+FbSqZ/eHAFgyb4bV/bmKhZoIYiUVuHMag4VwDfLWeq6B+8PIhHSF8qVIJoAzWNqVEibtl3HhFQF5V74= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=i99zJ1Us; 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="i99zJ1Us" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DB94FC4CEF7; Wed, 4 Feb 2026 15:19:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1770218357; bh=sAsxKTxKPfun+eUmNbL+7JJpMtrx528E2vH36nHw8II=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=i99zJ1UsSk64p9DTXnlxssB9bLvipkWJQtCcqvZGJoWS9AJyniHjKV+ezAxtuacBU KF/Y+oqOKBWGwyZRJHVX//FtoMDLcwJqgfB5JsV0vAvTlM6MpS4/5gYwRfPEghWCpw /DCoN6gJr7OZtPjX6d9EVzgI2GobALy1OYcf+U1k= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Laveesh Bansal , Jan Kara , Christian Brauner , Sasha Levin Subject: [PATCH 6.1 277/280] writeback: fix 100% CPU usage when dirtytime_expire_interval is 0 Date: Wed, 4 Feb 2026 15:40:51 +0100 Message-ID: <20260204143919.672252584@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260204143909.614719725@linuxfoundation.org> References: <20260204143909.614719725@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.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Laveesh Bansal [ Upstream commit 543467d6fe97e27e22a26e367fda972dbefebbff ] When vm.dirtytime_expire_seconds is set to 0, wakeup_dirtytime_writeback() schedules delayed work with a delay of 0, causing immediate execution. The function then reschedules itself with 0 delay again, creating an infinite busy loop that causes 100% kworker CPU usage. Fix by: - Only scheduling delayed work in wakeup_dirtytime_writeback() when dirtytime_expire_interval is non-zero - Cancelling the delayed work in dirtytime_interval_handler() when the interval is set to 0 - Adding a guard in start_dirtytime_writeback() for defensive coding Tested by booting kernel in QEMU with virtme-ng: - Before fix: kworker CPU spikes to ~73% - After fix: CPU remains at normal levels - Setting interval back to non-zero correctly resumes writeback Fixes: a2f4870697a5 ("fs: make sure the timestamps for lazytime inodes eventually get written") Cc: stable@vger.kernel.org Closes: https://bugzilla.kernel.org/show_bug.cgi?id=220227 Signed-off-by: Laveesh Bansal Link: https://patch.msgid.link/20260106145059.543282-2-laveeshb@laveeshbansal.com Reviewed-by: Jan Kara Signed-off-by: Christian Brauner [ adapted system_percpu_wq to system_wq for the workqueue used in dirtytime_interval_handler() ] Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- fs/fs-writeback.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) --- a/fs/fs-writeback.c +++ b/fs/fs-writeback.c @@ -2360,12 +2360,14 @@ static void wakeup_dirtytime_writeback(s wb_wakeup(wb); } rcu_read_unlock(); - schedule_delayed_work(&dirtytime_work, dirtytime_expire_interval * HZ); + if (dirtytime_expire_interval) + schedule_delayed_work(&dirtytime_work, dirtytime_expire_interval * HZ); } static int __init start_dirtytime_writeback(void) { - schedule_delayed_work(&dirtytime_work, dirtytime_expire_interval * HZ); + if (dirtytime_expire_interval) + schedule_delayed_work(&dirtytime_work, dirtytime_expire_interval * HZ); return 0; } __initcall(start_dirtytime_writeback); @@ -2376,8 +2378,12 @@ int dirtytime_interval_handler(struct ct int ret; ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos); - if (ret == 0 && write) - mod_delayed_work(system_wq, &dirtytime_work, 0); + if (ret == 0 && write) { + if (dirtytime_expire_interval) + mod_delayed_work(system_wq, &dirtytime_work, 0); + else + cancel_delayed_work_sync(&dirtytime_work); + } return ret; }