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 B3E053CF365; Sat, 28 Feb 2026 17:40:13 +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=1772300413; cv=none; b=TPsPAswounpnyyT46wim6N8t5tt5s9mOPPLkOnIwTnErboU3dewbDFjFBafA15DVe6m4QrtQ16D6GMwe2oZPcMv1KoNzTnaoqab4yT8qtwAAQMlglrHOvju3jyZLQnabR1So9OiPCgAjPSki+aWb8AAqLyAx4z0iiyFlHIBgSwE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772300413; c=relaxed/simple; bh=CHIQ8RFlYm6XssHKC0qEZNneuTPqhYyW6GTW/jhvNzA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XvG0Rcge6vsZQGm+nHmuHwNiZRkw04Eq4ccl96azMzBNfwmmfMfFAn0XmGvFhYRGkLUUgIdzgKhgHOXeyhcmlRm12XUUGUduzG1MFYBBWGpwc0PECshluior+K+QP5P3+yOAsYXdYJwsK7qJnG0ErN810AmcNJ5aphh9YQD+4Go= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=tcfVUVws; 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="tcfVUVws" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EAB35C116D0; Sat, 28 Feb 2026 17:40:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1772300413; bh=CHIQ8RFlYm6XssHKC0qEZNneuTPqhYyW6GTW/jhvNzA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tcfVUVwsKhsMksy0DGoRl+BccbjaLRkRCy/Y7EcZMlNJpBYqCznBv9SVsOcK2wdPk AV+7+VPj0cr/9VWivfTmWUcbuCV5XiPa9xv+65ODKjNltz6ZpDhsPHHk8/qnhjDxxe 8pzMSa8PtUBDS9ZCDPVPsJ5pUKLHT/ESfjsDGjlgU/Ec/RNXyNaeadQpnnEdK5yINZ fa9sWYoJFxZRtztvJReZoiVy+OL4KDwwy2Dq2NryUUPQju30wLEilxNgxhEthqlIt7 7wJ5W5xVQsCHUaDdpNM+TnCdOkS2E8zXKeBdxBOKIE3MFkV93Z8pfahlfrauWNlj/Q CfJ3N0R4EAbjw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Huacai Chen , Jan Kara , Christian Brauner , Sasha Levin Subject: [PATCH 6.19 451/844] writeback: Fix wakeup and logging timeouts for !DETECT_HUNG_TASK Date: Sat, 28 Feb 2026 12:26:04 -0500 Message-ID: <20260228173244.1509663-452-sashal@kernel.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260228173244.1509663-1-sashal@kernel.org> References: <20260228173244.1509663-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit From: Huacai Chen [ Upstream commit 9eed043d10f17301c1b5141e16bb98a85a8fd07e ] Recent changes of fs-writeback cause such warnings if DETECT_HUNG_TASK is not enabled: INFO: The task sync:1342 has been waiting for writeback completion for more than 1 seconds. The reason is sysctl_hung_task_timeout_secs is 0 when DETECT_HUNG_TASK is not enabled, then it causes the warning message even if the writeback lasts for only one second. Guard the wakeup and logging with "#ifdef CONFIG_DETECT_HUNG_TASK" can eliminate the warning messages. But on the other hand, it is possible that sysctl_hung_task_timeout_secs be also 0 when DETECT_HUNG_TASK is enabled. So let's just check the value of sysctl_hung_task_timeout_secs to decide whether do wakeup and logging. Fixes: 1888635532fb ("writeback: Wake up waiting tasks when finishing the writeback of a chunk.") Fixes: d6e621590764 ("writeback: Add logging for slow writeback (exceeds sysctl_hung_task_timeout_secs)") Signed-off-by: Huacai Chen Link: https://patch.msgid.link/20260203094014.2273240-1-chenhuacai@loongson.cn Reviewed-by: Jan Kara Signed-off-by: Christian Brauner Signed-off-by: Sasha Levin --- fs/fs-writeback.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c index 5444fc706ac7d..79b02ac66ac6d 100644 --- a/fs/fs-writeback.c +++ b/fs/fs-writeback.c @@ -198,10 +198,11 @@ static void wb_queue_work(struct bdi_writeback *wb, static bool wb_wait_for_completion_cb(struct wb_completion *done) { + unsigned long timeout = sysctl_hung_task_timeout_secs; unsigned long waited_secs = (jiffies - done->wait_start) / HZ; done->progress_stamp = jiffies; - if (waited_secs > sysctl_hung_task_timeout_secs) + if (timeout && (waited_secs > timeout)) pr_info("INFO: The task %s:%d has been waiting for writeback " "completion for more than %lu seconds.", current->comm, current->pid, waited_secs); @@ -1944,6 +1945,7 @@ static long writeback_sb_inodes(struct super_block *sb, .range_end = LLONG_MAX, }; unsigned long start_time = jiffies; + unsigned long timeout = sysctl_hung_task_timeout_secs; long write_chunk; long total_wrote = 0; /* count both pages and inodes */ unsigned long dirtied_before = jiffies; @@ -2030,9 +2032,8 @@ static long writeback_sb_inodes(struct super_block *sb, __writeback_single_inode(inode, &wbc); /* Report progress to inform the hung task detector of the progress. */ - if (work->done && work->done->progress_stamp && - (jiffies - work->done->progress_stamp) > HZ * - sysctl_hung_task_timeout_secs / 2) + if (work->done && work->done->progress_stamp && timeout && + (jiffies - work->done->progress_stamp) > HZ * timeout / 2) wake_up_all(work->done->waitq); wbc_detach_inode(&wbc); -- 2.51.0