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 EF2EA2C234B for ; Tue, 3 Feb 2026 20:19:36 +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=1770149977; cv=none; b=d8/3YQ6OrQd7ZSPZ3ZjezvaS/kd11bzRr39eSqrNyxnOVKWeGhDjeuVyNIOYbAvUP5Wqyc7aM20luZoXPQNCpxy2OxGTBsKFKJaNgLDZMcK0EunO/PzuzsE8VELyl3phk5c4tBH34GEiNMm4jCQReuEbIXSQgts6S83FH936SE0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770149977; c=relaxed/simple; bh=ESPyrTkY5nECp0xEpdctE4imPIR+r/0MiQx5nu5jg1c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jKQsD31wXKQs9IMhLnxXB+6X3pWtfFwtOfXMR+51s1ua7sFTS2S+TpczeTInc2lZJCg1v0a+xsOg0J4DyccSIFxQ5lUDsfddSzsv8MQekE7vqaHU9gP0KqdWbXVX9Iz3n/ve1qlzWys50ZEU1dVvtPwkKfpeWXpXboT3OBcTFnk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=VzPNTFhA; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="VzPNTFhA" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 08132C116D0; Tue, 3 Feb 2026 20:19:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1770149976; bh=ESPyrTkY5nECp0xEpdctE4imPIR+r/0MiQx5nu5jg1c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VzPNTFhAj9tWfAtJWsfoecqowLKQ/Cd3XYMJCtCjfglrQPmDfKDL5zsEJ9reRyIZk QagwtNUWyVIssP3PqqV2kOfY5BRiWy8QdMy5IQ+ZjCU0rws3iBDXqTQHqoW1X8nTYC 9jL5I6QsgJwWdkzAfH35ICgdvIj2zfzFej+zvow0K9Yenp57uY4SCEcwYFNk+BgwRW sCRKnaOn1HqY5P/ZBZmfrgTVW130nLXDR3fxaiBpE9H9y2CbVGkHIWWwrvearoOpwj X5ZYdG+52BleMdzxWWfPOoPjG2SODOAId70j2s9ez71k8Su1oqTaYzDgJCwIFLiTZf Yn83aLqtLUxiQ== From: Sasha Levin To: stable@vger.kernel.org Cc: Laveesh Bansal , Jan Kara , Christian Brauner , Sasha Levin Subject: [PATCH 6.1.y] writeback: fix 100% CPU usage when dirtytime_expire_interval is 0 Date: Tue, 3 Feb 2026 15:19:34 -0500 Message-ID: <20260203201934.1387179-1-sashal@kernel.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <2026020305-spoils-sandworm-ccc5@gregkh> References: <2026020305-spoils-sandworm-ccc5@gregkh> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 --- fs/fs-writeback.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c index 75e8c102c5eef..0a36fc5e1bf2c 100644 --- a/fs/fs-writeback.c +++ b/fs/fs-writeback.c @@ -2360,12 +2360,14 @@ static void wakeup_dirtytime_writeback(struct work_struct *w) 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 ctl_table *table, int write, 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; } -- 2.51.0