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=-17.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=unavailable 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 8606DC47088 for ; Wed, 26 May 2021 14:06:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 66F0D61026 for ; Wed, 26 May 2021 14:06:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234456AbhEZOIT (ORCPT ); Wed, 26 May 2021 10:08:19 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:49658 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234422AbhEZOIM (ORCPT ); Wed, 26 May 2021 10:08:12 -0400 Received: from imap.suse.de (imap-alt.suse-dmz.suse.de [192.168.254.47]) by smtp-out2.suse.de (Postfix) with ESMTP id 828A41FD29; Wed, 26 May 2021 14:06:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1622037999; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+fWJ89PhgnhS/Yf0anDjWgbu8PDm6n5TN+P7qd4Wr8U=; b=RDbd3fdHF45PozgvzgXadaMAZxMTQxUQmwVQHJvnnc4S3H6ZtYg0gUDI1CgoRvs7XGAa4j J5qqMNGwn+m0/oABtqzrxcdiuttGnWEvVZxePlyeVlIfEr4Ln+ZI3jIDLcCbI2jeJOU3/Z tBXmfYg6pVymi3IatniocPvzWYGAkrc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1622037999; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+fWJ89PhgnhS/Yf0anDjWgbu8PDm6n5TN+P7qd4Wr8U=; b=bprVp6ntthqke5j8weOXe3bT25Blzuf6OkkbkDDU5JiA9ypm+J6GeQNVPqgHf991axpd47 pFpUdVianUHVevCg== Received: from director2.suse.de (director2.suse-dmz.suse.de [192.168.254.72]) by imap.suse.de (Postfix) with ESMTPSA id 6249D11A98; Wed, 26 May 2021 14:06:39 +0000 (UTC) Subject: Re: [RFC 2/3] mm/slub: sort objects in cache by frequency of stack trace To: glittao@gmail.com, cl@linux.com, penberg@kernel.org, rientjes@google.com, iamjoonsoo.kim@lge.com, akpm@linux-foundation.org Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, faiyazm@codeaurora.org References: <20210521121127.24653-1-glittao@gmail.com> <20210521121127.24653-2-glittao@gmail.com> From: Vlastimil Babka Message-ID: Date: Wed, 26 May 2021 16:06:39 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.2 MIME-Version: 1.0 In-Reply-To: <20210521121127.24653-2-glittao@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 5/21/21 2:11 PM, glittao@gmail.com wrote: > From: Oliver Glitta > > Sort objects in slub cache by the frequency of stack trace used > in object location in alloc_calls and free_calls implementation > in debugfs. Most frequently used stack traces will be the first. That will make it much more convenient. > Signed-off-by: Oliver Glitta Reviewed-by: Vlastimil Babka > --- > mm/slub.c | 17 +++++++++++++++++ > 1 file changed, 17 insertions(+) > > diff --git a/mm/slub.c b/mm/slub.c > index d5ed6ed7d68b..247983d647cd 100644 > --- a/mm/slub.c > +++ b/mm/slub.c > @@ -37,6 +37,7 @@ > #include > #include > #include > +#include > > #include > #include > @@ -5893,6 +5894,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 kmem_cache_node *n; > @@ -5944,6 +5956,11 @@ static void *slab_debugfs_start(struct seq_file *seq, loff_t *ppos) > process_slab(&t, s, page, alloc); > 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); > + > } > > if (*ppos < t.count) { >