Re: [PATCH RFC v2 03/11] mm/page_owner: preserve accounting with countable stack depot records

From: Matt Fleming

Date: Thu Oct 22 2026 - 10:31:01 EST


On Tue, Oct 20, 2026 at 11:11:24AM +0000, 'Marco Elver' via kernel-team wrote:
> On Tue, Sep 08, 2026 at 02:13PM +0100, Caleb Kan wrote:
> >
> > @@ -609,6 +611,9 @@ static inline struct stack_record *find_stack(struct list_head *bucket,
> > list_for_each_entry_rcu(stack, bucket, hash_list) {
> > if (stack->hash != hash || stack->size != size)
> > continue;
> > + /* Page owner countable records have a distinct count lifetime. */
> > + if ((stack->flags ^ flags) & STACK_DEPOT_FLAG_COUNTABLE)
> > + continue;
>
> This splits hash deduplication unconditionally even when
> stackdepot.trie_enabled=0 (the default), and even for page_owner's
> free_handle traces (__reset_page_owner()), which never touch
> stack_record->count. Prior to this patch, persistent hash records had
> refcount_set(&stack->count, REFCOUNT_SATURATED) and page_owner safely
> overwrote it with its 1-biased page count while still sharing records
> with non-GET callers.
>
> The interface looks error-prone to me.

OK, fair point. I think the best course is just to make the trie
backend work with the ->count mechanism too so this whole problem goes
away.

Thanks,
Matt