linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* page_ref tracepoints
@ 2025-01-23 19:55 Matthew Wilcox
  2025-01-27  7:46 ` David Hildenbrand
  2025-01-27 23:42 ` Alistair Popple
  0 siblings, 2 replies; 3+ messages in thread
From: Matthew Wilcox @ 2025-01-23 19:55 UTC (permalink / raw)
  To: linux-mm; +Cc: Joonsoo Kim, linux-fsdevel

The page reference count tracepoints currently look like this:

                __entry->pfn = page_to_pfn(page);
                __entry->flags = page->flags;
                __entry->count = page_ref_count(page);
                __entry->mapcount = atomic_read(&page->_mapcount);
                __entry->mapping = page->mapping;
                __entry->mt = get_pageblock_migratetype(page);
        TP_printk("pfn=0x%lx flags=%s count=%d mapcount=%d mapping=%p mt=%d val=%d",


Soon, pages will not have a ->mapping, nor a ->mapcount [1].  But they will
still have a refcount, at least for now.  put_page() will move out of
line and look something like this:

void put_page(struct page *page)
{
        unsigned long memdesc = page->memdesc;
        if (memdesc_is_folio(memdesc))
                return folio_put(memdesc_folio(memdesc));
        BUG_ON(memdesc_is_slab(memdesc));
        ... handle other memdesc types here ...
	if (memdesc_is_compound_head(memdesc))
		page = memdesc_head_page(memdesc);

        if (put_page_testzero(page))
                __put_page(page);
}

What I'm thinking is:

 - Define a set of folio_ref_* tracepoints which dump exactly the same info
   as page_ref does today
 - Remove mapping & mapcount from page_ref_* functions.

Other ideas?  I don't use these tracepoints myself; they generate far
too much data to be useful to me.

[1] In case you missed it,
https://lore.kernel.org/linux-mm/Z37pxbkHPbLYnDKn@casper.infradead.org/


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: page_ref tracepoints
  2025-01-23 19:55 page_ref tracepoints Matthew Wilcox
@ 2025-01-27  7:46 ` David Hildenbrand
  2025-01-27 23:42 ` Alistair Popple
  1 sibling, 0 replies; 3+ messages in thread
From: David Hildenbrand @ 2025-01-27  7:46 UTC (permalink / raw)
  To: Matthew Wilcox, linux-mm; +Cc: Joonsoo Kim, linux-fsdevel

On 23.01.25 20:55, Matthew Wilcox wrote:
> The page reference count tracepoints currently look like this:
> 
>                  __entry->pfn = page_to_pfn(page);
>                  __entry->flags = page->flags;
>                  __entry->count = page_ref_count(page);
>                  __entry->mapcount = atomic_read(&page->_mapcount);
>                  __entry->mapping = page->mapping;
>                  __entry->mt = get_pageblock_migratetype(page);
>          TP_printk("pfn=0x%lx flags=%s count=%d mapcount=%d mapping=%p mt=%d val=%d",
> 
> 
> Soon, pages will not have a ->mapping, nor a ->mapcount [1].  But they will
> still have a refcount, at least for now.  put_page() will move out of
> line and look something like this:
> 
> void put_page(struct page *page)
> {
>          unsigned long memdesc = page->memdesc;
>          if (memdesc_is_folio(memdesc))
>                  return folio_put(memdesc_folio(memdesc));
>          BUG_ON(memdesc_is_slab(memdesc));
>          ... handle other memdesc types here ...
> 	if (memdesc_is_compound_head(memdesc))
> 		page = memdesc_head_page(memdesc);
> 
>          if (put_page_testzero(page))
>                  __put_page(page);
> }
> 
> What I'm thinking is:
> 
>   - Define a set of folio_ref_* tracepoints which dump exactly the same info
>     as page_ref does today
>   - Remove mapping & mapcount from page_ref_* functions.

Yes, I did not completely remove the mapcount in 
6eca32567455db2db38b1126e0d6ad8f0e5c3ed9, but likely I just should have. 
We're dumping raw values of flags/mappings/mapcount right now, and 
probably we should drop them all here.

I also once thought about introducing folio variants on my todo list to 
dump actual per-folio fields instead of raw values.

One "problematic" part in the current usage are things like 
page_ref_sub_and_test(), where we end up calling 
__page_ref_mod_and_test() on something with a refcount of 0 (or could 
even have been reallocated? not sure)



-- 
Cheers,

David / dhildenb



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: page_ref tracepoints
  2025-01-23 19:55 page_ref tracepoints Matthew Wilcox
  2025-01-27  7:46 ` David Hildenbrand
@ 2025-01-27 23:42 ` Alistair Popple
  1 sibling, 0 replies; 3+ messages in thread
From: Alistair Popple @ 2025-01-27 23:42 UTC (permalink / raw)
  To: Matthew Wilcox; +Cc: linux-mm, Joonsoo Kim, linux-fsdevel

On Thu, Jan 23, 2025 at 07:55:24PM +0000, Matthew Wilcox wrote:
> The page reference count tracepoints currently look like this:
> 
>                 __entry->pfn = page_to_pfn(page);
>                 __entry->flags = page->flags;
>                 __entry->count = page_ref_count(page);
>                 __entry->mapcount = atomic_read(&page->_mapcount);
>                 __entry->mapping = page->mapping;
>                 __entry->mt = get_pageblock_migratetype(page);
>         TP_printk("pfn=0x%lx flags=%s count=%d mapcount=%d mapping=%p mt=%d val=%d",
> 
> 
> Soon, pages will not have a ->mapping, nor a ->mapcount [1].  But they will
> still have a refcount, at least for now.  put_page() will move out of
> line and look something like this:
> 
> void put_page(struct page *page)
> {
>         unsigned long memdesc = page->memdesc;
>         if (memdesc_is_folio(memdesc))
>                 return folio_put(memdesc_folio(memdesc));
>         BUG_ON(memdesc_is_slab(memdesc));
>         ... handle other memdesc types here ...
> 	if (memdesc_is_compound_head(memdesc))
> 		page = memdesc_head_page(memdesc);
> 
>         if (put_page_testzero(page))
>                 __put_page(page);
> }
> 
> What I'm thinking is:
> 
>  - Define a set of folio_ref_* tracepoints which dump exactly the same info
>    as page_ref does today
>  - Remove mapping & mapcount from page_ref_* functions.
> 
> Other ideas?  I don't use these tracepoints myself; they generate far
> too much data to be useful to me.

I'm afraid I don't have any specific ideas but in the past I have used
these tracepoints mostly to debug issues around what is holding a pin on a
page and therefore preventing some operation, usually migration. For that
page_ref_count(page) and page->_mapcount were the most important fields, with
the latter required to determine the "expected" refcount.

The ->mapping field was less interesting to me when I have used these
tracepoints.

> [1] In case you missed it,
> https://lore.kernel.org/linux-mm/Z37pxbkHPbLYnDKn@casper.infradead.org/
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-01-27 23:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-01-23 19:55 page_ref tracepoints Matthew Wilcox
2025-01-27  7:46 ` David Hildenbrand
2025-01-27 23:42 ` Alistair Popple

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox