Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp2728726pxy; Mon, 3 May 2021 06:49:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxo52UpjFZngpRymVuMQp0rd9+Po74C3yoWTm3txIb1mElf6GlPRMaks0m7OVUhcCLGKceF X-Received: by 2002:a17:907:2708:: with SMTP id w8mr16800791ejk.0.1620049741723; Mon, 03 May 2021 06:49:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620049741; cv=none; d=google.com; s=arc-20160816; b=po8/9ihp8ROMd8Juu3AHzmsZCZwA211waVHNPS3zVkR/v2QpwM2f1UQ06PAfexrtSE wRYZTThm10jatsWoSbdlLKeKmZ8PQI1NPKMvLy0Dki3/hkOWVtGUF+LTeEu1RntlKwT0 UCMPI0DI0tXFKNwu5d5cO9yW0EcJglpQL4jKy9KjzwAzloDPTYUZ6z3dWq8YyWDeaUjd bl6g2pLMS2u+dV6oelLoxmuJZ/UY6u4jF2FeUuDN54xjUsiPubs+5FK497+E0tZT2kuQ MOxXrdscZtDECtL9qRUSegtbPmwgD+8Z0AHXNBmCbhLcXbAqQN7cq0drnATdwtK9VXkD untA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=vCHfLVT7xZm/VvmGHQo2PuQgSI+sUGNQhih98c652p4=; b=QjC9RxoEZfecyIcqNr1eqBnDoiEZK0AXAkWS6npl6Jwz+03dEGZiPWm54xQcpLqAIk 4EWL6zqP3gvsPmy8yTzXEXKLs3Lm1sCC7neMNUfVJv+udW2cGNnj0Zs+EA492mmz6VTP diIe1j04FV9z2dtG4frQ5EXv2fi2IAcN6gSTMvSGG0gTYgvdmPdmCgJLP0rfQzPfqr54 izcVGj9iwXZTL1Aqdcw1aqGWff8+TF5QfQ8XCuTspwbgQ9rsoiqO9cMEvK0HiNqUfU6p OSg4vpNUfulLC0cHdbjpHfusbmsxx3WJBy8jV/s8aNZIuES8hB1Nfpd41MWOR+82beuK TgQQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i3si10553991ejp.610.2021.05.03.06.48.36; Mon, 03 May 2021 06:49:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233624AbhECMgA (ORCPT + 99 others); Mon, 3 May 2021 08:36:00 -0400 Received: from mx2.suse.de ([195.135.220.15]:51488 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232213AbhECMgA (ORCPT ); Mon, 3 May 2021 08:36:00 -0400 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 >