Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "David Hildenbrand (Arm)" <david@kernel.org>
To: Linus Torvalds <torvalds@linuxfoundation.org>, ilya.gladyshev@linux.dev
Cc: Andrew Morton <akpm@linux-foundation.org>,
	ivgorbunov@me.com, Liam.Howlett@oracle.com, apopple@nvidia.com,
	artem.kuzin@huawei.com, baolin.wang@linux.alibaba.com,
	foxido@foxido.dev, harry.yoo@oracle.com,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	lorenzo.stoakes@oracle.com, mhocko@suse.com,
	muchun.song@linux.dev, rppt@kernel.org, surenb@google.com,
	vbabka@suse.cz, willy@infradead.org, yuzhao@google.com,
	ziy@nvidia.com, pfalcato@suse.de, kirill@shutemov.name
Subject: Re: [PATCH v4 0/2] mm: improve folio refcount scalability
Date: Mon, 22 Jun 2026 10:15:02 +0200	[thread overview]
Message-ID: <086b119c-b777-46ae-b087-798ca3e44ecd@kernel.org> (raw)
In-Reply-To: <CAHk-=wjwdbrwUpTiQef5eAd9pfC3bKig9YpXxoHQinssubRh=w@mail.gmail.com>

On 6/21/26 06:46, Linus Torvalds wrote:
> On Sat, 20 Jun 2026 at 11:19, <ilya.gladyshev@linux.dev> wrote:
>>
>> T2: optimistic get() [0 -> 1]
>> T2: put page back [1 -> 0]
>> T2: calls dtor for type X, returns into the allocator
> 
> Which optimistic getter does this?
> 
> I didn't go back and look at the series, but isn't the rule that the code does:
> 
>  - optimistic get
> 
>  - then check that the folio is still valid (*not* using the page
> count, but by re-looking it up elsewhere, typically the address space
> mapping)
> 
>  - put the page if it wasn't valid
> 
>  - if it goes to zero, there's no destructor inherent in that

I'm also confused about the destructor aspect. Usually we have

	folio_try_get(folio)

	... some checks

	folio_put(folio);

folio_put() is just:

	if (folio_put_testzero(folio))
		__folio_put(folio);


If the thing was a folio at the start, but stopped being a folio halfway through
folio_put(), I don't see the big difference to the thing not being a folio right
from the start. (folio_try_get() would succeed on some random page either way
right now)

Which destructors are we concerned about?

(1) hugetlb destructor

If we grabbed a non-hugetlb folio but suddenly have a hugetlb folio after
folio_put_testzero(), __folio_put() will just do the right thing and call
free_huge_folio().


(2) pagetable_dtor()

These destructors are called when we unmap the page table, before actually
freeing it. So it wouldn't apply here.


Maybe it's about something like

void page_frag_free(void *addr)
{
	struct page *page = virt_to_head_page(addr);

	if (unlikely(put_page_testzero(page)))
		free_frozen_pages(page, compound_order(page));
}

Whereby, if it's a folio, we wouldn't do the right thing as we are
not going through __folio_put()?

-- 
Cheers,

David


      parent reply	other threads:[~2026-06-22  8:15 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-08 21:53 [PATCH v4 0/2] mm: improve folio refcount scalability Gladyshev Ilya
2026-06-08 21:54 ` [PATCH v4 1/2] mm: drop page refcount zero state semantics ilya.gladyshev
2026-06-08 21:54 ` [PATCH v4 2/2] mm: implement page refcount locking via dedicated bit Gladyshev Ilya
2026-06-08 22:47 ` [PATCH v4 0/2] mm: improve folio refcount scalability Andrew Morton
2026-06-09 10:28   ` David Hildenbrand (Arm)
2026-06-09 19:02   ` Gladyshev Ilya
2026-06-09 21:02     ` Pedro Falcato
2026-06-20 18:19   ` ilya.gladyshev
2026-06-21  1:40     ` Zi Yan
2026-06-22  7:55       ` David Hildenbrand (Arm)
2026-06-21  4:46     ` Linus Torvalds
2026-06-21 21:34       ` Gladyshev Ilya
2026-06-21 21:50         ` Matthew Wilcox
2026-06-23 21:23           ` Ilya Gladyshev
2026-06-21 22:53         ` Linus Torvalds
2026-06-22  8:15       ` David Hildenbrand (Arm) [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=086b119c-b777-46ae-b087-798ca3e44ecd@kernel.org \
    --to=david@kernel.org \
    --cc=Liam.Howlett@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=apopple@nvidia.com \
    --cc=artem.kuzin@huawei.com \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=foxido@foxido.dev \
    --cc=harry.yoo@oracle.com \
    --cc=ilya.gladyshev@linux.dev \
    --cc=ivgorbunov@me.com \
    --cc=kirill@shutemov.name \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=lorenzo.stoakes@oracle.com \
    --cc=mhocko@suse.com \
    --cc=muchun.song@linux.dev \
    --cc=pfalcato@suse.de \
    --cc=rppt@kernel.org \
    --cc=surenb@google.com \
    --cc=torvalds@linuxfoundation.org \
    --cc=vbabka@suse.cz \
    --cc=willy@infradead.org \
    --cc=yuzhao@google.com \
    --cc=ziy@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox