From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from lgeamrelo07.lge.com (lgeamrelo07.lge.com [156.147.51.103]) (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 7ADF3305699 for ; Thu, 6 Aug 2026 19:47:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=156.147.51.103 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786045654; cv=none; b=MKWBb2qPGL9GmsNN/I8pIyN+6Gh8RhyWcfBeujZxCXNTMsnK6QOToHuLrxQkjiRDFZ0hiXrC3jItZw38Cv6ahuvKPqb7pbkzks20ZjIpD8Zb7vYQIhlZxSuwS9eWj45Igzm9dz1lj4raySKyIab4p0pLA6p8HkPJw71U8Kqwirw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786045654; c=relaxed/simple; bh=sL8UYDb/e4/OuMysTeJxJB2H3ds6ko3tHYDJWSp6yN8=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=JMXsid8zZlPMu+AZtpNnpGauPMl4sgMvRs88y442XgcxgD1TNmo1S8tA+93QjSSStVQaOf+m6Yf6XlMkkcJJqBkfabsieY7qNp7odEi6wai/wm8VX8y/A9b1k6BXuM3yDHOJrGn78baNJ1Yxm5jM+CgcBrNYUPwG3zGlHroM9rE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=lge.com; spf=pass smtp.mailfrom=lge.com; arc=none smtp.client-ip=156.147.51.103 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=lge.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=lge.com Received: from unknown (HELO yjaykim-PowerEdge-T330.lge.net) (10.177.112.156) by 156.147.51.103 with ESMTP; 7 Aug 2026 04:32:28 +0900 X-Original-SENDERIP: 10.177.112.156 X-Original-MAILFROM: youngjun.park@lge.com From: Youngjun Park To: Andrew Morton Cc: Chris Li , Kairui Song , Kemeng Shi , Nhat Pham , Baoquan He , Barry Song , Youngjun Park , her0gyugyu@gmail.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 0/2] mm/swap: skip empty clusters in the swapoff scan Date: Fri, 7 Aug 2026 04:32:26 +0900 Message-Id: <20260806193228.458685-1-youngjun.park@lge.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit find_next_to_unuse() walks a swap device one offset at a time. Slot state now lives in a per cluster swap table, so patch 2 dismisses an empty cluster with one counter read instead of SWAPFILE_CLUSTER table reads. Patch 1 is an unrelated one line comment fix noticed on the way. A debug test confirmed the skip path runs, and swapoff completed under load with no DEBUG_VM or lockdep splats. Changes in v3: - 2/2: clamp the scan end with min_t() so it stops at si->max, rather than running into the masked tail of the last cluster, which drops the need to explain why walking that tail was safe (Barry) - 2/2: compute ci_off only where it is used - 1/2, 2/2: pick up Barry's Reviewed-by - Rebased on mm-new - Link to v2: https://lore.kernel.org/r/20260805141146.127776-1-youngjun.park@lge.com Changes in v2: - 1/2: reword the comment to "array, one entry per cluster", dropping the redundant "on every device" (Barry) - 1/2: pick up Kairui's Acked-by - 2/2: drop the min(), the swap table is always SWAPFILE_CLUSTER entries and swapon() masks the tail past si->max as bad (Kairui) - 2/2: mark the unlocked ci->count read with READ_ONCE() for KCSAN instead of cluster_is_empty(), whose other callers hold ci->lock (Kairui) - 2/2: expand the commit message to cover both of the above - Rebased on mm-new - Link to v1: https://lore.kernel.org/r/20260728155907.391820-1-youngjun.park@lge.com Youngjun Park (2): mm/swap: fix stale comment on swap_info_struct::cluster_info mm/swap: scan by cluster in find_next_to_unuse() include/linux/swap.h | 2 +- mm/swapfile.c | 43 ++++++++++++++++++++++++++++++------------- 2 files changed, 31 insertions(+), 14 deletions(-) base-commit: 1fb556c523f6c18b43b1f52fb366f61c9963ce06 -- 2.48.1