Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp1809099pxm; Sun, 27 Feb 2022 03:44:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJwmN25WCgvW7VUmYBUAWlT2GeGAp3DcPiWlaODRr/lfwNdXPrMe/hXMKwL71fTi9xy2u06f X-Received: by 2002:a63:ee56:0:b0:378:96fe:fded with SMTP id n22-20020a63ee56000000b0037896fefdedmr837988pgk.281.1645962251824; Sun, 27 Feb 2022 03:44:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645962251; cv=none; d=google.com; s=arc-20160816; b=bpreBpsej77WrRWptuGdL6VtWXgtSFrenAaMj2od4pV9i4mYA6NQNvQ7uxxExv4EWJ o0XEutQsBqe0XxLPqLxJVv2Sz3Em+Ir+PCfokPPj6hlALB5a/td5KImQtfB3W23w3m/p nWHmZoHvXg//uvyYRCUWEfFVlSpzLH0EobExqg63BhvNvV6aMyJb2dIabn53LOEoREvq PDTPlVd8BGIvHTJ0licP1ynL0vN/WBcJKRMPJUK0hII1mRGLZbv4h1S+qVvCpRUztQBe DtpjpiL75si85dx7VsD2RoJHPjLENV39YUhfAjalhcDzU0l1vKUjx/hj8GmbF2kQpajE NnAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Ek02eCmAnj7Z2ZCUVWU1x+42laMB9rYJ1kTYghRSfoY=; b=DX6oMKzHOXcAZUJJtjIvWS9qqhOd8e+AP6elMx6N3jckaMYoRU3v/2XfOL8a0jSi3R 3aM/ug7hw8N64fNpY1ICjIluq5ZjqoPRoUr9pD2Q5lofu0NB8N9dPFwP5pCcQMI/CwMg dicsmxvWdsBq3azNF/TZtFypp5xEkP+6whmFytrnZ8QUDR0NgV/zUrd7/LUICVgXXFdi x8VO1D6LKaqvAE8DUhZ0eQIzq/HmgZTTB23C9ImCK/cfY1bHaqxVhSUFO7s0uV5cjMeH KYQyQFO5hpdRMn6lbYy6g60ISCzCjKdH1QKQjJIu8ZLvkQIlcsYtBQ1mobJXSdlkJMC7 vBmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="l5LWHNq/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z10-20020a63b90a000000b0037604b9b278si6557177pge.572.2022.02.27.03.43.58; Sun, 27 Feb 2022 03:44:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="l5LWHNq/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S229899AbiB0DuZ (ORCPT + 99 others); Sat, 26 Feb 2022 22:50:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43682 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229647AbiB0DuY (ORCPT ); Sat, 26 Feb 2022 22:50:24 -0500 Received: from mail-pg1-x533.google.com (mail-pg1-x533.google.com [IPv6:2607:f8b0:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 16E3A186409; Sat, 26 Feb 2022 19:49:49 -0800 (PST) Received: by mail-pg1-x533.google.com with SMTP id c1so8452790pgk.11; Sat, 26 Feb 2022 19:49:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=Ek02eCmAnj7Z2ZCUVWU1x+42laMB9rYJ1kTYghRSfoY=; b=l5LWHNq/cqCHFY23g+qTLqYtg2Mgv7d2GowvDp/LrdHdjfCCJaLU9EkWMTemApxWso L7mRV+GY4NUJAOnJh+SyFoQ2AZbCvtq05jfttc8/XZcF00Ud36eKQzeSuZjVoEZHvZ++ 8YfT3V4zEtI1guC9HOJfif2AxnmnL4ojUtunB/s9X0npaZci0zEQ2mpCn/QlbK+Z+rHf sDmNpLcXXv4B+GTZTvLpRvWn4EeuaZVBpIp78cUOh+oHp0hB/7XFRhHeYX8DlFERAUXO q1bgLt/dJHQCtgwP2G4oZvEMeHErFuP8cwaFoAvsmutlmF8RAK37gPgqxdt3ungrgXFy nfmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Ek02eCmAnj7Z2ZCUVWU1x+42laMB9rYJ1kTYghRSfoY=; b=2PGo6NH8nGiJbbJdsDXPLMBNvgMuGXCzLf4KEA98x/DJE3kocnIrf6q/XRE8cN2vXc PWTTF+mKpT+VUPWs67y9s8KHk69BDnEQLFuOHsjkDitOyWi9l3V3X9b4JF6ZouAajGdZ q/mStv1Ena6VXmAW+Jk2EXvWOH8jk4jcPFJMOeAzAQVI7Ay8fG7n4SFRBWQKcvA/6Pt4 Wprc1l3/ffWuwdLt7C+UCet9UpTZ8qZOVRZHlJq6gWRwVOwqeLm6ONPDA2GgHtQp85h5 E2TgaOeSDbzpwjkjtNH5gItJZuaqu/ao3YQeLjPm6WwLUk1y60ignD0lCa3Ht8TKDSTj L1Xw== X-Gm-Message-State: AOAM530h+5ToU2ToTcAGzx3JwgzIkD5radq9IRla7OHK9Hue1NklTqfB 2ZNv9iOsYcMFWpb9TFvyNyU= X-Received: by 2002:aa7:8a4d:0:b0:4f2:6d3f:5fe3 with SMTP id n13-20020aa78a4d000000b004f26d3f5fe3mr15220064pfa.48.1645933788551; Sat, 26 Feb 2022 19:49:48 -0800 (PST) Received: from ip-172-31-19-208.ap-northeast-1.compute.internal (ec2-18-181-137-102.ap-northeast-1.compute.amazonaws.com. [18.181.137.102]) by smtp.gmail.com with ESMTPSA id lt8-20020a17090b354800b001bc509e0085sm12606983pjb.21.2022.02.26.19.49.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 26 Feb 2022 19:49:48 -0800 (PST) Date: Sun, 27 Feb 2022 03:49:42 +0000 From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: Vlastimil Babka Cc: David Rientjes , Christoph Lameter , Joonsoo Kim , Pekka Enberg , Roman Gushchin , Andrew Morton , linux-mm@kvack.org, patches@lists.linux.dev, linux-kernel@vger.kernel.org, Oliver Glitta , Faiyaz Mohammed , Jonathan Corbet , Randy Dunlap , linux-doc@vger.kernel.org Subject: Re: [PATCH 5/5] slab, documentation: add description of debugfs files for SLUB caches Message-ID: References: <20220225180318.20594-1-vbabka@suse.cz> <20220225180318.20594-6-vbabka@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220225180318.20594-6-vbabka@suse.cz> X-Spam-Status: No, score=1.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,FROM_FMBLA_NEWDOM, HK_RANDOM_ENVFROM,HK_RANDOM_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: * X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Feb 25, 2022 at 07:03:18PM +0100, Vlastimil Babka wrote: > From: Oliver Glitta > > Add description of debugfs files alloc_traces and free_traces > to SLUB cache documentation. > > [ vbabka@suse.cz: some rewording ] > > Signed-off-by: Oliver Glitta > Signed-off-by: Vlastimil Babka > Cc: Jonathan Corbet > Cc: Randy Dunlap > Cc: linux-doc@vger.kernel.org > --- > Documentation/vm/slub.rst | 61 +++++++++++++++++++++++++++++++++++++++ > 1 file changed, 61 insertions(+) > > diff --git a/Documentation/vm/slub.rst b/Documentation/vm/slub.rst > index d3028554b1e9..2b2b931e59fc 100644 > --- a/Documentation/vm/slub.rst > +++ b/Documentation/vm/slub.rst > @@ -384,5 +384,66 @@ c) Execute ``slabinfo-gnuplot.sh`` in '-t' mode, passing all of the > 40,60`` range will plot only samples collected between 40th and > 60th seconds). > > + > +DebugFS files for SLUB > +====================== > + > +For more information about current state of SLUB caches with the user tracking > +debug option enabled, debugfs files are available, typically under > +/sys/kernel/debug/slab// (created only for caches with enabled user > +tracking). There are 2 types of these files with the following debug > +information: > + > +1. alloc_traces:: > + > + Prints information about unique allocation traces of the currently > + allocated objects. The output is sorted by frequency of each trace. > + > + Information in the output: > + Number of objects, allocating function, minimal/average/maximal jiffies since alloc, > + pid range of the allocating processes, cpu mask of allocating cpus, and stack trace. > + > + Example::: > + > + 1085 populate_error_injection_list+0x97/0x110 age=166678/166680/166682 pid=1 cpus=1:: > + __slab_alloc+0x6d/0x90 > + kmem_cache_alloc_trace+0x2eb/0x300 > + populate_error_injection_list+0x97/0x110 > + init_error_injection+0x1b/0x71 > + do_one_initcall+0x5f/0x2d0 > + kernel_init_freeable+0x26f/0x2d7 > + kernel_init+0xe/0x118 > + ret_from_fork+0x22/0x30 > + > + > +2. free_traces:: > + > + Prints information about unique free traces of the currently free objects, > + sorted by their frequency. > + I'm not sure that it's traces of the "currently free objects". static int slab_debug_trace_open(struct inode *inode, struct file *filep) { [...] obj_map = bitmap_alloc(oo_objects(s->oo), GFP_KERNEL); [...] for_each_kmem_cache_node(s, node, n) { unsigned long flags; struct slab *slab; if (!atomic_long_read(&n->nr_slabs)) continue; spin_lock_irqsave(&n->list_lock, flags); list_for_each_entry(slab, &n->partial, slab_list) process_slab(t, s, slab, alloc, obj_map); list_for_each_entry(slab, &n->full, slab_list) process_slab(t, s, slab, alloc, obj_map); spin_unlock_irqrestore(&n->list_lock, flags); } [...] } static void __fill_map(unsigned long *obj_map, struct kmem_cache *s, struct slab *slab) { void *addr = slab_address(slab); void *p; bitmap_zero(obj_map, slab->objects); for (p = slab->freelist; p; p = get_freepointer(s, p)) set_bit(__obj_to_index(s, addr, p), obj_map); } static void process_slab(struct loc_track *t, struct kmem_cache *s, struct slab *slab, enum track_item alloc, unsigned long *obj_map) { void *addr = slab_address(slab); void *p; __fill_map(obj_map, s, slab); for_each_object(p, s, addr, slab->objects) if (!test_bit(__obj_to_index(s, addr, p), obj_map)) add_location(t, s, get_track(s, p, alloc)); } I think it's not traces of "currently free objects" because index bit of free objects are set in obj_map bitmap? It's weird but it's traces of allocated objects that have been freed at least once (or ) I think we can fix the code or doc? Please tell me if I'm missing something :) > + Information in the output: > + Number of objects, freeing function, minimal/average/maximal jiffies since free, > + pid range of the freeing processes, cpu mask of freeing cpus, and stack trace. > + > + Example::: > + > + 51 acpi_ut_update_ref_count+0x6a6/0x782 age=236886/237027/237772 pid=1 cpus=1 > + kfree+0x2db/0x420 > + acpi_ut_update_ref_count+0x6a6/0x782 > + acpi_ut_update_object_reference+0x1ad/0x234 > + acpi_ut_remove_reference+0x7d/0x84 > + acpi_rs_get_prt_method_data+0x97/0xd6 > + acpi_get_irq_routing_table+0x82/0xc4 > + acpi_pci_irq_find_prt_entry+0x8e/0x2e0 > + acpi_pci_irq_lookup+0x3a/0x1e0 > + acpi_pci_irq_enable+0x77/0x240 > + pcibios_enable_device+0x39/0x40 > + do_pci_enable_device.part.0+0x5d/0xe0 > + pci_enable_device_flags+0xfc/0x120 > + pci_enable_device+0x13/0x20 > + virtio_pci_probe+0x9e/0x170 > + local_pci_probe+0x48/0x80 > + pci_device_probe+0x105/0x1c0 > + Everything else looks nice! > Christoph Lameter, May 30, 2007 > Sergey Senozhatsky, October 23, 2015 > -- > 2.35.1 > > -- Thank you, You are awesome! Hyeonggon :-)