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 87CC0C43462 for ; Tue, 27 Apr 2021 04:11:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6389E61396 for ; Tue, 27 Apr 2021 04:11:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234728AbhD0EMi (ORCPT ); Tue, 27 Apr 2021 00:12:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59380 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232157AbhD0EMa (ORCPT ); Tue, 27 Apr 2021 00:12:30 -0400 Received: from mail-lf1-x130.google.com (mail-lf1-x130.google.com [IPv6:2a00:1450:4864:20::130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 811ECC061574 for ; Mon, 26 Apr 2021 21:11:45 -0700 (PDT) Received: by mail-lf1-x130.google.com with SMTP id w9so7749800lfr.12 for ; Mon, 26 Apr 2021 21:11:45 -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=xSbYF6YmB+6Po+HsrmYDOpI6TtqeP+AMbaRD22AzlKI=; b=iO53A6Zb7PcYh/T3a3JH5aBVwk/mWU8zPtZ8LHjq9CDwqrY+wgUIAUI6GCtNGett3a 9YOBhkdQdORaqDS3iFyB3RMzMUmhtr2omR3et0XpSA/u3QFySPS5NAea3FD+yBBJfPAz XQjxXHd2nMnStBxUsFB3oG8sFNsxdXB79p7s+A7Swiov76ZdY19a2qVwLWKbrX59bmcG D/u4diG6TLNnEeBncOIyM/khN/IsvyFRC+hiFBsuNTySOj+dZFhuI2DIQAkc1mt7nkFZ NnXMW58mxx50adoY8y2IfFS9jD95YBPJlWezY4lEwImRbZwptzfRBpuSoY6k1auXMGEu rTGA== 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=xSbYF6YmB+6Po+HsrmYDOpI6TtqeP+AMbaRD22AzlKI=; b=WBA+Uac9+b2KGvt/v7U34GeJNzem9obZg0001buir+fwb+R4hwFhAffZVB/oqCfxvk KcI5u3MHDHI9msVtRYHcn384ZootOz4DHimNCrTII03F4r+9dx3YWN7D9rJi8E1+Mq6C fEs/imOhOSIvHG7xWH0xdQw6PQSLxU4Lv8cX+ikZx70GxPGTnf8tTT03WOOFWj+Swupx Y7Fo/8VzSFFUli8SH2QPlJCqfzSDPVnVknXm37z82HSrCpn3ar3WhsfwTjlyM/0Ociov IyYwT6JzKGyc3FGNgpKSiTsGWjcw26IFrVCj0va6TtD6A1k8QnMkvN/8IXr8I8AXFwr4 AkxQ== X-Gm-Message-State: AOAM531OpvTlY8f7vM2OPwO3zx+yPrYqlGDaiK1S/xznOJrSF667uv/U x+vesVlmlRJpv2tfzBk1wKl4Zsgl9KgMEhZ/aY8= X-Google-Smtp-Source: ABdhPJzYfDrrUdy6qUwDE9BULCvak/gZnwodwRAHBNJNzbbB0BEKQTUbuz7dtVc9efTktTYSbkx2W2Cf7qK/GtnjvCk= X-Received: by 2002:ac2:5042:: with SMTP id a2mr14687807lfm.650.1619496703957; Mon, 26 Apr 2021 21:11:43 -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> In-Reply-To: <20210427033632.GW235567@casper.infradead.org> From: Xiongwei Song Date: Tue, 27 Apr 2021 12:11:17 +0800 Message-ID: Subject: Re: [PATCH] mm: append __GFP_COMP flag for trace_malloc To: Matthew Wilcox Cc: Xiongwei Song , cl@linux.com, penberg@kernel.org, rientjes@google.com, iamjoonsoo.kim@lge.com, akpm@linux-foundation.org, vbabka@suse.cz, 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 Tue, Apr 27, 2021 at 11:36 AM Matthew Wilcox wrote: > > On Tue, Apr 27, 2021 at 11:29:32AM +0800, Xiongwei Song wrote: > > On Tue, Apr 27, 2021 at 10:54 AM Matthew Wilcox wrote: > > > > > > On Tue, Apr 27, 2021 at 10:43:20AM +0800, Xiongwei Song wrote: > > > > From: Xiongwei Song > > > > > > > > When calling kmalloc_order, the flags should include __GFP_COMP here, > > > > so that trace_malloc can trace the precise flags. > > > > > > I suppose that depends on your point of view. > > Correct. > > > > Should we report the > > > flags used by the caller, or the flags that we used to allocate memory? > > > And why does it matter? > > When I capture kmem:kmalloc events on my env with perf: > > (perf record -p my_pid -e kmem:kmalloc) > > I got the result below: > > 0.08% call_site=ffffffff851d0cb0 ptr=0xffff8c04a4ca0000 > > bytes_req=10176 bytes_alloc=16384 > > gfp_flags=GFP_ATOMIC|__GFP_NOWARN|__GFP_NOMEMALLOC > > Hmm ... if you have a lot of allocations about this size, that would > argue in favour of adding a kmem_cache of 10880 [*] bytes. That way, > we'd get 3 allocations per 32kB instead of 2. I understand you. But I don't think our process needs this size. This size may be a bug in our code or somewhere, I don't know the RC for now. > [*] 32768 / 3, rounded down to a 64 byte cacheline > > But I don't understand why this confused you. Your caller at > ffffffff851d0cb0 didn't specify __GFP_COMP. I'd be more confused if > this did report __GFP_COMP. > I just wanted to save some time when debugging. Regards 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 08AB2C43461 for ; Tue, 27 Apr 2021 04:11:47 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 86C06613AB for ; Tue, 27 Apr 2021 04:11:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 86C06613AB 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 127B46B0036; Tue, 27 Apr 2021 00:11:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0D8116B006E; Tue, 27 Apr 2021 00:11:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EB9F66B0070; Tue, 27 Apr 2021 00:11:45 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0228.hostedemail.com [216.40.44.228]) by kanga.kvack.org (Postfix) with ESMTP id D06236B0036 for ; Tue, 27 Apr 2021 00:11:45 -0400 (EDT) Received: from smtpin39.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 7D65740CA for ; Tue, 27 Apr 2021 04:11:45 +0000 (UTC) X-FDA: 78076823370.39.92D8323 Received: from mail-lf1-f53.google.com (mail-lf1-f53.google.com [209.85.167.53]) by imf17.hostedemail.com (Postfix) with ESMTP id B3BDC40002C1 for ; Tue, 27 Apr 2021 04:11:41 +0000 (UTC) Received: by mail-lf1-f53.google.com with SMTP id 4so31723666lfp.11 for ; Mon, 26 Apr 2021 21:11:45 -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=xSbYF6YmB+6Po+HsrmYDOpI6TtqeP+AMbaRD22AzlKI=; b=iO53A6Zb7PcYh/T3a3JH5aBVwk/mWU8zPtZ8LHjq9CDwqrY+wgUIAUI6GCtNGett3a 9YOBhkdQdORaqDS3iFyB3RMzMUmhtr2omR3et0XpSA/u3QFySPS5NAea3FD+yBBJfPAz XQjxXHd2nMnStBxUsFB3oG8sFNsxdXB79p7s+A7Swiov76ZdY19a2qVwLWKbrX59bmcG D/u4diG6TLNnEeBncOIyM/khN/IsvyFRC+hiFBsuNTySOj+dZFhuI2DIQAkc1mt7nkFZ NnXMW58mxx50adoY8y2IfFS9jD95YBPJlWezY4lEwImRbZwptzfRBpuSoY6k1auXMGEu rTGA== 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=xSbYF6YmB+6Po+HsrmYDOpI6TtqeP+AMbaRD22AzlKI=; b=UQOwxMIIPznQhIelFwXeNcofTrqAh36v/LIeM9dOy+xnWoGA2S8zwWEiHXDY0P3aeR njQ0NdSTEQ5tTrIrO232sGux1EY6zAptDBGoYKwmfM7eqlODXRZLi68VsbN2p+ZlF1A3 FpqDqbKyv44ukmR9nHsB0MFBdyLIfRpSmpT1eAf0gvFxUal0lH0oQuWSQL+sZa3P5rKm Jm18laKVZ5Mkt0reBmdGo20Qo2C/fOT50eaCDTnVz3ZgmcvkMvCUAMbmXBo2I/gnnPaD zRKiDIgvEWqU38kAQM2TCzKA468Av+jabUEWriG6I3FVeyx2YlVK70yTsElejbUS/KyJ QpKg== X-Gm-Message-State: AOAM533DDGP3K/imZmh852o9TcVGIGtgpctSheBwZYIwW2qqsIScOvo9 Ba0ZO90xbnmmZkaWFOKZE4RefwzL5JpER5ofs88= X-Google-Smtp-Source: ABdhPJzYfDrrUdy6qUwDE9BULCvak/gZnwodwRAHBNJNzbbB0BEKQTUbuz7dtVc9efTktTYSbkx2W2Cf7qK/GtnjvCk= X-Received: by 2002:ac2:5042:: with SMTP id a2mr14687807lfm.650.1619496703957; Mon, 26 Apr 2021 21:11:43 -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> In-Reply-To: <20210427033632.GW235567@casper.infradead.org> From: Xiongwei Song Date: Tue, 27 Apr 2021 12:11:17 +0800 Message-ID: Subject: Re: [PATCH] mm: append __GFP_COMP flag for trace_malloc To: Matthew Wilcox Cc: Xiongwei Song , cl@linux.com, penberg@kernel.org, rientjes@google.com, iamjoonsoo.kim@lge.com, akpm@linux-foundation.org, vbabka@suse.cz, linux-mm@kvack.org, Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: B3BDC40002C1 X-Stat-Signature: 8oicnrwrnxs4ga5a78u8y3ye8j6x48zr X-Rspamd-Server: rspam02 Received-SPF: none (gmail.com>: No applicable sender policy available) receiver=imf17; 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: 1619496701-574078 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 Tue, Apr 27, 2021 at 11:36 AM Matthew Wilcox wrote: > > On Tue, Apr 27, 2021 at 11:29:32AM +0800, Xiongwei Song wrote: > > On Tue, Apr 27, 2021 at 10:54 AM Matthew Wilcox wrote: > > > > > > On Tue, Apr 27, 2021 at 10:43:20AM +0800, Xiongwei Song wrote: > > > > From: Xiongwei Song > > > > > > > > When calling kmalloc_order, the flags should include __GFP_COMP here, > > > > so that trace_malloc can trace the precise flags. > > > > > > I suppose that depends on your point of view. > > Correct. > > > > Should we report the > > > flags used by the caller, or the flags that we used to allocate memory? > > > And why does it matter? > > When I capture kmem:kmalloc events on my env with perf: > > (perf record -p my_pid -e kmem:kmalloc) > > I got the result below: > > 0.08% call_site=ffffffff851d0cb0 ptr=0xffff8c04a4ca0000 > > bytes_req=10176 bytes_alloc=16384 > > gfp_flags=GFP_ATOMIC|__GFP_NOWARN|__GFP_NOMEMALLOC > > Hmm ... if you have a lot of allocations about this size, that would > argue in favour of adding a kmem_cache of 10880 [*] bytes. That way, > we'd get 3 allocations per 32kB instead of 2. I understand you. But I don't think our process needs this size. This size may be a bug in our code or somewhere, I don't know the RC for now. > [*] 32768 / 3, rounded down to a 64 byte cacheline > > But I don't understand why this confused you. Your caller at > ffffffff851d0cb0 didn't specify __GFP_COMP. I'd be more confused if > this did report __GFP_COMP. > I just wanted to save some time when debugging. Regards