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 4923ED10C16 for ; Sun, 27 Oct 2024 10:32:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D21E56B0082; Sun, 27 Oct 2024 06:32:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CAA906B0085; Sun, 27 Oct 2024 06:32:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B4B226B0088; Sun, 27 Oct 2024 06:32:24 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 92B8B6B0082 for ; Sun, 27 Oct 2024 06:32:24 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 411291619A2 for ; Sun, 27 Oct 2024 10:31:59 +0000 (UTC) X-FDA: 82719017346.04.321FF9A Received: from forward501a.mail.yandex.net (forward501a.mail.yandex.net [178.154.239.81]) by imf09.hostedemail.com (Postfix) with ESMTP id 613B7140007 for ; Sun, 27 Oct 2024 10:32:06 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=yandex.ru header.s=mail header.b=AE6j+aUp; spf=pass (imf09.hostedemail.com: domain of Hi-Angel@yandex.ru designates 178.154.239.81 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=1730024985; 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=f8wKVyw7s1+aUPhmnsGKtDuHcb2iSAaBcliY9w+RjOc=; b=c4CxVEUZa2kY4g3INSV+MFm9BhaOep+7ke2uz7FT3IhylcfNOE5YQtgadVxCeDLAnWD69Z E8lifMFylkXRAy6ustrOu7nj+ntl5eosCT45EUoBwiRx/WP5ODPqLO8tUbs4oqmIoZfkXH j5VLcj7KXS01m38lVAlF5x9SIhubv7M= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1730024985; a=rsa-sha256; cv=none; b=kEHFRZnyYiJ4Apc8RWE75iX6xKOHvS4J09XOrrmu8tEmAl2njYCSSpyibTCp9SShTo2XH4 cLiofKjA4i0wffiRZI5ZTXpcdksY7293FyeQV4d0n38k0z9xAUrhbhdRhz09l/zJqwQJj7 rwN7J0Ka8Dzx7Y59gETxvdidb/LFLWg= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=yandex.ru header.s=mail header.b=AE6j+aUp; spf=pass (imf09.hostedemail.com: domain of Hi-Angel@yandex.ru designates 178.154.239.81 as permitted sender) smtp.mailfrom=Hi-Angel@yandex.ru; dmarc=pass (policy=none) header.from=yandex.ru Received: from mail-nwsmtp-smtp-production-main-39.vla.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-39.vla.yp-c.yandex.net [IPv6:2a02:6b8:c15:2b05:0:640:2a62:0]) by forward501a.mail.yandex.net (Yandex) with ESMTPS id 140EE60FD7; Sun, 27 Oct 2024 13:32:19 +0300 (MSK) Received: by mail-nwsmtp-smtp-production-main-39.vla.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id HWUEQ2bXlW20-wyupsVu1; Sun, 27 Oct 2024 13:32:18 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1730025138; bh=f8wKVyw7s1+aUPhmnsGKtDuHcb2iSAaBcliY9w+RjOc=; h=References:Date:In-Reply-To:Cc:To:From:Subject:Message-ID; b=AE6j+aUpuMgQtmgaCHwYNmNpSVPFKxuTovgB5YAArSak4TIjVT9YgDroFlecYmV79 zixRPstv4Uz7wUkPLHMfp3OlQmwrsT7hbONPyomOJOSjMyiVKKFiY/cxUnjLUPpbVU CYIUHGhYgkYcDbM06co1mALZtexudQ58H/TwBUe4= Message-ID: Subject: Re: [BUG] ZSwap leaks memory upon being disabled From: Konstantin Kharlamov To: Yosry Ahmed , Nhat Pham Cc: linux-mm@kvack.org, Johannes Weiner , Chengming Zhou Date: Sun, 27 Oct 2024 13:32:17 +0300 In-Reply-To: <656f9dad3edba22b3b8ae16b97050d3f189ff1dc.camel@yandex.ru> References: <7d873b2682a7513a4d5aad5ac09f5c78851efbb6.camel@yandex.ru> <28352fb75268060f2e78a32325f02e46737a16ea.camel@yandex.ru> <656f9dad3edba22b3b8ae16b97050d3f189ff1dc.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-Stat-Signature: d478663z96nm5ts5accfnac7zzzt8no9 X-Rspamd-Queue-Id: 613B7140007 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1730025126-600000 X-HE-Meta: U2FsdGVkX19Au61tm6HmpTcs+kCAmB+ENuGOsBLHQjoZQWIkp1OKIlccLi/3NuUFeH05aay7TCYgx58Iu0G86E1tVcTznjieWv0T46Bb8DujdymyFB/7TvFPmE8dflgczKW4jo+RX99bA1frRCceOIoil2CZJGIAvqjS+isYBc/4hAzWa4gHAUOTShlZSG4+OjJXueQ3JHpe2A1fWIJtqGLpIPagJfWKko9FFtRLm3JU1RovrXwLgo2/ON5BhyNG0A3AQsnAQZ0asllrPiCQPOEYxAZ2tZ3rXb5iEoiUqhb33e5PdX9+INtthKOVvB+Ru0ul2pFaX6uYDaAFAZyZrg35dyvvchQvNCiSwyJ4v4aad+PC0dGz53Iv/TXdsS+bV9Qz2C52i6rBH8lEer1oVDi8gY3LkqKnNg1/rY/junLjXRdMzkDnA02ANANia4EFxVXNFGKiBhVmzjU832uIZrDMQBzd8o/ot/bFdd1P9zWlktvlxWQ32U+li+rqQsItOCW3A9DJkqYOi88rMWGwbLij5EULBRVPxNJWx4V62eHJTzaCGoZ4d9kjborg9RSGn1APY6BRx6QiV+naRxZqhAO6WD4LAOQGqj050orFlq2qXayfQxmQXKKcIZZZNWnI1XCN4zHPnNW5LLTkoOsL6JIGVwVK3bZBtM/wVCJdQGuzlQCBVu2+PhERsPs8AoZOm5ytVxUFpFgG/xKGzS9RCQAJtw1JX8AsKtvAfD4JUPLXB8K07GamHks+9uTYkdf4t/CQipqNB+M2GOzIuzQbQ4mm1DblfKe3/XotRq0zVYhzTFwdAnkbJ1SlVNC32NTXtCy8Z0U7QUMNFbu8aoJwdA3yUDWz3F0PXhp8YXtfcFKFIpPS+lAMMOgvsve++UVuImdrqAyAWn1cltS36TlxpdKtP7m5Mrg7n/v80t3Emrv0v8ITszTpbHEPof3xG7a71mPNNtwiw1/C7PZ50u7 7R0O61aJ qQrMonbw/jWUP2rjkUl0eyEsjxSydO/aGEuXP/Pwlr9ZWDjbXRr1qITb+dokxOguwnVxMFpz8ShWvO86RAc0eA+c6LtEAV53GVltaCaSEq6BtvPRde2JNHuio4XH20w9jpJPxaJ6Pz+UGC37sqAzmN57Vb/YhMP+IuXlYq0H0fLLL/oWUPI3iVxA0DoAhggp1iLWo+BP3kIiL8NasGnWt0JkWKX/KsqKXlheeVSWCNWjtFm+MEqzv2YSvap7IFWKvp4UN1p8mJHDaskoFiXt8GgGPB/RIyJrfF4wFtHW2ZXcONnwjLHg7EEz/j0RRjsNMwC8ZC45gOO4t/fjDBLXk5cJ7N2cjnfEmI5uM8HnJ1ZsqY+1qEK32bvNlxw== X-Bogosity: Ham, tests=bogofilter, spamicity=0.021880, 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 Sun, 2024-10-27 at 13:11 +0300, Konstantin Kharlamov wrote: > On Sat, 2024-10-26 at 23:46 -0700, Yosry Ahmed wrote: > > On Sat, Oct 26, 2024 at 8:14=E2=80=AFPM Nhat Pham > > wrote: > > > > > > On Sat, Oct 26, 2024 at 5:29=E2=80=AFPM Konstantin Kharlamov > > > wrote: > > > > > > > > That was a good idea! The > > > > `/sys/fs/cgroup/system.slice/memory.swap.current` seems to have > > > > the > > > > missing half of the SWAP memory. From my understanding of the > > > > `systemctl status` graph `sytem.slice` and `user.slice` groups > > > > do > > > > not > > > > intersect, and by adding up `system.slice/=E2=80=A6` + `user.slice/= =E2=80=A6` I > > > > get > > > > around 8G. > > > > > > > > However, I'm still unclear what does this memory belong to. > > > > `system.slice/memory.swap.current` is 4.4G currently, that's a > > > > lot and > > > > I'm not seeing anything that could take so much memory. > > > > I am not very familiar with what usually runs in system.slice. > > > > > > > > I assume you do not have any proactive memory reclaimer? :) I > > > believe > > > the top utility can display swap usage by process. Have you tried > > > that? > > > > > > There are a couple of edge cases - for instance, if you disable > > > zswap > > > writeback and zswap at the same time. We will allocate slots on > > > swapfile, and store it at the page table entry, but we cannot > > > store > > > the page's content in zswap or the swapfile, so the page remains > > > in > > > memory. You're occupying swap space, but are not really saving > > > any > > > memory usage. > > > > > > IIRC, there is also an edge case where a page is faulted back > > > into > > > memory from swap, but the associated swap space cannot be > > > immediately > > > released. This should be temporary though - memory reclaimer will > > > attempt to release these pages later on, or they can be released > > > when > > > we scan the swapfile for slots during swap out. > > > > I don't think this is an edge case. I think when we swapin a page > > we > > generally leave it in the swapcache if there is no pressure on swap > > space. In that case the memory is not really swapped out, but > > because > > it remains in the swapcache it is still reserving a swap slot, so > > it > > shows up as swap usage. > > > > Konstantin, could you check the amount of swapcache you have, > > whether > > through /proc/vmstat or memory.stat on both user and system slices? > > Sure > > =CE=BB grep cache /sys/fs/cgroup/*/memory.stat > =E2=80=A6 > /sys/fs/cgroup/system.slice/memory.stat:swapcached 434917376 > /sys/fs/cgroup/user.slice/memory.stat:swapcached 15478784 > > `434917376` is a 0.4G, not much. In comparison, > `system.slice/memory.swap.current` is currently `4764139520 =3D 4.4G`. I figured since 434917376 is 10 numbers, I'd grep everything in memory.stat that has ten digits: =CE=BB grep -P "\d{10}$" /sys/fs/cgroup/system.slice/memory.stat file 2671874048 shmem 2592768000 zswapped 2997760000 active_anon 1491247104 unevictable 1269555200 well, to me personally this isn't helpful, but perhaps am I missing something=E2=80=A6