From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ot1-f49.google.com (mail-ot1-f49.google.com [209.85.210.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 28E273A256B for ; Fri, 13 Mar 2026 15:34:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773416078; cv=none; b=RyM6rW3A3J0LAi5mwQiZad+wTrDRdMF8B/FpCkQh4kxnQrnjmdZhsBKSlIlkW7zy/yU+wbrz5oWUYTMV7vJK4c4m0xIk8gP16BHbHyZtFAClk7Vihfmuyl9PFwPQj96w8QiURtEPLgdGu31PCEY7M2QIK7kVQ7wiTGYBtma8RhQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773416078; c=relaxed/simple; bh=DJCs/BOdnBM2SbzqKJU+FiU7MEO4v/zuHQo/67Ie+G8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jK4Ky1K6o5UCzZ2jHzRK4tuntD0LmJSRzldu+O+cLyF+LrkuB+u43hv3DeWg6J8zodq1MaObOZ4unZlFZpw9hUIMH6pOHocD/wvAR36Q1roaCLvJDNW3/eIGCr7vTzSug9OPy94gvNmUak83zyHH7jV2tWWVYnPqUemThzYe29I= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=hoJpjjgu; arc=none smtp.client-ip=209.85.210.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="hoJpjjgu" Received: by mail-ot1-f49.google.com with SMTP id 46e09a7af769-7d74dbfe84cso1592724a34.1 for ; Fri, 13 Mar 2026 08:34:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1773416076; x=1774020876; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=qxJi/zSl5l+Hb0RVk/iR14eLBTshpKrTciXowhZG1gg=; b=hoJpjjguZz8KgXSUf/mxLm0fqcz/39ocyGNN7Qyk2ojB4Nrusoy5qsU9JY3DWvmd05 fKkOoGyGr8ueRb9kn0NQl6DameyvVTlreL5QwzDihVINUF3s61Lks+M493A8x6qZ8Usm 9cuHd8LQ9kXF7mkHNxqJOePPQxYBLIrzA3RACxgAzUAyJWmWsLsW0VcpKy+DmNhXZ6v5 mdXnQnZXYYhKlc9kSofu6jbhu+cVeHl6XT6inqE4pUQE41FbW84BWUq6ozOaLxXIEFxB rV+x2q8LfhROWQ8ZCeAFhrDqQ3dQP4dp5w3ry8JNCkRaR1Ra4IMCalMjZ1ehr+PMvP+x bthQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773416076; x=1774020876; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=qxJi/zSl5l+Hb0RVk/iR14eLBTshpKrTciXowhZG1gg=; b=mrLjkHqq19rjvt4PcH/GmL5RyWNTsH2+byPJFKQwffZQGb7tBQ2SlsbjyMHjXib3jy RFWkItEtLKg/3TJM8NQgebbOYsmfC9+Sfa9BTgiNXi+89Eu4CoqFM7R5Xb/kGDNjVojI 6PyWRgEouoMGeoFwfeEizPcCaFgPWH2kmk69nVOf7Ay1G8XkySzWYUhnwdiR6vDQ62jh HlOmI4VtNVqjrvNXMagA0O7V9GM2RoxZlFIGd97J9eFRLXeuJWJbHx2p9oEkeqP/5TfA XLDnrG1KhHEJuORJh+knyVNJbkly2GJ4jk2//17GmzG6vUuLjUrwfOlGeJwWnqwcBozw 9n8A== X-Forwarded-Encrypted: i=1; AJvYcCVrqPvyAiEa+qvWS4k2PYEE29Qj9XRV8H61ZsgKCH8qo8gK7hcPdz+Fyzkm1260ah6S6L2tU5ioent1sBw=@vger.kernel.org X-Gm-Message-State: AOJu0Yxzt1PGGrAim4t87eJWxtB9aJXAIJbhE4iflS+kBEPwB/sPhw4E wRAxEuY8LmWS0BvGlM06Ogd0nyl8pmp/CfpUfSm7EREDOCb5k7qYxouT X-Gm-Gg: ATEYQzy/6PP7DJ9iQ08s0mi9PpsKtandZ/+Fj6RpYgmHjKPu/x2rthS3XsZb2kDmRgB +DW3Y/uLgNevWb6c9rZEajL9x81qgAfQJhPFysonpsDeZWRsf/UdTGiD/qSnuXZDDCa6Ht585ES BpWE5QTp1m+xL8Nh/dTFAk3f8hSxVcLGlkjrO72b58drvKzfh+uYvrilytI79uwT6o6f8hh17TA gw38FD3qsx6Rn1hBfiNpGTC/zj6KPTaY4gQAG/A8l68h2MnkWogggiIY2TKumeFtUXPkWHP7WRx Z6c7z/igjo55FAf0JPiYPirMfFakIBv3g5TrSCitmcCq8Y11hl8egqfcaLSJ39tgtj3eb0DPuA3 fqdFr+nmgSVrDjG/nfzIXnU50i8AqWrZzAefl6bD9Hq/IIEtzFeoXTjCNSJxH1NYqH5KSeT/Y/O MaUGD+zU1SXJQ+UnG9+JpU9Q== X-Received: by 2002:a05:6830:6a11:b0:7d7:5d69:819d with SMTP id 46e09a7af769-7d782619ed7mr2747874a34.34.1773416075930; Fri, 13 Mar 2026 08:34:35 -0700 (PDT) Received: from localhost ([2a03:2880:10ff:5a::]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-7d76ae90586sm7005201a34.22.2026.03.13.08.34.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Mar 2026 08:34:35 -0700 (PDT) From: Joshua Hahn To: Johannes Weiner Cc: Minchan Kim , Sergey Senozhatsky , Yosry Ahmed , Nhat Pham , Nhat Pham , Chengming Zhou , Michal Hocko , Roman Gushchin , Shakeel Butt , Muchun Song , Andrew Morton , cgroups@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-team@meta.com Subject: Re: [PATCH 07/11] mm/zsmalloc, zswap: Handle objcg charging and lifetime in zsmalloc Date: Fri, 13 Mar 2026 08:34:33 -0700 Message-ID: <20260313153434.4074128-1-joshua.hahnjy@gmail.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit On Thu, 12 Mar 2026 17:42:01 -0400 Johannes Weiner wrote: > On Wed, Mar 11, 2026 at 12:51:44PM -0700, Joshua Hahn wrote: > > @@ -1244,6 +1297,8 @@ void zs_obj_write(struct zs_pool *pool, unsigned long handle, > > if (objcg) { > > WARN_ON_ONCE(!pool->memcg_aware); > > zspage->objcgs[obj_idx] = objcg; > > + obj_cgroup_get(objcg); > > + zs_charge_objcg(pool, objcg, class->size); > > } > > > > if (!ZsHugePage(zspage)) Hello Johannes, thank you for your review! > Note that the obj_cgroup_get() reference is for the pointer, not the > charge. I think it all comes out right in the end, but it's a bit > confusing to follow and verify through the series. Thank you for pointing that out. I'll try to make it more explicit via the placement. > IOW, it's better move that obj_cgroup_get() when you add and store > zspage->objcgs[]. If zswap stil has a reference at that point in the > series, then it's fine for there to be two separate obj_cgroup_get() > as well, with later patches deleting the zswap one when its > entry->objcg pointer disappears. Sounds good with me. Maybe for the code block above I just move it one line up so that it happens before the zspage->objcgs set and make it more obvious that it's associated with setting the objcg pointer and not with the charge? And for the freeing section, putting after we set the pointer to NULL could be more obvious? > > @@ -711,10 +711,6 @@ static void zswap_entry_free(struct zswap_entry *entry) > > zswap_lru_del(&zswap_list_lru, entry, objcg); > > zs_free(entry->pool->zs_pool, entry->handle); > > zswap_pool_put(entry->pool); > > - if (objcg) { > > - obj_cgroup_uncharge_zswap(objcg, entry->length); > > - obj_cgroup_put(objcg); > > - } > > if (entry->length == PAGE_SIZE) > > atomic_long_dec(&zswap_stored_incompressible_pages); > > zswap_entry_cache_free(entry); > > [ I can see that this was misleading. It was really getting a > reference for the entry->objcg = objcg a few lines down, hitching a > ride on that existing `if (objcg)`. ] Thank you for the clarification! I hope you have a great day : -) Joshua