From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=220.197.31.2 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796439359; b=HEoU7vGUlHp3XMZFY9RG6OFqNGvEsMYsGz8Xc4mf7Zby44Pm1hLZcA++NhfbnPjLuN7C hcwtz+WyP3VfBVXYQKSctNzZSGOZ3OLRI/EGPB+hYYPgyHx1rX9DcQ0G6vgCRC+u1lHB1 5dZsyVRshiIqCKSYyB30llviLDzwJKhNL+RxxGtYVZk5hAiBKnWHazZ1O6VpwLobTDs3p AdwNcVn/QZDT7VZ9FrZmOmF4eIQ8oPstrX1W5O7bPk7HhpIxUiKqunA0lMwciwRViK0Oa HKGbEoqG0Ucihxq5RnOcbURIRuZDPOiHdM18UXpILzKGGuy7bMbhu4YbsWVL7/NgoLw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796439359; h=DMARC-Filter:DKIM-Signature:Received:From:To:Cc:Subject:Date: Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:X-CM-TRANSID:X-Coremail-Antispam: X-CM-SenderInfo; bh=Jifo7Vwbcr1kMfjMtk9md1ZNzC7zRkKzhqWk4uwa2SE=; b=EkCDnaRqoV7OoYbMbDhtowsRYRMeJoi8zhrBiHOSqh6uhp9Gtpg/YphYQ0uw9I+AwuO4 Jijik2HEwtpWLG9VIjPcavAlLG1TPtwFGycke7uiSmZpNo07Bmjmp9PKKr5yw5FAC/HIF zBpe2gAXJIFYaugvtaIvOaUNTK0PZ0Gu1zVDMBBBDpiEDqQXV5dlAG/MHY+IPf1PAyBZp yMpYSk7okvNDxXPlO2hB5SqdMHPGgBjWsHzWFVeKaotdnc+qpQ64uTXsTP9OOFuQ1fhNh 90K8slitK7IhH4NyYWEkGq8S+879gwXo73Z38FRGMv4mtkw3LWosF5Mf+llFROBKD6A== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=163.com; spf=pass smtp.mailfrom=163.com; dkim=pass header.d=163.com header.i=@163.com header.a=rsa-sha256 header.s=s110527 header.b=Gwdq2IO0; arc=none smtp.remote-ip=220.197.31.2 Received: from m16.mail.163.com (m16.mail.163.com [220.197.31.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 86501606A322 for ; Sat, 5 Dec 2026 02:55:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 86501606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=163.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.a=rsa-sha256 header.s=s110527 header.b=Gwdq2IO0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=Ji fo7Vwbcr1kMfjMtk9md1ZNzC7zRkKzhqWk4uwa2SE=; b=Gwdq2IO0z6LlaLcC9O 1HkFI/UP9AXu7x6yzGJ3nQXGyBdO5z+zWATS5X/jF4dkZ9eGpjTyTMkTaD9575MT Z4RpL9UYveFVnU1GGtB0NYavVd+qGYsCOluwWqwZcLXdlDyrhEjdOGFeaYIfUba4 1+7Cjy9ol0NcXKEGjaqcJ8IyI= Received: from localhost.localdomain (unknown []) by gzga-smtp-mtada-g0-4 (Coremail) with SMTP id _____wDnbzcUfRNr417ANQ--.798S2; Sat, 05 Dec 2026 10:55:17 +0800 (CST) From: albin_yang@163.com To: youngjun.park@lge.com Cc: akpm@linux-foundation.org, albin_yang@163.com, albinwyang@tencent.com, baohua@kernel.org, baoquan.he@linux.dev, chrisl@kernel.org, kasong@tencent.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, nphamcs@gmail.com Subject: Re: [PATCH v2] mm/swap: skip devices without SWP_PAGE_DISCARD in swap_sync_discard() Date: Sat, 5 Dec 2026 10:55:16 +0800 Message-ID: <20261205025516.308616-1-albin_yang@163.com> X-Mailer: git-send-email 2.43.7 In-Reply-To: References: X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID:_____wDnbzcUfRNr417ANQ--.798S2 X-Coremail-Antispam: 1Uf129KBjvJXoWrKr4fJr47XFWfCrWftFy8Grg_yoW8JrWUpr sYgws3ta1qgrsruw47Zr48Gw4FvwnxGa95Gry7Gryj9wnxGryFq3y5CFW7JFyqgrn3AFyF vayUt347CFW2kF7anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0JUpCJPUUUUU= X-CM-SenderInfo: pdoex0xb1d0wi6rwjhhfrp/xtbC7xUEpmsTfRWTxAAA3f Hi Youngjun, On Fri, 4 Dec 2026 13:52:06 +0900, Youngjun Park wrote: > Looking at your use case, there seems to be no discard device at all. > > What about counting SWP_PAGE_DISCARD devices like nr_rotate_swap, so we > can skip the walk (and swap_lock) entirely when it's zero? Might be a > bit local, but swap on discard devices isn't that common. > It is just opinion for curios about your thought. no serious consideration plz :) Interesting idea, but a counter would need to stay consistent with swap_active_head across swapon/swapoff, and it only saves the last lock/unlock pair now that the scan is down to 2 operations. Better to leave that to the structural rework and keep this fix minimal. > This inner check should be redundant now, right? Can we drop it? Yes. All runtime writes to si->flags for an enabled device hold swap_lock, so the loop-head check is stable. After the unlock those writes only touch SWP_WRITEOK/SWP_HIBERNATION; the only runtime place clearing SWP_PAGE_DISCARD is swapoff's p->flags = 0, which comes after percpu_ref_kill(), so a live ref from get_swap_device_info() cannot reach it. The inner check is therefore always true, and is itself a read outside swap_lock. I'll drop it in v3. Thanks, Wei Yang