Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp1339567pxm; Sat, 26 Feb 2022 12:16:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJwv/KjrA4o2xvmSLrJlrup3QSimYpZ2WtKOlo4IcWweJvVd72DTHZNH4qd/I1jCxHdQElAR X-Received: by 2002:a17:902:e944:b0:14e:dc4f:f099 with SMTP id b4-20020a170902e94400b0014edc4ff099mr13210933pll.161.1645906585875; Sat, 26 Feb 2022 12:16:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645906585; cv=none; d=google.com; s=arc-20160816; b=bmXCsoI8pTUTXQ9XmnXyGXGj0DLQwXzGcnBHGSDN/uMXK1gZbqBAyAFg6G5fKDTbov YiygwuiNVtFSdKiK/9lWFWckuL3laKvTcRGNTVGZyaLFMDTGAkj38P7Hdcl6mVrKsw8N uvJqRIbscy5BXQ313i4RuDKxcqksUfc0PQfEXTtByD95lrvfBE4DFwC22RvIMTYvZBhL R58UemTH/1nx5JFD0Ebxr5CFlBnq6FG0hiPH6DG3fyjKFyV2S7xKFKAgJhMTG312AqGh JLvGvQDgLr5kkMU6fZXGlG0cZMt5GzQ0Ad3aOZvi0Wiz9/RQttYm1j6ih7uEocXoL+LS xhBA== 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=mmkWsrso01vONxcAXV20rQyXeBZP2Ss9B8KA2fOi8ag=; b=V6C8U1pdZZuqAE08A1p/NKZTSCL8zJIkDqbZST7WaW4z1EyZEnGLk9EubVJh73wqGN +RdAvHM2vxuhrTYv/LbBlDCh/rJ4iI5VsorLtQtVUdPHw5Bc+a1LXVy7yCyiIudqHJJu G7f1tcYQe2RMf5cImxhg4d9vVswvVGqu/l5OzCFrDhDeAB4mVPBaIuLrbaA2kt4FaFGT STz2Sdq78VUzY+Or3VYq0BXSpxN9+z9L5XQ69BCvB/AAalSNoavT1KaanWS0IdmkOPBw qsYqfE5geMiPcd30flGb1B0F+xPa4cE6hWbglfTIimevf+houAvFmuTF1uT/mrSbggd2 GhoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=k5S5i1E4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id i11-20020a63d44b000000b0036c71b669b5si5143242pgj.535.2022.02.26.12.16.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 26 Feb 2022 12:16:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=k5S5i1E4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 982EF24DEC1; Sat, 26 Feb 2022 12:10:01 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231307AbiBZLDt (ORCPT + 99 others); Sat, 26 Feb 2022 06:03:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231287AbiBZLDq (ORCPT ); Sat, 26 Feb 2022 06:03:46 -0500 Received: from mail-pf1-x42d.google.com (mail-pf1-x42d.google.com [IPv6:2607:f8b0:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7005431340 for ; Sat, 26 Feb 2022 03:03:11 -0800 (PST) Received: by mail-pf1-x42d.google.com with SMTP id p8so6888755pfh.8 for ; Sat, 26 Feb 2022 03:03:11 -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=mmkWsrso01vONxcAXV20rQyXeBZP2Ss9B8KA2fOi8ag=; b=k5S5i1E4NCCM4iHYCxYqvpeR9HY1NZVvfuYaFHDFveJx88bYwYsYzzpmFk8bdZ8Pyv ANz6YXwgEKKXSkHZE+9vFNHD7Yk7GWyhRAunYXXu5w9W0M7dkcdC05aoSZuWY8JoDTrS eqw/NxXlybnE4sRaYgRvV2txym58lE88n/18IPvSkLVoL5r7hjUthkxWFFVFpPxbV4R1 gYVx1tmOgFwtmRD2If00nSjG6VeGuBgoCdCPMVXUBlOpzR9E/s9m3nOXSp3qLK4o2ICi 6Pq5/VGCfbv9HEoL9HaNnGuI+mzN+IYGJGmj9ITAiP5J/TzIu8NqTO6u2v0UG8RBFibG Zp2A== 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=mmkWsrso01vONxcAXV20rQyXeBZP2Ss9B8KA2fOi8ag=; b=3YLqK4BCkzvBLSviNk3e6omdorbKfwysKBYipNvtseI2Yjk6cjRJwj8EMslUMdxG8T ilHAY8Ftn58u+4e/HsnkIELg/TgvRrIZ7ktdsWMwFFsCwsTJJr1C3YVXUi/x9Yso3DVi +NooEmSjpsLj9j9YSGvuv5Wmn9VSMaQpqjYDhJQXhu2k7aZTE9JoC+Kri7tKwrsqDmaz sHf6GKreYeEo50ZK09FclH2kqMNfNOAlalrvjYiknL38ZRFIft1xTftShooKR6K2XbFM IoSsXnX9xBEivY77UIM5Y/BrQfFDjrNP2VxAxbYde7GxkG/f9gzq9t/0Nlal9wCG5fWx disQ== X-Gm-Message-State: AOAM531cYRpUEWho5PS99DZbUCQ1y57ti0az7hCagyvHa2oFRGWbr5Ic s4NqszLc7k6cSBtqz3cygeU= X-Received: by 2002:a05:6a00:1ac6:b0:4bd:140:626c with SMTP id f6-20020a056a001ac600b004bd0140626cmr12027035pfv.7.1645873390956; Sat, 26 Feb 2022 03:03:10 -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 e14-20020a056a001a8e00b004e136d54a15sm6804244pfv.105.2022.02.26.03.03.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 26 Feb 2022 03:03:10 -0800 (PST) Date: Sat, 26 Feb 2022 11:03:05 +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 Subject: Re: [PATCH 4/5] mm/slub: sort debugfs output by frequency of stack traces Message-ID: References: <20220225180318.20594-1-vbabka@suse.cz> <20220225180318.20594-5-vbabka@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220225180318.20594-5-vbabka@suse.cz> X-Spam-Status: No, score=-0.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HK_RANDOM_FROM,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 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:17PM +0100, Vlastimil Babka wrote: > From: Oliver Glitta > > Sort the output of debugfs alloc_traces and free_traces by the frequency > of allocation/freeing stack traces. Most frequently used stack traces > will be printed first, e.g. for easier memory leak debugging. > > Signed-off-by: Oliver Glitta > Signed-off-by: Vlastimil Babka > --- > mm/slub.c | 16 ++++++++++++++++ > 1 file changed, 16 insertions(+) > > diff --git a/mm/slub.c b/mm/slub.c > index 06599db4faa3..a74afe59a403 100644 > --- a/mm/slub.c > +++ b/mm/slub.c > @@ -38,6 +38,7 @@ > #include > #include > #include > +#include > > #include > #include > @@ -6150,6 +6151,17 @@ static void *slab_debugfs_next(struct seq_file *seq, void *v, loff_t *ppos) > return NULL; > } > > +static int cmp_loc_by_count(const void *a, const void *b, const void *data) > +{ > + struct location *loc1 = (struct location *)a; > + struct location *loc2 = (struct location *)b; > + > + if (loc1->count > loc2->count) > + return -1; > + else > + return 1; > +} > + > static void *slab_debugfs_start(struct seq_file *seq, loff_t *ppos) > { > struct loc_track *t = seq->private; > @@ -6211,6 +6223,10 @@ static int slab_debug_trace_open(struct inode *inode, struct file *filep) > spin_unlock_irqrestore(&n->list_lock, flags); > } > > + /* Sort locations by count */ > + sort_r(t->loc, t->count, sizeof(struct location), > + cmp_loc_by_count, NULL, NULL); > + > bitmap_free(obj_map); > return 0; > } This is so cool! Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Tested-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> > -- > 2.35.1 > > -- Thank you, You are awesome! Hyeonggon :-)