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 30E92264636 for ; Sun, 4 Jan 2026 02:08:19 +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=1767492499; cv=none; b=lEubZnNK67v9dnShFdqaiiHfXOigJJLhZFnd37C5zQrA+nyGGlagv559HLW0KT+so6r54XwpKs6kNRjAsnWNq/xELc+rqZ3/fKlIuNKZwuyOOvNsT41SLy6cSAVj4af+3s1q6ChXpTb2sSjZjvsXcUPn5VbIvUtsO+HIDpAVUzU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767492499; c=relaxed/simple; bh=60UVB4W5HK+obx+wEZMpdwOTBdFj32mqZwuFWRScR+w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mcUF9TPUJ1QUsYopgvbDpg9MaFW64KK/cLnU2OHT7MYXM51RQp2DPVJlucLKYNe3YllN1k1LZdqgeaeaKltlERCjT7H0L0re71gDcT1uV4gNsCR096Fw7T056jMzKlsMEQ7RjNEuoWcLo9+3v0ylFxXL76ZF6ZikL79WuwcDVfE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ZoazZiuw; 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="ZoazZiuw" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DB32EC16AAE; Sun, 4 Jan 2026 02:08:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1767492498; bh=60UVB4W5HK+obx+wEZMpdwOTBdFj32mqZwuFWRScR+w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZoazZiuwPCE+vC2O0jz0M+ltH+/h3k/TMp4s/4C/5NKV/3Eo9OZvASKTHg9HbPZGO +kw+F1tXPKFt8JrtyFpSQ7fsl9S/PIPzTRVYPuD+Q4d4PAGQGNvSHvOsT8hYh57ka6 Jh1wiRTiBiKPAIJp58SyJtIexpfRfKNL6KlidcwYSDOgS5U9inos28O1q/FXF3MZur 82cnZQC8S0za3rPJgA4DbnwZxMF0SteWFTdeV83VzPl0DCh19nV/AvMrWN7iHlMqKW a5VmK9MpC70f7qsEfJHEpMBwPZOU33Bi8JczJpItdqzjuY3c5lRqnoWGxngd/gbR6O XvNvdGdqq7oZw== From: Chao Yu To: jaegeuk@kernel.org Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, Chao Yu Subject: [PATCH 11/14] f2fs: fix timeout precision of f2fs_io_schedule_timeout_killable() Date: Sun, 4 Jan 2026 10:07:26 +0800 Message-ID: <20260104020729.1064529-11-chao@kernel.org> X-Mailer: git-send-email 2.52.0.358.g0dd7633a29-goog In-Reply-To: <20260104020729.1064529-1-chao@kernel.org> References: <20260104020729.1064529-1-chao@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sometimes, f2fs_io_schedule_timeout_killable(HZ) may delay for about 2 seconds, this is because __f2fs_schedule_timeout(DEFAULT_SCHEDULE_TIMEOUT) may delay for about 2 * DEFAULT_SCHEDULE_TIMEOUT due to its precision, but we only account the delay as DEFAULT_SCHEDULE_TIMEOUT as below, fix it. f2fs_io_schedule_timeout_killable() .. timeout -= DEFAULT_SCHEDULE_TIMEOUT; Signed-off-by: Chao Yu --- fs/f2fs/f2fs.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index c4d3b37821d6..54cde9a0e24c 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -4985,13 +4985,12 @@ static inline void __f2fs_schedule_timeout(long timeout, bool io) static inline void f2fs_io_schedule_timeout_killable(long timeout) { - while (timeout) { + unsigned long last_time = jiffies + timeout; + + while (jiffies < last_time) { if (fatal_signal_pending(current)) return; __f2fs_schedule_timeout(DEFAULT_SCHEDULE_TIMEOUT, true); - if (timeout <= DEFAULT_SCHEDULE_TIMEOUT) - return; - timeout -= DEFAULT_SCHEDULE_TIMEOUT; } } -- 2.49.0