From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qk1-f173.google.com (mail-qk1-f173.google.com [209.85.222.173]) (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 CDC603EF66B for ; Thu, 12 Mar 2026 21:42:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773351730; cv=none; b=gM1GqFsFwKfQlJ/AOQigcdPOZL2bSvq99Q3IGhQXnRJPDFbWPK7J5F/8Fhfl+JDcRmVELc0jghq1WvAO3xd5Epbhkd3TvYuvCqJ+odbkyNLHpR121iZEp+uauOZuNmhb2BgDqWLldMHKUj0vrvLeVv8Qzpy7qNsREhWH5OAeA+s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773351730; c=relaxed/simple; bh=sgwa46VwlJ5NW0Quir1JmdvJvZe9OmJMk+cKe/4nCDw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=XGupGrCc9BXdlhQUWTZ1HTgW48X0zJykIwB1GSrURvRgS+ylriSxjHUkPpS+MVyGyO/O99eONM80uR36QmBQ7HmtLnUSmsiWV+1pve4vtkT6/SK0CU57bGzhXIk5Mujk+kKZeqepkdSVDTo2dY9K5q3/ZXbza29oIEkR5jvtF8Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=cmpxchg.org; spf=pass smtp.mailfrom=cmpxchg.org; dkim=pass (2048-bit key) header.d=cmpxchg.org header.i=@cmpxchg.org header.b=pa+XaN5Y; arc=none smtp.client-ip=209.85.222.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=cmpxchg.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cmpxchg.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=cmpxchg.org header.i=@cmpxchg.org header.b="pa+XaN5Y" Received: by mail-qk1-f173.google.com with SMTP id af79cd13be357-8cb40149037so165545285a.2 for ; Thu, 12 Mar 2026 14:42:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg.org; s=google; t=1773351726; x=1773956526; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=LyceMyfiqLdgt3XmH3cZvfSKhUu32FwkvwXjXF/XZck=; b=pa+XaN5YpMZg8SBNN1OhPtVFuFPTUOQnGYNjSWQX3Zr/YS3Mi5Tfc9Tw+H1/ZwFavf WlVxtqlNMVOSkzW6F4cJa34JrNrVd6rvEOJO8CRSqToEOusuIfTsHMtP3PmJub4wy5kU 7ki2JXCOquEfZjKt09t3NPKYFyFcGQhBpDu9lXBXZG1WSETT6FcDy4heyBx+GwuJOJV6 B2NFF4OieoRW1NlDSJgjG+52mbrFttzQrnDibirbclC1bTZABALTVX8u1SuLPBEmdtdI 384joc/3FV/Z9up9YG2u9AVwuLGTzRXQ7xdCA5mO3Y7IM6ukdjxyWfmmS1aIon9Cg5oy FM4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1773351726; x=1773956526; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LyceMyfiqLdgt3XmH3cZvfSKhUu32FwkvwXjXF/XZck=; b=jFibon2xE5xZGO7FXRqbaXH0ClwYPe8tBdk+d7nJQ+QKytBAg1ErdAEfHtCfDZQlKf 7tyO2aNHrOiok2Xtq7IIEsavbQVRDLqXXj43Vi0MuJRExnEXFUp4nkbBXKxYo1FoL+Gz Tjg7rYsc6DMXNt9XPihG2o7Hdmjukf8MFXVvcto9wlYkd3GyYLh1o0MOCTtiDu2Sam8h VmvZkz5GNYu5NXrtRYgLoMEYcyaX9ynGCgauVTm8B0K2ACQzUAgTJe5KTNkntsck6npu i1LjHO3s8epoV44Rj+yuh0x+o7bDwlIJc6PR6zj2XsDkYLOw00cCD48YoM+PDWIdV76H fp9g== X-Forwarded-Encrypted: i=1; AJvYcCU18GRjqzVayeC39x+VZTH9BHIlgHXYjLzlReeYq6GQPCLAsincNRU6hSU58SyyzkStEQx7G1eKtcFVFq4=@vger.kernel.org X-Gm-Message-State: AOJu0Ywzxwkn9Jzg7Y/dRfJbCZa4RTfx31Bme5Robur2sYTiQzX9RdiA MyyFdk7PeT609IedHPBos90/A8itiOtDWFMZK3VrdcxkA/zhRjQDWmfUa2Wf4u0FovU= X-Gm-Gg: ATEYQzy7H3vjscYsBCRe/CylcneqP3gC9yh/uZws739C3EZMk6BAORzaur4Ue+8Aje7 mziEvSYJgq7PN8cvfjN/URzOIMP7ehIdf/wi6alqQveiHe5xY1t0J0fhOHZVFUrZD5q4VONtaU0 Wj9G8Ul8Jnaamd9jneSQgzEQ9lSQN8+2AYkLCv4zVciKB4S43e9az5GPLt/WU3uyr8A2lcX8nBj B+6i3c4onOIa/akzeKwshdc6XELPPBqHYes3Du+EWPh8if7PW6QwSjjEUpifqU4qGlFWQrHRm8K Yf5e2qNFvVMYsdwOesk5ilRjBWvdPmjyj+9cacyOaw9205ody4qc4yAh7syL7wPd7161GY3rlhu Y8I0Aq8JJsFzws+k0+BitllO1LjjW2vzF0PmhePBlnGcq7H6p8g6W5n576NUr3L82BZ+1Td6fXQ 3SDpJ5ndl4u0JQ/+kU6/qryA== X-Received: by 2002:a05:620a:269a:b0:8cd:9b31:23b1 with SMTP id af79cd13be357-8cdb5b1b1ebmr170750085a.53.1773351726619; Thu, 12 Mar 2026 14:42:06 -0700 (PDT) Received: from localhost ([2603:7000:c00:3a00:365a:60ff:fe62:ff29]) by smtp.gmail.com with ESMTPSA id af79cd13be357-8cda2151db2sm404907185a.44.2026.03.12.14.42.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Mar 2026 14:42:05 -0700 (PDT) Date: Thu, 12 Mar 2026 17:42:01 -0400 From: Johannes Weiner To: Joshua Hahn 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 Message-ID: References: <20260311195153.4013476-1-joshua.hahnjy@gmail.com> <20260311195153.4013476-8-joshua.hahnjy@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260311195153.4013476-8-joshua.hahnjy@gmail.com> 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)) 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. 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. > @@ -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)`. ]