From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qk1-f181.google.com (mail-qk1-f181.google.com [209.85.222.181]) (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 71EE140B0FD for ; Mon, 3 Aug 2026 15:05:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.181 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785769505; cv=none; b=AFzbbWIrqwEUteaQXRj/+xsnkSObAPo45HLg6TpOtTUgjbkH6GSKbqiYmCBolBlk4ovwaT3GTMGZPcGqF9Kp2V9b7K/zukoNgM8htuDayuw8gk4gA12LFRp3YKpWKtXhqdRNfzWXPGM9UDeUcdX7xh5qbqm00ca3x90w2hvzkCM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785769505; c=relaxed/simple; bh=60RfMnIwzonkPIiT+bhYp4Dmik2Ru9P35TnztzhJhTM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Eg+RwNlr/s6917ZmPA1/OH1gMvNJ8SXLWilUbJp+XtxTjeFQFcTbsZzSmm3nf/Vi+D9R11vGWMUpXnKAxkaSeqEVj/hQdV5WW7uwKapeuXHNoxG4HpO7UVbiIB5UUNwAejWtjL7FMsLNTQOC2ZVN9PTuXCd15qSDjoTvcZuVd9o= 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=nu8yfbJ0; arc=none smtp.client-ip=209.85.222.181 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="nu8yfbJ0" Received: by mail-qk1-f181.google.com with SMTP id af79cd13be357-92e50979c71so308284285a.3 for ; Mon, 03 Aug 2026 08:05:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg.org; s=google; t=1785769502; x=1786374302; darn=vger.kernel.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=InaA9nphc+gU/P+HAgEZidewKrxFbc6zJkV9A2LJFs8=; b=nu8yfbJ0P0XCOXPc8WLXais3QR4J1xOMBwV61XH+M3eWPabTHu8DYnSghdXnD8JKy7 JLbUE4j8G5pbeCD9f3iFbKr2KZZOMoQ3/ugH25m5ZdLlsw6ZF1VIVbWBFV4SzvS0yErp 1ujfUBQyAmm2nI8kHtv/pIbuT/PM8LCwjGvyA/20KnIUPKzoMxQhPRqEg8f9PdWe2TLI 6jlyQUCcgnYwC1jxr1HmHoDbS1sZXal485OaPnvHRZxX73UW0V5o2k/K8n/It7zYuHSX sGGoU2FHP2C0lF+TGJEJ2Uajme9HtKkwTxLvt5cRsT5bULp4877wQcVKQj6Qq63RTTln qtdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785769502; x=1786374302; h=in-reply-to:content-disposition:content-type: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 :content-type; bh=InaA9nphc+gU/P+HAgEZidewKrxFbc6zJkV9A2LJFs8=; b=ih6Ik5WvW+KNXjCLabASKRJk61EuiXgHevn1whVjusLgNDwS0nMSmKfnQMZ9CCKOcO 7962mWn9Zf7SMmXIrna0waUuoHvTndKqkPsVC1MTmY4Qrm/Vvd9GldvBooPfhByjR3zY UD1AQKurvD/tWOHPA6VnxnBlGHV6oOSXMyLriTN7hOoYKkCwszJylFoxS1vWXH080a/z 65aPTFT1rPAHYZr53LNdQpBvBnG0VApCjm6xFQW8D7wT1u+G1+dHwlBWDnbf0gqkx0/V N/ZxJpbldxx81EbYrNiS9ehfpte1MYrCQf48q5RoxwfPb0L6t8Vtts5P02QZ4NZuZnk2 QTqQ== X-Forwarded-Encrypted: i=1; AHgh+RoG2hv/ReYHMDgss3Z8IL85AMKVcn954lsOJMzTG8wJUxOzDRHtTrgdAJwKinLOmTZvkMvEu0h+nP/QQHc=@vger.kernel.org X-Gm-Message-State: AOJu0Ywg51DkjRKrsDphAnI+JsaJcQ6LzssrQ5/ND0yvj7utZNjYfQ1d p0eaXDblc1fNH+Mwp/6hvUD8NOspx7ddvFtdTi650qTEeobVSE1K7IgnWthvO8wV5tc= X-Gm-Gg: AR+sD11aWbrkRnNDbFhkjyAFHvtaavVLO+J6F/GzoX0Xf8cPRy5TrRdVnZSEsG/VZNz oGjqdpsFhsEDngzDqY+s8cAHGK1DlSyInZ5PV+8S24dhe3OzCi3+E+xziK29j2O3hjrqJrfpkAj L+PcxtyRWjqCL3VITKMeIqXDRTYoeP/wkNaZnCYd9zAY7Enu3syGEbFss7Kd33E+HA1XqMprXAB DcptT1BR6Rvk20JjTuAqxr54A5Gu97UNSyW5aFuVxeTpq48BPCVEzMdoU9WxVGcecDT/dxz/d/l 1N1jXg505gch6GxKiIVuKlBx6oLXWCjvyP/Wi3BOB1Roy3DN1DF5Cri3scyOL66NxBZTLsr2qdz CHwLaGBV1qFsnfPhTOJIpvmErIhUl4RP3Dey02gjsGhVg2wve2OLO+KwaBlQMfYKqWjDzptKogM /N2Ut2xmAKmuqP5vMJa9mtCxxoPqyMaqKvMjakpMPbMVcm6nODabHb2dpfNYE= X-Received: by 2002:a05:620a:4725:b0:934:aa05:f590 with SMTP id af79cd13be357-934aa060270mr1387660685a.43.1785769501831; Mon, 03 Aug 2026 08:05:01 -0700 (PDT) Received: from localhost ([2603:7001:f100:500:365a:60ff:fe62:ff29]) by smtp.gmail.com with ESMTPSA id af79cd13be357-9349bc25593sm681081085a.6.2026.08.03.08.05.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Aug 2026 08:05:01 -0700 (PDT) Date: Mon, 3 Aug 2026 11:04:57 -0400 From: Johannes Weiner To: Zi Yan Cc: David Hildenbrand , "Matthew Wilcox (Oracle)" , Andrew Morton , Muchun Song , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Baolin Wang , Nico Pache , Ryan Roberts , Dev Jain , Barry Song , Lance Yang , Usama Arif , Gregory Price , Ying Huang , Alistair Popple , Qi Zheng , Shakeel Butt , Kairui Song , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Minchan Kim , Sergey Senozhatsky Subject: Re: [PATCH RFC 01/14] mm/zsmalloc: replace PG_private with pointer comparison Message-ID: References: <20260731-remove-pg_private-v1-0-142c97ba3562@nvidia.com> <20260731-remove-pg_private-v1-1-142c97ba3562@nvidia.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: <20260731-remove-pg_private-v1-1-142c97ba3562@nvidia.com> On Fri, Jul 31, 2026 at 10:13:24PM -0400, Zi Yan wrote: > zsmalloc uses PG_private to indicate first zpdesc in the zspage chain. > Replace it with zpdesc->zspage->first_zpdesc == zpdesc. The check, > is_first_zpdesc(), is only used in VM_BUG_ON(), so performance impact > should be negligible. > > It prepares for a future commit that remove PG_private. > > No functional change intended. > > Assisted-by: Claude:claude-opus-4-8 > Assisted-by: Codex:gpt-5 > Signed-off-by: Zi Yan > To: Minchan Kim > To: Sergey Senozhatsky > To: Andrew Morton > Cc: linux-mm@kvack.org > Cc: linux-kernel@vger.kernel.org > --- > mm/zpdesc.h | 2 +- > mm/zsmalloc.c | 15 +++------------ > 2 files changed, 4 insertions(+), 13 deletions(-) > > diff --git a/mm/zpdesc.h b/mm/zpdesc.h > index b8258dc78548d..4fd81c2e80769 100644 > --- a/mm/zpdesc.h > +++ b/mm/zpdesc.h > @@ -26,8 +26,8 @@ > * with memcg_data. > * > * Page flags used: > - * * PG_private identifies the first component page. > * * PG_locked is used by page migration code. > + * The first component page has zpdesc->zspage->first_zpdesc == zpdesc > */ > struct zpdesc { > unsigned long flags; > diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c > index 8204b76f78308..e8ef227624efa 100644 > --- a/mm/zsmalloc.c > +++ b/mm/zsmalloc.c > @@ -290,11 +290,6 @@ struct zs_pool { > atomic_t compaction_in_progress; > }; > > -static inline void zpdesc_set_first(struct zpdesc *zpdesc) > -{ > - SetPagePrivate(zpdesc_page(zpdesc)); > -} > - > static inline void zpdesc_inc_zone_page_state(struct zpdesc *zpdesc) > { > inc_zone_page_state(zpdesc_page(zpdesc), NR_ZSPAGES); > @@ -478,7 +473,7 @@ static void record_obj(unsigned long handle, unsigned long obj) > > static inline bool __maybe_unused is_first_zpdesc(struct zpdesc *zpdesc) > { > - return PagePrivate(zpdesc_page(zpdesc)); > + return zpdesc->zspage->first_zpdesc == zpdesc; > } There are two checks: get_first_zpdesc() and obj_allocated(). static struct zpdesc *get_first_zpdesc(struct zspage *zspage) { struct zpdesc *first_zpdesc = zspage->first_zpdesc; VM_BUG_ON_PAGE(is_first_zpdesc(first_zpdesc), zpdesc_page(first_zpdesc)); return first_zpdesc; } If you expand the helper, this seems kind of pointless now: first_zpdesc = zspage->first_zpdesc; VM_BUG_ON_PAGE(first_zpdesc != first_zpdesc->zspage->first_zpdesc, ...); Mayyybe it could make sense to assert first_zpdesc->zspage != zspage. But that's a separate issue that the previous check didn't necessarily catch. And might not be worth checking, considering how trivial create_page_chain() is. In any case, it doesn't seem worth keeping the check as-is. And with one caller remaining, you could delete the helper and inline that expression into the check in obj_allocated(). What it does now is self-explanatory; it doesn't need another name like that PagePrivate() check before did.