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]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7F290D11701 for ; Fri, 25 Oct 2024 06:41:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 71B9D6B0082; Fri, 25 Oct 2024 02:41:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6A4A56B0083; Fri, 25 Oct 2024 02:41:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 545956B0085; Fri, 25 Oct 2024 02:41:47 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 32EF56B0082 for ; Fri, 25 Oct 2024 02:41:47 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 0864D805E5 for ; Fri, 25 Oct 2024 06:41:30 +0000 (UTC) X-FDA: 82711178844.29.D4B7739 Received: from forward500d.mail.yandex.net (forward500d.mail.yandex.net [178.154.239.208]) by imf20.hostedemail.com (Postfix) with ESMTP id C0E6E1C0012 for ; Fri, 25 Oct 2024 06:41:20 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=yandex.ru header.s=mail header.b=HcNU2Nxv; spf=pass (imf20.hostedemail.com: domain of Hi-Angel@yandex.ru designates 178.154.239.208 as permitted sender) smtp.mailfrom=Hi-Angel@yandex.ru; dmarc=pass (policy=none) header.from=yandex.ru ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1729838452; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=MirYaYf42Z/5qguWwalsY5yjgzJLNsgurMJJU6yedNY=; b=dZ0EewSVAGc/wqqLXKOs+zDCj+l4U+1aMkC0vqFKDI7NsxRdHSOdMsOBHfzxrhPZZxEu3J 89mT3YXm7ZSW2HcV6pbf4Og+jA57UGT9DAV/WKEuCSz19Qx9MfhwtiwuDVw5IEiT2xKXFq wKC4U0NS7xZr8I99kfkEP2TPoA7ebVI= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=yandex.ru header.s=mail header.b=HcNU2Nxv; spf=pass (imf20.hostedemail.com: domain of Hi-Angel@yandex.ru designates 178.154.239.208 as permitted sender) smtp.mailfrom=Hi-Angel@yandex.ru; dmarc=pass (policy=none) header.from=yandex.ru ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1729838452; a=rsa-sha256; cv=none; b=EFmHRqaonCBJ1NqkBD1At40CypP8UPIEM2PB66Wk0uai0ZcaZ7aFIzBS++bodNSboUY46g oXdI5OCVAdckW3R9Qcw+ngZ4MdFAWIWjBJE4DNfAmAMja+cg/GusQhOeOaJvWGi0sWJXRF BWkOegla8BMRQGQOiKfBd0vh9wNP0cQ= Received: from mail-nwsmtp-smtp-production-main-99.klg.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-99.klg.yp-c.yandex.net [IPv6:2a02:6b8:c42:94a0:0:640:af90:0]) by forward500d.mail.yandex.net (Yandex) with ESMTPS id BEF7960FDD; Fri, 25 Oct 2024 09:41:42 +0300 (MSK) Received: by mail-nwsmtp-smtp-production-main-99.klg.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id ffOZJ36OjCg0-0f5bbx83; Fri, 25 Oct 2024 09:41:42 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1729838502; bh=MirYaYf42Z/5qguWwalsY5yjgzJLNsgurMJJU6yedNY=; h=References:Date:In-Reply-To:Cc:To:From:Subject:Message-ID; b=HcNU2Nxv4lk80APaBuyM38fSh7q5mHloavhwvkf2qZRVQSMimvUCzPE3WNxGhYRrX 3hwxR6jRnRRTsTXSPdA7BhRBFP5+uyTQF/5zr6nOu7R2bt4Od45IQudtk7WUnRD2Tl ptW5Q7myptm7Us38/2SJLkSGm5dxrcFLyB+JDoE0= Message-ID: <28352fb75268060f2e78a32325f02e46737a16ea.camel@yandex.ru> Subject: Re: [BUG] ZSwap leaks memory upon being disabled From: Konstantin Kharlamov To: Yosry Ahmed Cc: linux-mm@kvack.org, Johannes Weiner , Nhat Pham , Chengming Zhou Date: Fri, 25 Oct 2024 09:41:39 +0300 In-Reply-To: References: <7d873b2682a7513a4d5aad5ac09f5c78851efbb6.camel@yandex.ru> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.54.0 MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: inegphjkuiu8f96344jybinp4bfe8f3f X-Rspamd-Queue-Id: C0E6E1C0012 X-Rspamd-Server: rspam11 X-HE-Tag: 1729838480-544133 X-HE-Meta: U2FsdGVkX1+YuYvlIVBMXUH9qJ9ArY1fy5nQq21gk5dWL89DHXzipwJ3Clvz23EcILvJcNcMqbEpvdf7hwnFuTRneU8c2BM3C38HUCTeLSB5fxr0RAF9pWODt+462xyXUybDwmrSnEIMbAIXiYw9I6Stybu+HYiD6SV4cA4UbEpms/4JTj7iz+FCnVwkE4pDiHvUyt3ItdPdRq/AGybG4zoF4LWrEScfR74f6b4S6HAQdafromuAULIf3PiDad8EAMNr+SkfPu+fpwmu9pKwMXMZm31/t/+Jhai4Ps++uZqfV4VUTS5ByBmsUszfSmw68GHLTmcFfzCn00XIrLqxb6zsnL76K9Z8VxEZNF2aPg9ajPILDZAk/YK6IK6b893eIiCe5AjNdc6stUIW/8UB0s6ZIVG8H2XOAmsKnEB81wNNY/jjVE7HhZ6tnluHgdAtSl3uKUpjeiNrUNZPZqhsKlE3rkApj+0PmCyXEpXMaugrOWJiQ7L6mSio20F07nE6yLzlJ7AYYV+LPA2MmTsASaRkilATEufs1P1n9wlG5a9zA9huDa14g95b9r37GgGwAQaC0bkXiIqq2tUX4FIEXSnRfqHfFODu7ZLa/7v/I2nKOK6Tbh0HzkQf6lXtvqfSh7AaBnFrmslAdDBjGJ9YMeLsRCVTbL4YCPVlw897adShY+xag9w9489SIZyNLnclCtVlfoCnelCDQ7jBKJkflpOmj7v/aeYIX1IsHeCjd5FFI4kDPWIsfzavkj0ZsqnnCK0TZMK1eiIqUbsrbXnbL280QIFEjZ91jK7EPJcn9SOAF6zLDLGi50ibV13De4j1ZJFK10MBmOhqH0te9a8zVlh9zQFlYXdPO5V5Hqo3iLKF64ruqZSMGbrOCf7wSvJo6c3/kEgOpPdtF3LMQtf0N9Wtt8fQIM7X/TZPuQ/T9S+5brU2fIKbo131JKb+4fu29yY0M82xHjmBhjMGkOj gPwherNl BUU8LYujtHzdgPmRXYWUuAWYnx9kAtTy1ErX8mr+S71HonHhb32xfLliWc51UgBxQ9Ideh45C2AUGKVTdJboWVPbO3ys1FfjTEu/vHGMZNhwXZKno5TgvTDXhos6eIzXjUP98dfJgBmXGL51+BmRYTGU4JU4wC+g4ezW8HTNu1h7hT4CHtVOaeBUEvJmEZ0AIIumHeWmg1yXir6eYfYS3i53vdlz2aQUMfadsC5pyJIKfWuKRkP7h9oS8cQPilWJEWhyFltNKiGc6TO+EZS8eEoXd/L9Apc/u5BLLZU2GRR5T3zJ9UVWNdaTJwIpIXDTOh3qs9EBABHKsWiD7cVS0BfYl6JtsocDO/qBZxkxl9d0D27T0CGyeO5Ob9OFmF1oaK55KxV81HwhMtSHqJkIEodyPYf+goxvsHs/muFSVJCibhKA= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Thu, 2024-10-24 at 13:47 -0700, Yosry Ahmed wrote: > On Thu, Oct 24, 2024 at 6:02=E2=80=AFAM Konstantin Kharlamov > wrote: > >=20 > > When ZSWAP is disabled, the `Zswap` and `Zswapped` in meminfo are > > still non-zero. > > IOW, ZSWAP doesn't free memory upon being disabled. > >=20 > > Stumbled upon this while trying to figure out where did =E2=89=884G of = my > > SWAP memory > > disappear. Been seeing some unknown memory in SWAP for years, now I > > suspect ZSWAP > > might be the culprit. But no way to know for sure because of this > > bug. > >=20 > > # Steps to reproduce > >=20 > > 1. Enable ZSWAP > > 2. Wait for `grep Zswap /proc/meminfo` to become non-zero > > 3. Disable ZSWAP via `sudo sh -c "echo 0 > > > /sys/module/zswap/parameters/enabled"` > > 4. Look at `grep Zswap /proc/meminfo` > >=20 > > ## Expected > >=20 > > The rows are zero because ZSWAP is disabled. >=20 > Not really, the expected behavior is that further swapouts will not > go > to zswap, but pages that are already compressed in zswap will not be > written out to the backing swapfile or swapped back to memory. A > swapoff would be required for the latter. >=20 > This is documented in: > https://docs.kernel.org/admin-guide/mm/zswap.html#overview. Oh, I see, thank you, sorry for the noise. Then, I'm curious, is it correct to assume that this `Zswap`-prefixed memory mentioned in meminfo is never the one that is in SWAP? I mean, Zswap being a buffer before data goes to swap kind of implies that yes, the data *either* in zswap or in swap. But just wanted to hear that explicitly. The background to my question is that I'm trying to find the culprit some "phantom memory" eventually filling up my SWAP. This memory is not one accounted to apps (as calculated via `smem`), nor to tmpfs. So my next suspect was something related to ZSwap. >=20