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=-2.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED 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 5F47AC433B4 for ; Fri, 7 May 2021 05:42:14 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D92A6613D6 for ; Fri, 7 May 2021 05:42:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D92A6613D6 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 42B696B0082; Fri, 7 May 2021 01:42:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3FFAA6B0083; Fri, 7 May 2021 01:42:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 27A106B0085; Fri, 7 May 2021 01:42:13 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0096.hostedemail.com [216.40.44.96]) by kanga.kvack.org (Postfix) with ESMTP id 0BB2D6B0082 for ; Fri, 7 May 2021 01:42:13 -0400 (EDT) Received: from smtpin24.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id ABE5F689F for ; Fri, 7 May 2021 05:42:12 +0000 (UTC) X-FDA: 78113339304.24.EB700B7 Received: from mail-lf1-f53.google.com (mail-lf1-f53.google.com [209.85.167.53]) by imf14.hostedemail.com (Postfix) with ESMTP id F28C7C0007CC for ; Fri, 7 May 2021 05:41:50 +0000 (UTC) Received: by mail-lf1-f53.google.com with SMTP id x20so11128772lfu.6 for ; Thu, 06 May 2021 22:42:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=uUwArXt1iCdXIwHhFgryf7iwp6cge2eaeiWsAF4dcRo=; b=Uk4nH6KS+LeFUC6YRrxgumdVC1SGPzSFqA20jxE/bTyDxq4csREcr4Y+AqI61VtKAi vfPNPB1YSENtEnCfhH1XU/zOIqJpN6mRAw5Q0xGsO2DxvhEbRxbo5UGxRIMe0pgToyzA WHpeMvgwN0hOXM0VUS2AjwVoTX5kAKBCnlvFCIc/4ZmsYVP+AfVhHgjpGo9CU2OScGAI cqNCqW/gq4yrlcWrzgozxZ18SErsQnemoKw8XFeXPIzTcZBZq+yVA1vpItln38T2OQpX 9aLG/V1m16W9UxiXhr2wXx5fIiDgrqqF/LdnJp+YU/A4Zf4vtxib9jDD9ODdHGaGOMc4 etuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=uUwArXt1iCdXIwHhFgryf7iwp6cge2eaeiWsAF4dcRo=; b=UlYRgJrvsUyugzRX1LZrmWZKdAjalyKzQKk6O9fnTuQ0x9QSoP6OhXxdApZBir7aKV eww8BGTSHOKTd34skoIODXjpPqnKTerZCyBdc8i2vKRwOJvXamkIns/3CypwUDsTDvJP A4DlZdg1SYMNbJaYKS8ry+YcOkGxRGQ6P4wboj0zaKVnu/fLj3kK6Ai4u2+p0sCLNka4 ZdKdlJDJYN3I5cpLL7TIP11xsCGl+r6V4W7YJ8iLAo2mF0Qj50+Hgxwa/2GFVq/sMYG1 LEJy9EAAW8HT5KhClR/Eb/XAZnEWmwKJnmvVcdYn1Jt847Ig+qIU9+eN4hE2CFJeL10I mnEQ== X-Gm-Message-State: AOAM530WI1tkThEM1MlY7OgV4mW3Ftiem3C8jOctGtHXclnwYjObcP5x 4BhGsKFwdNYH/9/IVUPaPtgbt1Di213McTz4jDM= X-Google-Smtp-Source: ABdhPJyDk0FNvTIUXdXE+nCjY54cKktl1JwQNERc3u38PcT+xPgRYthrW2MW/Cdr8sgKiTAWkUpW9t09PCHGGLwhKuk= X-Received: by 2002:a05:6512:5d6:: with SMTP id o22mr5343267lfo.587.1620366130789; Thu, 06 May 2021 22:42:10 -0700 (PDT) MIME-Version: 1.0 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> In-Reply-To: From: Xiongwei Song Date: Fri, 7 May 2021 13:41:44 +0800 Message-ID: Subject: Re: [PATCH] mm: append __GFP_COMP flag for trace_malloc To: Vlastimil Babka Cc: Matthew Wilcox , 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 Content-Type: text/plain; charset="UTF-8" Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=Uk4nH6KS; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf14.hostedemail.com: domain of sxwjean@gmail.com designates 209.85.167.53 as permitted sender) smtp.mailfrom=sxwjean@gmail.com X-Rspamd-Server: rspam03 X-Stat-Signature: hsjx7c64mb6jwe1amm5iq8tkseamoeaa X-Rspamd-Queue-Id: F28C7C0007CC Received-SPF: none (gmail.com>: No applicable sender policy available) receiver=imf14; identity=mailfrom; envelope-from=""; helo=mail-lf1-f53.google.com; client-ip=209.85.167.53 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1620366110-274306 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 Mon, May 3, 2021 at 8:35 PM Vlastimil Babka wrote: > > 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. Make sense. Thank you. > > 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 > > >