From nobody Fri Apr 17 00:23:50 2026 Received: from mail-dl1-f74.google.com (mail-dl1-f74.google.com [74.125.82.74]) (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 1B03713D51E for ; Wed, 25 Feb 2026 00:24:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771979083; cv=none; b=S8mwlbNPS5W+pYzczTgiJPlYM6yvvZzaHnc1eX9EiPL3buNQbmgBzvdYdBJ5Unl3zcS3PtmT/IN2EtO6J8ExvRjvzEVeL9BITRpUSJMNZt2tV7fLyeCWDF399kyPJhESClSWS3T/DfeyYw9V2uPHBXjLnaWtKgpvkl0Gjbj5Mh0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771979083; c=relaxed/simple; bh=1djW+sviE8GMc9yihya8bBPKGdGDhx7z9iqWw0JDbyc=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=qHgaFCxYZKWpbAtqs5xGQeTve4qUKhvP+fpWqT7aKxaGTwjtyOrxeSP7mAI8OzbWsMhZrJhMjljwvyOJLnaQQRkVO3eyHNxfHtsDDuwxKclbzbZPL/OzGruMXfjTbJ2wzexXI5wmU3I3fzDV7JY/cFPZ9CoDQPfldeCZRCla7IA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--axelrasmussen.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=KGAwt1gs; arc=none smtp.client-ip=74.125.82.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--axelrasmussen.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="KGAwt1gs" Received: by mail-dl1-f74.google.com with SMTP id a92af1059eb24-1275c6fc58aso11381865c88.0 for ; Tue, 24 Feb 2026 16:24:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1771979081; x=1772583881; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=y6p6m2t6gYC4KUM+VAX+tvTTd08UPZbYNt8kHVfP8DA=; b=KGAwt1gs8tZ3qGiqO4U78pB5RCwJZBnhefIrimB38tRLN7WyjqFWq42mA+lp0cqGno nwU0KsVFrtqUiKVi22cft0jmQ8eAI6UFZ+eVlrPZ4qQA3I1QocC2/rQxjT5cVx+oO3Re yngkSWeGjvsSc+LvoO4FpOyAoUPzh1QhHOKVsTDb3kokHyeGeikUshb1r7b59sgeZ3BB qk1ssUFQpUzc5hvxVlbkDRCAHFCu/Z+dzcqzCuXzgTet0yS6wvlJx1Ap4Xxx9y3qNUXs 3JmdZvBlg70vV9b4bSmJpSVN1bMkHmPK4q0p6lYsKV3occFALqWO6BDuzaYeUqfj6NIJ meSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771979081; x=1772583881; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=y6p6m2t6gYC4KUM+VAX+tvTTd08UPZbYNt8kHVfP8DA=; b=YpfvPsnrUIA14Kg/bIMF2z0Z88XA2cg+sVyTZv3vzuag55v6DfgzzFQnFaxyC5sUJm y97+YZ9o0duV+dDoR0ssmLRAZAa92ij+Nz3IWKmLPW3ZN57aVXPE/PJSoqazOLlmbpBT i7WC+y40ltkKVVeyn702iJr81vBvrtUd7Jy4yS1YgKaX8jjAfMb0FdMlHGghcGWkwF6K f4ElQf6ikIjvojBzQc5v8Ur+bM/Q3QxQjpxm0ftkNCZbXcE0rv37e0Q/OFHRXeqM8R0O xGB3H+RVVXErjhMBDGpxzWqnLR40NxA8JTP5fVXBBNieQlpr57tsYgUDAPke/xytiONf +B/A== X-Forwarded-Encrypted: i=1; AJvYcCW2Fk1zS60fcKyJXfGLcP3Y9PaBoMj/wb/daQ8ivZm5Dzu46x0Xuq4vItQWNdK/Y79wue1gSDQDLtrQatg=@vger.kernel.org X-Gm-Message-State: AOJu0Yzig8k22X3KDCqIyRpHFRYxo1KDEO+RqlfD16kOLuXBkrQSIgD8 lO7cl4o6SuM/GoVYlmW5zccuDBM6g/hJOjrVjyOjHbLdUmk+yjF0dfebOf4PvFmFBBSchDQi2xR ieKYP9uv72/2BNeeoDW9nTHwGizBuMDgI5g== X-Received: from dlbsn11.prod.google.com ([2002:a05:7022:b90b:b0:127:365a:84c7]) (user=axelrasmussen job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7022:2521:b0:11b:99a2:9082 with SMTP id a92af1059eb24-12781dd78c8mr205452c88.15.1771979080917; Tue, 24 Feb 2026 16:24:40 -0800 (PST) Date: Tue, 24 Feb 2026 16:24:34 -0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.53.0.414.gf7e9f6c205-goog Message-ID: <20260225002434.2953895-1-axelrasmussen@google.com> Subject: [PATCH] Revert "ptdesc: remove references to folios from __pagetable_ctor() and pagetable_dtor()" From: Axel Rasmussen To: Andrew Morton , David Hildenbrand , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , "Matthew Wilcox (Oracle)" Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Axel Rasmussen , stable@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This change swapped out mod_node_page_state for lruvec_stat_add_folio. But, these two APIs are not interchangeable: the lruvec version also increments memcg stats, in addition to "global" pgdat stats. So after this change, the "pagetables" memcg stat in memory.stat always yields "0", which is a userspace visible regression. I tried to look for a refactor where we add a variant of lruvec_stat_mod_folio which takes a pgdat and a memcg instead of a folio, to try to adhere to the spirit of the original patch. But at the end of the day this just means we have to call folio_memcg(ptdesc_folio(ptdesc)) anyway, which doesn't really accomplish much. This regression is visible in master as well as 6.18 stable, so CC stable too. Fixes: f0c92726e89f ("ptdesc: remove references to folios from __pagetable_= ctor() and pagetable_dtor()") Cc: stable@vger.kernel.org Signed-off-by: Axel Rasmussen Acked-by: Johannes Weiner Acked-by: Shakeel Butt Reviewed-by: Vishal Moola (Oracle) --- include/linux/mm.h | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 5be3d8a8f806..abb4963c1f06 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -3514,26 +3514,21 @@ static inline bool ptlock_init(struct ptdesc *ptdes= c) { return true; } static inline void ptlock_free(struct ptdesc *ptdesc) {} #endif /* defined(CONFIG_SPLIT_PTE_PTLOCKS) */ =20 -static inline unsigned long ptdesc_nr_pages(const struct ptdesc *ptdesc) -{ - return compound_nr(ptdesc_page(ptdesc)); -} - static inline void __pagetable_ctor(struct ptdesc *ptdesc) { - pg_data_t *pgdat =3D NODE_DATA(memdesc_nid(ptdesc->pt_flags)); + struct folio *folio =3D ptdesc_folio(ptdesc); =20 - __SetPageTable(ptdesc_page(ptdesc)); - mod_node_page_state(pgdat, NR_PAGETABLE, ptdesc_nr_pages(ptdesc)); + __folio_set_pgtable(folio); + lruvec_stat_add_folio(folio, NR_PAGETABLE); } =20 static inline void pagetable_dtor(struct ptdesc *ptdesc) { - pg_data_t *pgdat =3D NODE_DATA(memdesc_nid(ptdesc->pt_flags)); + struct folio *folio =3D ptdesc_folio(ptdesc); =20 ptlock_free(ptdesc); - __ClearPageTable(ptdesc_page(ptdesc)); - mod_node_page_state(pgdat, NR_PAGETABLE, -ptdesc_nr_pages(ptdesc)); + __folio_clear_pgtable(folio); + lruvec_stat_sub_folio(folio, NR_PAGETABLE); } =20 static inline void pagetable_dtor_free(struct ptdesc *ptdesc) --=20 2.53.0.414.gf7e9f6c205-goog