lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Y2jpnBLFOgP8+RZ7@smile.fi.intel.com>
Date:   Mon, 7 Nov 2022 13:18:52 +0200
From:   Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To:     Hyeonggon Yoo <42.hyeyoo@...il.com>
Cc:     linux-mm@...ck.org, Andrew Morton <akpm@...ux-foundation.org>,
        Christoph Lameter <cl@...ux.com>,
        Pekka Enberg <penberg@...nel.org>,
        David Rientjes <rientjes@...gle.com>,
        Vlastimil Babka <vbabka@...e.cz>,
        Naoya Horiguchi <naoya.horiguchi@....com>,
        Miaohe Lin <linmiaohe@...wei.com>,
        Matthew Wilcox <willy@...radead.org>,
        Minchan Kim <minchan@...nel.org>,
        Mel Gorman <mgorman@...hsingularity.net>,
        Andrea Arcangeli <aarcange@...hat.com>,
        Dan Williams <dan.j.williams@...el.com>,
        Hugh Dickins <hughd@...gle.com>,
        Muchun Song <songmuchun@...edance.com>,
        David Hildenbrand <david@...hat.com>,
        Petr Mladek <pmladek@...e.com>,
        Steven Rostedt <rostedt@...dmis.org>,
        Sergey Senozhatsky <senozhatsky@...omium.org>,
        Rasmus Villemoes <linux@...musvillemoes.dk>,
        Jonathan Corbet <corbet@....net>, linux-doc@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [RFC v2 3/3] mm, printk: introduce new format %pGt for page_type

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.

> [    1.816704] raw: 0017ffffc0000000 0000000000000000 dead000000000122 0000000000000000
> [    1.817291] raw: 0000000000000000 0000000000000000 00000001ffffffff 0000000000000000
> [    1.817870] page dumped because: Before __SetPageSlab()
> 
> [    1.818258] page:ffffea000415e200 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x105788
> [    1.818857] flags: 0x17ffffc0000000(node=0|zone=2|lastcpupid=0x1fffff)
> [    1.819250] page_type: 0xffefffff(slab)
> [    1.819483] raw: 0017ffffc0000000 0000000000000000 dead000000000122 0000000000000000
> [    1.819947] raw: 0000000000000000 0000000000000000 00000001ffefffff 0000000000000000
> [    1.820410] page dumped because: After __SetPageSlab()

> Cc: Petr Mladek <pmladek@...e.com>
> Cc: Steven Rostedt <rostedt@...dmis.org>
> Cc: Sergey Senozhatsky <senozhatsky@...omium.org>
> Cc: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
> Cc: Rasmus Villemoes <linux@...musvillemoes.dk>
> Cc: Jonathan Corbet <corbet@....net>
> Cc: Andrew Morton <akpm@...ux-foundation.org>
> Cc: linux-doc@...r.kernel.org
> Cc: linux-kernel@...r.kernel.org
> Cc: linux-mm@...ck.org

Can you utilize --cc parameter next time and avoid polluting commit message
with this? We have archives where anybody can check this (and usually maintainers
add a Link tag for that purpose).

...

> +	%pGt	0xffefffff(slab)

No space before ( ?

...

> +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?

> +	buf = number(buf, end, page_type, default_flag_spec);
> +
> +	if (buf < end)
> +		*buf = '(';
> +	buf++;

> +	if (page_type_has_type(page_type))

This should be check for the entire function.

> +		buf = format_flags(buf, end, ~page_type, pagetype_names);
> +
> +	if (buf < end)
> +		*buf = ')';
> +	buf++;
> +
> +	return buf;
> +}

...

> @@ -36,6 +36,11 @@ const struct trace_print_flags pageflag_names[] = {
>  	{0, NULL}
>  };
>  
> +const struct trace_print_flags pagetype_names[] = {
> +	__def_pagetype_names,


> +	{0, NULL}

Hmm... I see it's already done like this above, but {}  would suffice, why not
to convert the rest first to the {} and use it here?

> +};

...

>  	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.

-- 
With Best Regards,
Andy Shevchenko


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ