From patchwork Fri May 21 12:11:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver Glitta X-Patchwork-Id: 12273003 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=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 71002C43460 for ; Fri, 21 May 2021 12:11:34 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 099BA613D6 for ; Fri, 21 May 2021 12:11:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 099BA613D6 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 B88D38E0038; Fri, 21 May 2021 08:11:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B60428E0022; Fri, 21 May 2021 08:11:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A00358E0038; Fri, 21 May 2021 08:11:32 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0175.hostedemail.com [216.40.44.175]) by kanga.kvack.org (Postfix) with ESMTP id 7246E8E0022 for ; Fri, 21 May 2021 08:11:32 -0400 (EDT) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 1CE091814ACBF for ; Fri, 21 May 2021 12:11:32 +0000 (UTC) X-FDA: 78165123624.07.578F9FD Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) by imf19.hostedemail.com (Postfix) with ESMTP id 217F990009EF for ; Fri, 21 May 2021 12:11:29 +0000 (UTC) Received: by mail-wr1-f47.google.com with SMTP id r12so20856926wrp.1 for ; Fri, 21 May 2021 05:11:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=i3PtvIn3e83BJKazxoRmqSdndVRiSDgFlBve83mzSb0=; b=lWo0CnDeza1lg1y/wl0wstJvMhHfAumf114y9xzRjwZTnbUeMXVE0HNqg24Uerkn/j jG2Cx8StiDpVjcp2++hDyzfPQ9XoAGSPQP1npC720ODVBqWDMR9FxsRc1vI1PbBC5p9i CIYLPCk1UZ3oGnnLmUSVAdWoUA1Xui6x/MY/Rd1HZzrH/F3RSoAGAIif4tNRyXDzRXv7 cOjqCOum6LSTCJ4y0GDGCv97FqImIFPn1taGtcelrXNxuojOn2JTWXrh07dDN1xADLGq VqC5EQYKkSqWeJ0VC6LG6j0NuYeIYYpET3cXlffeE5D7wVLHs0aazL4EdrKfzAI6LdyS V+Nw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=i3PtvIn3e83BJKazxoRmqSdndVRiSDgFlBve83mzSb0=; b=mTz8vA5mONro2vLuPRGXja+tV0jnocjy7yfJI0BXjt4ElFuZ5qJzI8CjuD7Is6nO33 rlk91P0M7pmDaY1lNrvQy0XFF7aud4nWviujgdpx1+qPjbmxIjXztj4o+IBJlyD06gfu 7ZNdpt3Ez4ZwYBqX4SPMsFuYar7v0M12grlXZeXH6iKvzFrouz4C4GGqc73ZR3nmj6s2 IpsR24GhHvSokH2pDdETt3o3Z5xjE6yu6/TuwslhzVua2cRJtImph9659tpHywOw2QSY YYPh5kX173lGQdLGfUQVSMJNBRK3odpDmelY6CUn54omt1eVKbdwdO3oSBI7u9n412BH BrwQ== X-Gm-Message-State: AOAM530pbH6MtUxHjoMtBpg9hmGEVwz2NfAmm4ltZZIJZ2BpxkVv35lQ NfRzEoncc0ZwBrPH0uKGkzUEEW0u0XCco/mO X-Google-Smtp-Source: ABdhPJwrgnwHqggWQ/pppvxseMU9ZskSzS2UEsOWZW6JmOTj/pMlpOtg3UuT78DMFju3VNdIhAveMA== X-Received: by 2002:adf:f10c:: with SMTP id r12mr9416310wro.26.1621599090895; Fri, 21 May 2021 05:11:30 -0700 (PDT) Received: from oliver-Z170M-D3H.cuni.cz ([2001:718:1e03:5128:e010:8b67:85b8:dc89]) by smtp.gmail.com with ESMTPSA id c64sm3339401wma.15.2021.05.21.05.11.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 May 2021 05:11:30 -0700 (PDT) From: glittao@gmail.com To: cl@linux.com, penberg@kernel.org, rientjes@google.com, iamjoonsoo.kim@lge.com, akpm@linux-foundation.org, vbabka@suse.cz Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, faiyazm@codeaurora.org, Oliver Glitta Subject: [RFC 2/3] mm/slub: sort objects in cache by frequency of stack trace Date: Fri, 21 May 2021 14:11:26 +0200 Message-Id: <20210521121127.24653-2-glittao@gmail.com> X-Mailer: git-send-email 2.31.1.272.g89b43f80a5 In-Reply-To: <20210521121127.24653-1-glittao@gmail.com> References: <20210521121127.24653-1-glittao@gmail.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 217F990009EF Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=lWo0CnDe; spf=pass (imf19.hostedemail.com: domain of glittao@gmail.com designates 209.85.221.47 as permitted sender) smtp.mailfrom=glittao@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspamd-Server: rspam04 X-Stat-Signature: 9skiafcdxzmdpcdaij1cer4rcbfitzah X-HE-Tag: 1621599089-154817 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: 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. 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) {