Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp180228pxy; Fri, 7 May 2021 00:17:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwhU05f079DGWUO1NOLZ7CWXbwKhYgALmqiEZF537IPsMS82nQ/vFuyyyI4SBS/3pIrLTVf X-Received: by 2002:a17:902:e84f:b029:ee:cd36:80e3 with SMTP id t15-20020a170902e84fb02900eecd3680e3mr8828272plg.70.1620371869037; Fri, 07 May 2021 00:17:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620371869; cv=none; d=google.com; s=arc-20160816; b=rD+W1kxpKTQlrS+/n7V+eUGWUGaQ1pViyp1lecVXgGHkDWwtv3G3nM1VwWImHqUbrr x+w5nFw6L3h+bgNv0vL+0gEKNDYe84miJTzVyl8WXyKbhMdsnn/WaL2YbUdum71y+ecq wqfY8ptqf9pwYkr/kDhXP5TLUPP0VAMuLYzWtGLPFSloqjeRPn8Ub5iIKzUBs0izCoNh 2m+BUYV4TNsGrSMZo2eI48sjCE6w2cwtp9eZEPUVBruqH92+7yN9mb7GrEXplUoxO46o 2as7ckiY39UcWJuDwsc+KD5DxjWrQsN0gldIP8NYVeAzplymYtW3qP8jEy+n0nC8SGDy 0aVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=uUwArXt1iCdXIwHhFgryf7iwp6cge2eaeiWsAF4dcRo=; b=ZsnnalWh7gS3LxE/yywUwmHiJl5Amt37HgLllm5YJOW7QIpWVJmf0BvmfURvcPGVPp fMfXUdrikG1MRofyDAStlvgpcR2gen7Z4B9XYTB0DefzfRajc9/NPOjT5HqpU2M6nN4x hsRufadmiH7J0xeDgpc+GwlGbTXBQ7KeBD9q30D4cIX5PeVqLv7eyKB0LJAahq+lHkXN FDVI28GEPtyHdDwsRLKQDKE9b9j5LRzlA52403uXFy+xPqRdaZUnKuT1HptMfg9YICNN N1GxaxzOpv/23G23tdL+GVX49YZbQ3ZHWIB27XJBSZ3ysM0fWJXPdlxy628bGQC087eo 22yQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Uk4nH6KS; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p8si1719696pli.18.2021.05.07.00.17.36; Fri, 07 May 2021 00:17:49 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Uk4nH6KS; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232868AbhEGFnM (ORCPT + 99 others); Fri, 7 May 2021 01:43:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231649AbhEGFnL (ORCPT ); Fri, 7 May 2021 01:43:11 -0400 Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C8AAC061574 for ; Thu, 6 May 2021 22:42:12 -0700 (PDT) Received: by mail-lf1-x134.google.com with SMTP id j10so11065856lfb.12 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=PWvNE0sRvHTs1E0JRJTmRPq0dlRi7OhJk3ca3fw5TF/p3K8qdmB1Cq5iGdedlxBlx0 5sCOnZuBF4gTEpdPitBJv+BCp8CvYGTpu98Qj5IWDtuij7GGhDyVZ1VFja1v7DM8zoFl RGqQBHiJ6qljBfTnVA6fN/0wmYdc5d5cKtEgX8chGbAr5SUjHRySrh5Zx6RyuVCRZX3p 4MRRiDnmcWxGztlvFPH/WIBmt3sORWzUFA2LfM+fCYEQVGME3+xditd7YxY+EzEQmv4X sePT4Yo98xNeqO51tCKfCu6Eh3ez27q9h0v4zg0XVaDfPpmeHkjvmlfTn8sBQbHyd0er qRCg== X-Gm-Message-State: AOAM5317m5zsSCxpHf0t+p0hRQrc6x1Gta2C7oZoRHMuGtvQ/JuYGuHy 2LgAPDSizVkroBMSozKOHnop0ciq9AJ82cXc2sg= 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" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > > >