From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 376CBC5AC67 for ; Thu, 6 Aug 2026 19:32:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 373306B0098; Thu, 6 Aug 2026 15:32:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3238F6B009F; Thu, 6 Aug 2026 15:32:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 261C26B00A3; Thu, 6 Aug 2026 15:32:34 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 094416B0098 for ; Thu, 6 Aug 2026 15:32:34 -0400 (EDT) Received: from smtpin13.hostedemail.com (lb01a-stub [10.200.18.249]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 93D37A0F20 for ; Thu, 6 Aug 2026 19:32:33 +0000 (UTC) X-FDA: 85071841386.13.D930CB1 Received: from lgeamrelo07.lge.com (lgeamrelo07.lge.com [156.147.51.103]) by imf30.hostedemail.com (Postfix) with ESMTP id 4F7CC8000C for ; Thu, 6 Aug 2026 19:32:31 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=none; spf=pass (imf30.hostedemail.com: domain of youngjun.park@lge.com designates 156.147.51.103 as permitted sender) smtp.mailfrom=youngjun.park@lge.com; dmarc=pass (policy=none) header.from=lge.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1786044752; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references; bh=XLlN1ovzTjhAxFTGUf8Dk3R8hkqV+QyGLVCYzczqdq8=; b=SzTExUjQ3gOHZoQQUqkL2ylGePh74o8qttK4wnylVJSQrg/qM3AvZCPIgq3yPTO6L2+V9B XtXm9jhm4Hyp97YegVstSaW24hj0nwtskukdvfJqO5+6W01I0/2c0S+s2e6Vs2zlfS6ZIt q8chN0D02t8vWJeEKs9LJUdWXWqo14s= ARC-Seal: i=1; a=rsa-sha256; d=hostedemail.com; s=arc-20220608; cv=none; t=1786044752; b=OzBGYrN4X66zCT/U3VhMrhudFMr3Q4qCk11N4QJuRHwY8d9acDmnLxyKp7d2X57r0jErL6 v8QgSzn6G6odskDfTSmA8UDzKD6InhVjsWROM580MnN/x6N4Wcv2xaT2p/gz/s0h+/mrWB jIN0P73mrdq7aC0979IdMZ/2J/lOirM= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=none; spf=pass (imf30.hostedemail.com: domain of youngjun.park@lge.com designates 156.147.51.103 as permitted sender) smtp.mailfrom=youngjun.park@lge.com; dmarc=pass (policy=none) header.from=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 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 4F7CC8000C X-Rspamd-Server: rspam10 X-Rspam-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CtBZCuLGLHhYsio3rcF+dkj4aKYHF9pK0iTE3uK0smblVqX32VQym/AZccg7obLCbEA3RtDrllbB3BpVEbHeNdgOOQty6SYx7y1ILCzwEQSbHR/2kWDgRtIy+t+ztYK+nCidqND1WRQRruMpGE1x/e7qWVi4wgqbw== Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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