lkml.org 
[lkml]   [2022]   [Nov]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC v2 3/3] mm, printk: introduce new format %pGt for page_type
On Mon 2022-11-07 13:18:52, Andy Shevchenko wrote:
> On Sun, Nov 06, 2022 at 11:03:55PM +0900, Hyeonggon Yoo wrote:
> > dump_page() uses %pGp format to print 'flags' field of struct page.
> > As some page flags (e.g. PG_buddy, see page-flags.h for more details)
> > are set in page_type field, introduce %pGt format which provides
> > human readable output of page_type. And use it in dump_page().
> >
> > Note that the sense of bits are different in page_type. if page_type is
> > 0xffffffff, no flags are set. if PG_slab (0x00100000) flag is set,
> > page_type is 0xffefffff. Clearing a bit means we set the bit. Bits in
> > page_type are inverted when printing type names.
> >
> > Below is examples of dump_page(). One is just after alloc_pages() and
> > the other is after __SetPageSlab().
> >
> > [ 1.814728] page:ffffea000415e200 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x105788
> > [ 1.815961] flags: 0x17ffffc0000000(node=0|zone=2|lastcpupid=0x1fffff)
>
> > [ 1.816443] page_type: 0xffffffff()
>
> Why do we have empty parentheses? I would expect either something there, or no
> parentheses at all.

This looks fine. format_page_flags() does the same for %pGp.

> ...
>
> > + %pGt 0xffefffff(slab)
>
> No space before ( ?

Also looks fine. %pGp does the same.

> ...
>
> > +static
> > +char *format_page_type(char *buf, char *end, unsigned int page_type)
> > +{
> > + if (!(page_type & PAGE_TYPE_BASE))
> > + return string(buf, end, "no type for user-mapped page", default_str_spec);
>
> It's too long, can we make it shorten?

I wonder if it would help to write the value. Something like:

page_type: 0x0ace5768(no type)

That said. I am not familiar with the page types and am not sure
about the semantic of this value. MM people should decide what they
want to see in this case.

> ...
>
> > pr_warn("%sflags: %pGp%s\n", type, &head->flags,
> > page_cma ? " CMA" : "");
> > + pr_warn("page_type: %pGt\n", &head->page_type);
> > +
> > print_hex_dump(KERN_WARNING, "raw: ", DUMP_PREFIX_NONE, 32,
> > sizeof(unsigned long), page,
> > sizeof(struct page), false);
> > diff --git a/mm/internal.h b/mm/internal.h
> > index cb4c663a714e..956eaa9f12c0 100644
> > --- a/mm/internal.h
> > +++ b/mm/internal.h
> > @@ -773,6 +773,7 @@ static inline void flush_tlb_batched_pending(struct mm_struct *mm)
> > #endif /* CONFIG_ARCH_WANT_BATCHED_UNMAP_TLB_FLUSH */
> >
> > extern const struct trace_print_flags pageflag_names[];
> > +extern const struct trace_print_flags pagetype_names[];
> > extern const struct trace_print_flags vmaflag_names[];
> > extern const struct trace_print_flags gfpflag_names[];
>
> I would split this to a separate change, but it's up to PRINTK maintainers.

I guess that you are talking about the line:

+ pr_warn("page_type: %pGt\n", &head->page_type);


Yes, it would be better to have implementation of %pGt modifier
in one patch and add the user in another one.

Best Regards,
Petr

\
 
 \ /
  Last update: 2022-11-07 15:28    [W:0.068 / U:0.048 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site