From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E2C0B7478 for ; Tue, 14 Jul 2026 03:16:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783998983; cv=none; b=Tanpp474LRLatpdi3qHReUoYIpzjr9gha1h8r59tZTfzshx43Y/i2w1yuHbfxu4UTNEyoplTO65GHXEHngNq3+kG6HFaC6OAg/H26OUwMLNiDr8xenTkic5XQ3a3QfYjvH+w7awm3VQ5mt3CkxL8WgEOi3h72kFtTvt6yQkNHf4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783998983; c=relaxed/simple; bh=Wc183axFgSaZL7Vtv0/g1c7Hd5cOGRh9xbqoekKgD4c=; h=Date:From:To:Cc:Subject:Message-Id:In-Reply-To:References: Mime-Version:Content-Type; b=MgXhDJm4vW48vQPt93hirRqq9Fgt3zV2x2FhGVw1o3SoPPKx5cV6Rxqi716mrCezZC8pzuxtW/tOiE/tAEb5lTNmA6qdYAOcGfsZqB6S6epv3htGEfttfvwBSPBvkQjhysrjrf6zJANsMSpNTOZvi8sVuHkxdoYMdtWLtEZVs8M= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b=i5IrMgf+; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="i5IrMgf+" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2F1F01F000E9; Tue, 14 Jul 2026 03:16:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=korg; t=1783998981; bh=dNQ3cvHxuHE4isS2+7t6ZlfquRgdiYmjN4YpiQXlf1A=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=i5IrMgf+jWZ3QJrlbp0biQqPoZxd7IMDJsS2CtdnHkkGui16rgS9KB+i5c8KNy59U vuy6MOn6d0sC/3liO9Hbbi4ETiYWh6222URBJw/SedmGJoX0OXPu1LZ338khz5t9Z5 VBd08WmbfoER/WPPPwf3BpeAdDzNUK/AL9VRkxVA= Date: Mon, 13 Jul 2026 20:16:20 -0700 From: Andrew Morton To: Ye Liu Cc: Zi Yan , Vlastimil Babka , Suren Baghdasaryan , Michal Hocko , Brendan Jackman , Johannes Weiner , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v6 0/9] mm/page_owner: misc cleanups Message-Id: <20260713201620.1481535c63be9a408fbd7e4e@linux-foundation.org> In-Reply-To: <20260714015117.78351-1-ye.liu@linux.dev> References: <20260714015117.78351-1-ye.liu@linux.dev> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) 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-Transfer-Encoding: 7bit On Tue, 14 Jul 2026 09:50:59 +0800 Ye Liu wrote: > This series collects a few cleanups for mm/page_owner.c that have been > accumulated while reading through the file. There is no functional > change -- the goal is to make the code easier to read and maintain. Thanks, I updated mm.git's mm-unstable branch to this version of the patchset. > v6: > - Patch 3: drop unnecessary 'extern' from __folio_set_owner_migrate_reason() > declaration in page_owner.h; Adjust the indentation; add Reviewed-by from > Lorenzo Stoakes. > - Patch 8: clarify commit message wording; add Reviewed-by from Zi Yan and > Vlastimil Babka. > - Patch 9: rename patch to cover both TOCTOU fixes; also replace > page_memcg_check(page) with extracting objcg from the memcg_data snapshot > to fix a second TOCTOU issue; add early return for the MEMCG_DATA_OBJEXTS > (slab) case. > - Link: https://lore.kernel.org/all/20260701061101.344679-1-ye.liu@linux.dev/ Here's how v6 altered mm.git: include/linux/hugetlb.h | 4 ++-- include/linux/migrate.h | 6 +++--- include/linux/page_owner.h | 2 +- mm/page_owner.c | 8 ++++++-- 4 files changed, 12 insertions(+), 8 deletions(-) --- a/include/linux/hugetlb.h~b +++ a/include/linux/hugetlb.h @@ -155,7 +155,7 @@ bool folio_isolate_hugetlb(struct folio int get_hwpoison_hugetlb_folio(struct folio *folio, bool *hugetlb, bool unpoison); void folio_putback_hugetlb(struct folio *folio); void move_hugetlb_state(struct folio *old_folio, struct folio *new_folio, - enum migrate_reason reason); + enum migrate_reason reason); void hugetlb_fix_reserve_counts(struct inode *inode); extern struct mutex *hugetlb_fault_mutex_table; u32 hugetlb_fault_mutex_hash(struct address_space *mapping, pgoff_t idx); @@ -425,7 +425,7 @@ static inline void folio_putback_hugetlb } static inline void move_hugetlb_state(struct folio *old_folio, - struct folio *new_folio, enum migrate_reason reason) + struct folio *new_folio, enum migrate_reason reason) { } --- a/include/linux/migrate.h~b +++ a/include/linux/migrate.h @@ -57,9 +57,9 @@ void putback_movable_pages(struct list_h int migrate_folio(struct address_space *mapping, struct folio *dst, struct folio *src, enum migrate_mode mode); int migrate_pages(struct list_head *l, new_folio_t new, free_folio_t free, - unsigned long private, enum migrate_mode mode, - enum migrate_reason reason, - unsigned int *ret_succeeded); + unsigned long private, enum migrate_mode mode, + enum migrate_reason reason, + unsigned int *ret_succeeded); struct folio *alloc_migration_target(struct folio *src, unsigned long private); bool isolate_movable_ops_page(struct page *page, isolate_mode_t mode); bool isolate_folio_to_list(struct folio *folio, struct list_head *list); --- a/include/linux/page_owner.h~b +++ a/include/linux/page_owner.h @@ -15,7 +15,7 @@ extern void __set_page_owner(struct page extern void __split_page_owner(struct page *page, int old_order, int new_order); extern void __folio_copy_owner(struct folio *newfolio, struct folio *old); -extern void __folio_set_owner_migrate_reason(struct folio *folio, enum migrate_reason reason); +void __folio_set_owner_migrate_reason(struct folio *folio, enum migrate_reason reason); extern void __dump_page_owner(const struct page *page); extern void pagetypeinfo_showmixedcount_print(struct seq_file *m, pg_data_t *pgdat, struct zone *zone); --- a/mm/page_owner.c~b +++ a/mm/page_owner.c @@ -540,6 +540,7 @@ static inline int print_page_owner_memcg struct page *page) { unsigned long memcg_data; + struct obj_cgroup *objcg; struct mem_cgroup *memcg; bool online; char name[80]; @@ -549,11 +550,14 @@ static inline int print_page_owner_memcg if (!memcg_data || PageTail(page)) goto out_unlock; - if (memcg_data & MEMCG_DATA_OBJEXTS) + if (memcg_data & MEMCG_DATA_OBJEXTS) { ret += scnprintf(kbuf + ret, count - ret, "Slab cache page\n"); + goto out_unlock; + } - memcg = page_memcg_check(page); + objcg = (void *)(memcg_data & ~OBJEXTS_FLAGS_MASK); + memcg = objcg ? obj_cgroup_memcg(objcg) : NULL; if (!memcg) goto out_unlock; _