From patchwork Fri May 21 12:11:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver Glitta X-Patchwork-Id: 12273001 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 4D46BC433B4 for ; Fri, 21 May 2021 12:11:33 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D391F61073 for ; Fri, 21 May 2021 12:11:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D391F61073 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 3C1528E0037; Fri, 21 May 2021 08:11:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 36FB98E0022; 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 1EA898E0037; Fri, 21 May 2021 08:11:32 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0234.hostedemail.com [216.40.44.234]) by kanga.kvack.org (Postfix) with ESMTP id E3E3F8E0022 for ; Fri, 21 May 2021 08:11:31 -0400 (EDT) Received: from smtpin30.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 7B8E9DB39 for ; Fri, 21 May 2021 12:11:31 +0000 (UTC) X-FDA: 78165123582.30.FADD260 Received: from mail-wr1-f46.google.com (mail-wr1-f46.google.com [209.85.221.46]) by imf26.hostedemail.com (Postfix) with ESMTP id 2E33840B8CF0 for ; Fri, 21 May 2021 12:11:30 +0000 (UTC) Received: by mail-wr1-f46.google.com with SMTP id j14so19108841wrq.5 for ; Fri, 21 May 2021 05:11:30 -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:mime-version :content-transfer-encoding; bh=Ml9aXgYWsxmLMe303aemuEkZuwFy+qH+s0r1NMT4fd0=; b=G/y47iLV9zx1VyEIaxEgrqDGsn62RsNLQqEpjLroeGdYnN6Qtn3rQH+gX5cZBdaEpv wPar/LUQLrM+8TGApiAaIbFAPgBWFuggukQMtECP5+bahU5Di8h4R+lSr5Tiko2/rpuR GcvuDNhfGEmZeY/JzKn8m+flnUdGinGHX3ihLFXqpPArO74ezylDdv3b1vrs4M4gl63S RynlKm2daNsDvVtfX0ln0DkYJXI/cx/SHvZVJnTOUUhvYs5HK5yUBZyCwHxQKnV0URxL 7cx15SnBT3Oog83WwenE29Z4icoTrgklovwy91BbMslPQH27KfpWnAZwlzNsydJXa9zs aAyg== 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:mime-version :content-transfer-encoding; bh=Ml9aXgYWsxmLMe303aemuEkZuwFy+qH+s0r1NMT4fd0=; b=Z8vHfaBb+OMgEyM7oMNuVw8pPyb1OjBCvcdalF4nV8fzfKhsNeecDGnVH1Wf60WXPd dSV0ItZ8K1ep54R0uywOhLqfNMA4u/T7XS2FsVNMBWQL806wxmEXQl1LOezHbMQp5A+r CUv88sIO1IFI3bpoyoBAfF71sXFIfKWpYaLiU4vyHe799ncvZb3TX6cTb76XSDU2XY4n btNaH8vK4VDUyYD1oykzrtcjk7vB++XMcKYZ224dc8kDGC/j3EQoUhb5mpShHoUDd+B5 simEmZFqP7IjPTzgG/gJJ15pI+xEdmp1JYFdMnpJyHAgV3y0TFDTDAT3aed0/dR5ytFg IsUw== X-Gm-Message-State: AOAM532Vmc6FefRm8JwUyPRKGSWo3YxVYxqqf3G6hq633vPXPgA51jtj xnmJ5PYS3gYiHHx13lVMiAE= X-Google-Smtp-Source: ABdhPJyARzQ5c2zgj9Ij37sb3vRqmocu60KNmQ5m0huB27J8Uo/pGQO62NjtYRLFuHqtdGD698zp8Q== X-Received: by 2002:a5d:648e:: with SMTP id o14mr9037494wri.27.1621599089846; Fri, 21 May 2021 05:11:29 -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.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 May 2021 05:11:29 -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 1/3] mm/slub: aggregate objects in cache by stack trace Date: Fri, 21 May 2021 14:11:25 +0200 Message-Id: <20210521121127.24653-1-glittao@gmail.com> X-Mailer: git-send-email 2.31.1.272.g89b43f80a5 MIME-Version: 1.0 X-Rspamd-Queue-Id: 2E33840B8CF0 Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=gmail.com header.s=20161025 header.b="G/y47iLV"; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf26.hostedemail.com: domain of glittao@gmail.com designates 209.85.221.46 as permitted sender) smtp.mailfrom=glittao@gmail.com X-Rspamd-Server: rspam03 X-Stat-Signature: pczcronbbir3bcqwiqt3xfomggd7y7gx X-HE-Tag: 1621599090-359277 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 Aggregate objects in slub cache by stack trace in addition to caller address during alloc_calls and free_calls implementation in debugfs. Add stack trace to output. Add all_objects implementation to debugfs to print information about all objects. Signed-off-by: Oliver Glitta Reviewed-by: Vlastimil Babka --- Based on next-20210518 and https://lore.kernel.org/r/1621341949-26762-1-git-send-email-faiyazm@codeaurora.org/ mm/slub.c | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) -- 2.31.1.272.g89b43f80a5 diff --git a/mm/slub.c b/mm/slub.c index e9b84eddc50d..d5ed6ed7d68b 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -4770,6 +4770,7 @@ EXPORT_SYMBOL(validate_slab_cache); */ struct location { + depot_stack_handle_t handle; unsigned long count; unsigned long addr; long long sum_time; @@ -4822,9 +4823,15 @@ static int add_location(struct loc_track *t, struct kmem_cache *s, { long start, end, pos; struct location *l; - unsigned long caddr; + unsigned long caddr, chandle; unsigned long age = jiffies - track->when; + depot_stack_handle_t handle; +#ifdef CONFIG_STACKDEPOT + handle = READ_ONCE(track->handle); +#else + handle = 0; +#endif start = -1; end = t->count; @@ -4839,7 +4846,8 @@ static int add_location(struct loc_track *t, struct kmem_cache *s, break; caddr = t->loc[pos].addr; - if (track->addr == caddr) { + chandle = t->loc[pos].handle; + if ((track->addr == caddr) && (handle == chandle)) { l = &t->loc[pos]; l->count++; @@ -4864,6 +4872,8 @@ static int add_location(struct loc_track *t, struct kmem_cache *s, if (track->addr < caddr) end = pos; + else if (track->addr == caddr && handle < chandle) + end = pos; else start = pos; } @@ -4886,6 +4896,7 @@ static int add_location(struct loc_track *t, struct kmem_cache *s, l->max_time = age; l->min_pid = track->pid; l->max_pid = track->pid; + l->handle = handle; cpumask_clear(to_cpumask(l->cpus)); cpumask_set_cpu(track->cpu, to_cpumask(l->cpus)); nodes_clear(l->nodes); @@ -5837,6 +5848,21 @@ static int slab_debugfs_show(struct seq_file *seq, void *v) seq_printf(seq, " nodes=%*pbl", nodemask_pr_args(&l->nodes)); +#ifdef CONFIG_STACKDEPOT + { + depot_stack_handle_t handle; + unsigned long *entries; + unsigned int nr_entries, j; + + handle = READ_ONCE(l->handle); + if (handle) { + nr_entries = stack_depot_fetch(handle, &entries); + seq_puts(seq, "\n"); + for (j = 0; j < nr_entries; j++) + seq_printf(seq, "\t%pS\n", (void *)entries[j]); + } + } +#endif seq_puts(seq, "\n"); }