From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BDA88C433ED for ; Mon, 3 May 2021 12:35:09 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1E1C1611C9 for ; Mon, 3 May 2021 12:35:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1E1C1611C9 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 64F4D6B006E; Mon, 3 May 2021 08:35:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5FEA56B0071; Mon, 3 May 2021 08:35:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 49F6D6B0070; Mon, 3 May 2021 08:35:08 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0051.hostedemail.com [216.40.44.51]) by kanga.kvack.org (Postfix) with ESMTP id 2D0146B0036 for ; Mon, 3 May 2021 08:35:08 -0400 (EDT) Received: from smtpin34.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id CFC10181AEF3F for ; Mon, 3 May 2021 12:35:07 +0000 (UTC) X-FDA: 78099864654.34.0F0F8AC Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf05.hostedemail.com (Postfix) with ESMTP id 89EE2E00012A for ; Mon, 3 May 2021 12:35:03 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 183CAAE00; Mon, 3 May 2021 12:35:06 +0000 (UTC) Subject: Re: [PATCH] mm: append __GFP_COMP flag for trace_malloc To: Xiongwei Song , Matthew Wilcox Cc: Xiongwei Song , 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 References: <1619491400-1904-1-git-send-email-sxwjean@me.com> <20210427025358.GV235567@casper.infradead.org> <20210427033632.GW235567@casper.infradead.org> <20210427112527.GX235567@casper.infradead.org> From: Vlastimil Babka Message-ID: Date: Mon, 3 May 2021 14:35:04 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Authentication-Results: imf05.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf05.hostedemail.com: domain of vbabka@suse.cz designates 195.135.220.15 as permitted sender) smtp.mailfrom=vbabka@suse.cz X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 89EE2E00012A X-Stat-Signature: ee6zs9anofdpmjj8s7atfbnyz3qse9u4 Received-SPF: none (suse.cz>: No applicable sender policy available) receiver=imf05; identity=mailfrom; envelope-from=""; helo=mx2.suse.de; client-ip=195.135.220.15 X-HE-DKIM-Result: none/none X-HE-Tag: 1620045303-797848 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 4/28/21 5:05 AM, Xiongwei Song wrote: > On Tue, Apr 27, 2021 at 7:26 PM Matthew Wilcox 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 >