From patchwork Wed Dec 11 15:05:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filipe Manana X-Patchwork-Id: 13903635 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 728891B6D0D for ; Wed, 11 Dec 2024 15:05:16 +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=1733929516; cv=none; b=tSoy2AdWX2XafBh3CB//x46wJQl/qzUrrT37phvP6qdVU+3VzGGdTmyP2IF1iZx/gRqIQhlZ8Ck6fRlShvpwvODo0GrLzVbX6YqMIM/5+yTGPvdsEmnm/DV7vTDkEasq6y2Niy2Ztt+L5KPIossTzopqQmLOH1oumOrBzTHrQE8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733929516; c=relaxed/simple; bh=gcJlCl3eYEkScuFHlQMq13/7I4cWeKB5TpS20bMssO8=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=QsrEXKNxUAAo+UhkdV5BuEm4SE/Si20hD2CJo0s0kQE+eqVc0qo5v/rdfSEyaF7/+oX3hErq4J7IJ+ypzfwyruZLWepW9rvCuzwA/Gsn6A0CXgFfsDGM37RNh5CeSLL1i4unchJ18P2z1qxpKYfXjp01kYV5ydQT9nRYkCfzyM8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=clqktjK4; 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="clqktjK4" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6DDFBC4CED7 for ; Wed, 11 Dec 2024 15:05:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1733929516; bh=gcJlCl3eYEkScuFHlQMq13/7I4cWeKB5TpS20bMssO8=; h=From:To:Subject:Date:In-Reply-To:References:From; b=clqktjK4Vm2tqJLP96O4Z/7Yx0vm+UV10X3mwQishiTPM4k2q6e2dXqNxurLEZNts rFp9ojXMBvBGM7oDDsSAU2r7HJs7nS9eToMdNRE2Yg0GLPHNtPM8Niks3vLuF8v5MD 3cNKr9Ih5rplRcgS0CGrGny9ti2Ii3CmTg4vnZB9/nehR88mO1TpXsMyc6J3+9rmKY XbEs3FG6uBd5XwQjlGMPUACPI3hIaJeRi50l0UQEzBnaHD/ih2qkN9DjAeugUomCer K+IS9bkMplcwTzSNWZ7QJQs6hC2MCe5v1fivNPfGTT8DxUOGaKuDFnOXPRfUOmrTPM vPIXzR+Pq7+xQ== From: fdmanana@kernel.org To: linux-btrfs@vger.kernel.org Subject: [PATCH v2 04/11] btrfs: avoid monopolizing a core when activating a swap file Date: Wed, 11 Dec 2024 15:05:01 +0000 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Filipe Manana During swap activation we iterate over the extents of a file and we can have many thounsands of them, so we can end up in a busy loop monopolizing a core. Avoid this by doing a voluntary reschedule after processing each extent. Signed-off-by: Filipe Manana --- fs/btrfs/inode.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 5edc151c640d..283199d11642 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -10078,6 +10078,8 @@ static int btrfs_swap_activate(struct swap_info_struct *sis, struct file *file, ret = -EINTR; goto out; } + + cond_resched(); } if (bsi.block_len)