linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vlastimil Babka <vbabka@suse.cz>
To: Xiongwei Song <sxwjean@gmail.com>, Matthew Wilcox <willy@infradead.org>
Cc: Xiongwei Song <sxwjean@me.com>,
	cl@linux.com, penberg@kernel.org, rientjes@google.com,
	iamjoonsoo.kim@lge.com, akpm@linux-foundation.org,
	linux-mm@kvack.org,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] mm: append __GFP_COMP flag for trace_malloc
Date: Mon, 3 May 2021 14:35:04 +0200	[thread overview]
Message-ID: <c08e5e63-f66c-211c-5a9b-03ea12ee10bf@suse.cz> (raw)
In-Reply-To: <CAEVVKH8AFMqwEcpp=7h7k-_BYqwU+gutoUMNM93pnGPiW=u+gg@mail.gmail.com>

On 4/28/21 5:05 AM, Xiongwei Song wrote:
> On Tue, Apr 27, 2021 at 7:26 PM Matthew Wilcox <willy@infradead.org> wrote:
>>
>> On Tue, Apr 27, 2021 at 01:30:48PM +0800, Xiongwei Song wrote:
>> > Hi Mattew,
>> >
>> > One more thing I should explain, the kmalloc_order() appends the
>> > __GFP_COMP flags,
>> > not by the caller.
>> >
>> > void *kmalloc_order(size_t size, gfp_t flags, unsigned int order)
>> > {
>> > ...........................................................
>> >
>> > flags |= __GFP_COMP;
>> > page = alloc_pages(flags, order);
>> > ...........................................................
>> > return ret;
>> > }
>> > EXPORT_SYMBOL(kmalloc_order);
>> >
>> > #ifdef CONFIG_TRACING
>> > void *kmalloc_order_trace(size_t size, gfp_t flags, unsigned int order)
>> > {
>> > void *ret = kmalloc_order(size, flags, order);
>> > trace_kmalloc(_RET_IP_, ret, size, PAGE_SIZE << order, flags);
>> > return ret;
>> > }
>> > EXPORT_SYMBOL(kmalloc_order_trace);
>> > #endif
>>
>> Yes, I understood that.  What I don't understand is why appending the
>> __GFP_COMP to the trace would have been less confusing for you.
>>
>> Suppose I have some code which calls:
>>
>>         kmalloc(10 * 1024, GFP_ATOMIC|__GFP_NOWARN|__GFP_NOMEMALLOC);
>>
>> and I see in my logs
>>
>>      0.08%  call_site=ffffffff851d0cb0 ptr=0xffff8c04a4ca0000 bytes_req=10176 bytes_alloc=16384 gfp_flags=GFP_ATOMIC|__GFP_NOWARN|__GFP_NOMEMALLOC|__GFP_COMP
>>
>> That seems to me _more_ confusing because I would wonder "Where did that
>> __GFP_COMP come from?"
> 
> Thank you for the comments. But I disagree.

FTR, I agree with Matthew. This is a tracepoint for kmalloc() so I would expect
to see what flags were passed to kmalloc().
If I wanted to see how the flags translated to page allocator's flags, I would
have used a page allocator's tracepoint which would show me that.

> When I use trace, I hope I can get the precise data rather than something
> changed that I don't know , then I can get the correct conclusion or
> direction on my issue.

It's precise from the point of the caller.

> Here my question is what the trace events are for if they don't provide the
> real situation? I think that's not graceful and friendly.
> 
> From my perspective, it'd be better to know my flags changed before checking
> code lines one by one. In other words, I need a warning to reminder me on this,
> then I can know quickly my process might do some incorrect things.

Your process should not care about __GFP_COMP if you use properly
kmalloc()+kfree(). Once you start caring about __GFP_COMP, you should be using
page allocator's API, not kmalloc().

> Regards,
> Xiongwei
> 


  reply	other threads:[~2021-05-03 12:35 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-27  2:43 [PATCH] mm: append __GFP_COMP flag for trace_malloc Xiongwei Song
2021-04-27  2:53 ` Matthew Wilcox
2021-04-27  3:29   ` Xiongwei Song
2021-04-27  3:36     ` Matthew Wilcox
2021-04-27  4:11       ` Xiongwei Song
2021-04-27  5:30         ` Xiongwei Song
2021-04-27 11:25           ` Matthew Wilcox
2021-04-28  3:05             ` Xiongwei Song
2021-05-03 12:35               ` Vlastimil Babka [this message]
2021-05-07  5:41                 ` Xiongwei Song

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=c08e5e63-f66c-211c-5a9b-03ea12ee10bf@suse.cz \
    --to=vbabka@suse.cz \
    --cc=akpm@linux-foundation.org \
    --cc=cl@linux.com \
    --cc=iamjoonsoo.kim@lge.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=penberg@kernel.org \
    --cc=rientjes@google.com \
    --cc=sxwjean@gmail.com \
    --cc=sxwjean@me.com \
    --cc=willy@infradead.org \
    /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;
as well as URLs for NNTP newsgroup(s).