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 A1C49D1039E for ; Sun, 27 Oct 2024 06:47:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7C1F86B0082; Sun, 27 Oct 2024 02:47:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 772CC6B0085; Sun, 27 Oct 2024 02:47:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 639556B0088; Sun, 27 Oct 2024 02:47:25 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 4AA146B0082 for ; Sun, 27 Oct 2024 02:47:25 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id CE753A19ED for ; Sun, 27 Oct 2024 06:46:45 +0000 (UTC) X-FDA: 82718450556.02.7D48D20 Received: from mail-qv1-f54.google.com (mail-qv1-f54.google.com [209.85.219.54]) by imf21.hostedemail.com (Postfix) with ESMTP id 4A0DB1C0008 for ; Sun, 27 Oct 2024 06:46:41 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=jHeVFHEP; spf=pass (imf21.hostedemail.com: domain of yosryahmed@google.com designates 209.85.219.54 as permitted sender) smtp.mailfrom=yosryahmed@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1730011487; 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=vdN1RaSxFld41fK3RlGsXxPxT2DSK8Jl6tKDpSk5DFM=; b=5pyhQgwIAFLe0+IFotg0x5pEmU1WMfRS28hwYmhcPDnN5U2Y/EUWJt+miPrWKuLnUsVlVm PAI/5JLzgswQk3aDvqrgvajf5D6B7tKq2ogkSTnIXh6d6wyNjDfsqGnRjGFPPcJcvaNQCM XSobUK2XjeSZmR0upIL+MdPNWUYjGOk= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1730011487; a=rsa-sha256; cv=none; b=RcHu2XFrKHesaz68QtXXPYzRMthlWkP6PicegUzCgsYcEUhJP5AKQXkDsHuBwOx1y7qeDZ LBcDNx2JzhRucEHrgfCFqRprFCZV5feJKpfWpU5mTH2AnDiKnNnyhVxYMtF3i3RSdsQyZL uGwKGqU7Qwt9MkC6In03OCvBDg6H2Ts= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=jHeVFHEP; spf=pass (imf21.hostedemail.com: domain of yosryahmed@google.com designates 209.85.219.54 as permitted sender) smtp.mailfrom=yosryahmed@google.com; dmarc=pass (policy=reject) header.from=google.com Received: by mail-qv1-f54.google.com with SMTP id 6a1803df08f44-6cbd57cc35bso36564046d6.1 for ; Sat, 26 Oct 2024 23:47:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1730011642; x=1730616442; darn=kvack.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=vdN1RaSxFld41fK3RlGsXxPxT2DSK8Jl6tKDpSk5DFM=; b=jHeVFHEPO1dylrYSm7NeYVSH5afn7BiPakgOZt3c5+soQaZsnE0VtxmJM54TmwWutC OOx2oOipRYYvzJBKIjiz9WnSVCFj59pCihJ/4zu5QFzMX63PbRyZ8z4mqKK5vFkp4aIZ BrcdAQZuzjgzxX2D244t7HO+5gUEngM+nINVsVBnEfx+7FzM9qwtpF4smSJtvK9i//cj G4EQxl5Y28rg/T0SbnkrUHf5I8OKiqkmL4woDSyTUqTXiSeGyJsvmRA/xhqTJCUzR15r DjSBpfuBVXSDkX1GFKP3HWffP3kIR/QV8yDKldRGlB6H/60tXObsQAUTnKrk2iiPEzHa UE4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730011642; x=1730616442; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vdN1RaSxFld41fK3RlGsXxPxT2DSK8Jl6tKDpSk5DFM=; b=ePOs504poWJhqNElXTn1gM5wbuOWDhMp55KhEIR/2sgwG4f75BERsOTO0/2iPtkF9M 1hvJeKokziEwkIOoiPctGPN9YG6zj/jT4cjl8GlNAjHSER34dILBjmZuMu2w2msBhOcq sMGiaQ63eYezOxSTnUvisxldMVpNBxK8TWZ03brtA1pm8J3WsAqznmBpKXRNBxTaRQcf 2VRDvyVqxbNqlhniyWYhXhgXqDa1ViDoj3vU/oQcdRPiWXlo+poDLY0Gc8ZI1u1dBF1w JTRY6sAO95Z0xJj+79DhR/xMTDCgSfana3ATbVxkm9hL0E8DXV7w5Cp3KChnBKyJ/ylJ i/LQ== X-Forwarded-Encrypted: i=1; AJvYcCWXqUrgDUcmsjX5mBKGnMxIKJGxCM9iqZkYrxgpA/qO7DI7MmzVTe4Ex9xUBV9HEWlxLtf153HmSQ==@kvack.org X-Gm-Message-State: AOJu0Yx8tkiNWnE45Z6825y/0r3yh1RmUxZgsQIpW2W8IjdJqgR/E+wn NVi9oeGfrKA/fvlEntlLLdQM/qZUSAHxGnZLskU9mvUplQG+S8KEVLJrO3TvZ3ZLxzbXG5pYVY2 qh4dE2cyoe3to7Ud0xuYl5jiZi1dfz9FwwGJa X-Google-Smtp-Source: AGHT+IE3QhSPviV6vHCPdvojnT37Y93JPl2M2d3GmoBVOPxiY0+Jy00zA9glBWDcq4GumPmZOjzBxSOPQVHinpEq66s= X-Received: by 2002:a05:6214:2f88:b0:6cc:44b:105a with SMTP id 6a1803df08f44-6d1854e29fbmr81994596d6.20.1730011641866; Sat, 26 Oct 2024 23:47:21 -0700 (PDT) MIME-Version: 1.0 References: <7d873b2682a7513a4d5aad5ac09f5c78851efbb6.camel@yandex.ru> <28352fb75268060f2e78a32325f02e46737a16ea.camel@yandex.ru> In-Reply-To: From: Yosry Ahmed Date: Sat, 26 Oct 2024 23:46:45 -0700 Message-ID: Subject: Re: [BUG] ZSwap leaks memory upon being disabled To: Nhat Pham Cc: Konstantin Kharlamov , linux-mm@kvack.org, Johannes Weiner , Chengming Zhou Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: 4A0DB1C0008 X-Stat-Signature: ir9s7wh818ojx19n73c4np6iqau5f8ri X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1730011601-373379 X-HE-Meta: U2FsdGVkX1/GqoCPdNYCif+jLA4NsvAku7pnjan8OdI20rZTyst7ZhVx3IANytc5qCHmmAJ8Nagi4zFVhcjy/z0ezbTXIjw4uo6VKwg5eDP9ckC02sxDpDQZHctPLuPNVz9+xymWEYU07XdzUqD2DabnXeLOjR3k5digZwMRRTk0KdTR9cLfHrhPY4JlkigV3PaPL/YMZ5n8IS9/zXr42FtCUx/ljxv9a+QqLI545nayUHg++byK2NIuSy8JdJ7ju9zGLXXmYZH3AUMCDRrDthh+jedO4OmpQzUIavrr1CRZ/rRd636Yml+uEq8W3/9elUNWLyQpMV41danEmcNbXCamTFNjp7El4r6UrZyK5Axp2kO9h5/IE9n52mEU2EujLlDVDHCEdH5P7PdBrePf17YsBcfL4yGIwcbZFvJ5cV5uFuImC3wejur89kZGEYyxtVc7fgeSsM/ovmn8wGgUA0zwQJrpjv2ybE0gF8XZ30Kf9AcyAWTokIyPG/ArxdPGrkwQAlkWSxbeb3TuYKkYHIt252a0Dp+ARCZL3j74IYZbIiPVem3DYRYV9MhqRx9dHyg8BFAIrgroTtKuwWaekms1PPyc+vCEJRSG5fSgoqBBoCdKqgBziEGvcpSXbqut53xVC68jJOsO9R1hjZD8OTHVcpdk+UC0Kva6L7sAEEJ+KF41zWMlL/il8SbYoi73T0mcQXBB+jeEg3RdHk8n3VqEkm47isO0QJcnMyMsWJ27nqGR8GFxxAYxdRAwnuyLP3pIwghB35XvF02iNrw8pMhtLksSgwVTfkVGgx0dG6xbITVpSVEiryHhJ61+EjreGACqAwXqA0FzbtvfJ/ApWS7suCNJnQPVhMoosuhpUa7Ox7tqW0OBVi1+QLwVp1vh0whjtYO1/zf4timTcTVqMx+/Ha5RHL1+g6eZrJix4g2Hc7ppvfDiK7mXjqeG0EQvyYRuIfV0OYiyDuzBmZU Hnex69hi hIyGD9cq0Sn0abaldrmy3yQGd14hdFsbTVTzyizdGrfc7kfjsQsb5QFK3GGFerxBBzN5nDm60kU47qX6fiP4DS5dLPQKvp2fkaRe0OBfRco6aEzW3afbLlGI12nsJyFQ0izOMtgl4p+1mn1skyo2qVThg4dSXNtombOjz3CcWrhEMQhgGnBLaSsOBP5woyMmpNhCMY+EBHMFESa+s0bRf4nRZ1Qa4W48p4SjuBcGmmgBRA24= X-Bogosity: Ham, tests=bogofilter, spamicity=0.072315, 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 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?