Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp25913515rwd; Mon, 3 Jul 2023 02:50:32 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ537XEkMHYTdqKg4t7dM+w5qsUZWJqYfLftBz1wEPcYMDi/5hPcfVJsdCsPt6g+upwne0Y6 X-Received: by 2002:a9d:7c95:0:b0:6b8:807b:b50 with SMTP id q21-20020a9d7c95000000b006b8807b0b50mr10393924otn.22.1688377832610; Mon, 03 Jul 2023 02:50:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688377832; cv=none; d=google.com; s=arc-20160816; b=Mt5sIZ+oxKgSuA3wHqacdcZO7Psb10iStiNSccVxkNnxykQij+twi2ABqvYu8AGSKu aK5gjWwyN8zSgRLIyZaPzRMvyW0Ti/UsxZOrJ0rcjMSUYSGB/mNt3XCRU40L4FzyiOOO PxqdoEcnmDkilScDUGs9KDj930GyN2Wf5NYelrnGuXAPdblQOsMjHcwz1BkfpR5tKxAk 6OBWXMUSE71umraC0uoCf6xSb0g3miystFjAyywYEQ0PEdsEM/2jkC+KB2j3Dnc6Txzu N6utPhWwK3hRODV+GQsuGIaCA0C7EaydBlCg+Ik2PPxHkjHYHPFoZI4WvWYtgrYbhkXe 3nEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=Fei6JF8fFGpwRZZZ1z/H1CbAv0E6kC20RDaUButsOpw=; fh=QMm8m/ZWm+A1EqjKAllYKUqNg+o2tkLujHELlI5tZV0=; b=KnDzR9F6bGugyu4LD7zsAVecuApPJltGeOQK97K4GpNf10533DwMusF6jjoRZX6sKO QvtW5Cm3VuEPP/mctaRJw6AHvR0+ZWP3slIErLW+wVHBFHo8mgNwXZH1DuXQ040vIcSJ b/B32QkaLfOZ76DbDlmh69Eysn89Ni2dhp0sPCIBkUCUqpRIJKUnaw1X3llvc7Am/t/x Ut4zldQmrY4cbDRlEUTZqxLu/1A1MwwHYYdoVlRh5iFZ8Eib1QchY4ZR5E3OHfUC+M6b i81mXUlAOeEEFwkfSvuQL5hTL7S8Ppg3lM7KZdchs1eSMcwR8BBI+Vocqz1EqZAVXAD5 TB6A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q2-20020a656842000000b0053b928deb7asi17654902pgt.344.2023.07.03.02.50.18; Mon, 03 Jul 2023 02:50:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-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; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231327AbjGCJtx (ORCPT + 99 others); Mon, 3 Jul 2023 05:49:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50080 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231219AbjGCJts (ORCPT ); Mon, 3 Jul 2023 05:49:48 -0400 Received: from invmail4.hynix.com (exvmail4.skhynix.com [166.125.252.92]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 832CF1B5; Mon, 3 Jul 2023 02:49:46 -0700 (PDT) X-AuditID: a67dfc5b-d85ff70000001748-38-64a299b2593d From: Byungchul Park To: linux-kernel@vger.kernel.org Cc: kernel_team@skhynix.com, torvalds@linux-foundation.org, damien.lemoal@opensource.wdc.com, linux-ide@vger.kernel.org, adilger.kernel@dilger.ca, linux-ext4@vger.kernel.org, mingo@redhat.com, peterz@infradead.org, will@kernel.org, tglx@linutronix.de, rostedt@goodmis.org, joel@joelfernandes.org, sashal@kernel.org, daniel.vetter@ffwll.ch, duyuyang@gmail.com, johannes.berg@intel.com, tj@kernel.org, tytso@mit.edu, willy@infradead.org, david@fromorbit.com, amir73il@gmail.com, gregkh@linuxfoundation.org, kernel-team@lge.com, linux-mm@kvack.org, akpm@linux-foundation.org, mhocko@kernel.org, minchan@kernel.org, hannes@cmpxchg.org, vdavydov.dev@gmail.com, sj@kernel.org, jglisse@redhat.com, dennis@kernel.org, cl@linux.com, penberg@kernel.org, rientjes@google.com, vbabka@suse.cz, ngupta@vflare.org, linux-block@vger.kernel.org, josef@toxicpanda.com, linux-fsdevel@vger.kernel.org, viro@zeniv.linux.org.uk, jack@suse.cz, jlayton@kernel.org, dan.j.williams@intel.com, hch@infradead.org, djwong@kernel.org, dri-devel@lists.freedesktop.org, rodrigosiqueiramelo@gmail.com, melissa.srw@gmail.com, hamohammed.sa@gmail.com, 42.hyeyoo@gmail.com, chris.p.wilson@intel.com, gwan-gyeong.mun@intel.com, max.byungchul.park@gmail.com, boqun.feng@gmail.com, longman@redhat.com, hdanton@sina.com, her0gyugyu@gmail.com Subject: [PATCH v10 rebased on v6.4 06/25] dept: Add proc knobs to show stats and dependency graph Date: Mon, 3 Jul 2023 18:47:33 +0900 Message-Id: <20230703094752.79269-7-byungchul@sk.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230703094752.79269-1-byungchul@sk.com> References: <20230703094752.79269-1-byungchul@sk.com> X-Brightmail-Tracker: H4sIAAAAAAAAAzWSb0xTVxjGPefee+6ls+am03iVZZomZsYxFYPkFXVu84MnWzQ6xZjtw6zr je0ohbSI4LIFBzKHUpEEa6FRWk1toAK2ZCuTMgTknxFxdloVqyDqCEUWtAwE3ADjlzdP8vye 36dXYFR13GJBb8yQTUaNQU0UrGJoruMjr82pXV3vT4STx1dD9OVRFuzVHgLdVZUIPLWHMQxc 3QJ3RiMIJq7fYMBa0o3A0fuAgdrWMIK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HpetUbYCtMgsjUeRactT4C3ddrEPjq8jAM t26DX6ZHEcS6HjJgL+1GUDnQz0BdIIygsforAr1DSyAYmSDQUXqBQP6VWgI/j8xi6LtUgqFG 3QmdF90YmqJ/sGAfJlBuz8dz8SeGqMfLgyd3NQxWO3iYHUiGjvAjDlq+7eCg8cl6KPuuj8Cd xg4WAvWDGHpvOwmEff9w0BloZ6HbVsTBtXE3gZFpDwOeyAQPPU0uDDcK5mzn/nrJQVtRE4Zz V29iCD5uQHD3/G8YVN8jAi2RUQx+tZSBv6taEQwWj/FwtjDKQ3leMYILZy+x8PBFGwcFfSkQ m3GS91Jpy+gEQwv8n9HGaRdLf3JL9Jajn6cFd5/w1KWeov7qdfTKnWFMKycjHFW93xCqTpbw 1DoWxHT8wQOetl+OsXQoaMd7lh/UpBmUTGO2Yk7ckq7JqL/vJCdCm09XjCTkoh82WFGcIImb JMfoCzTfibhGCoWizHyPF9+U/EW/c1akERjx61ek6mddZH54XTwsTd1sX4BYcbVUMnkVW5Eg aMUUqdab+J9zhVRzo2kBiRM3S09nihf8ujmkryxMLiKNCy3yonijKTtLNmambLQcy8gxGU9v PHI8S0Vzl/F8OWurR1O925qRKCD9Ym3oi0qDjpOzLTlZzUgSGH28Nn+gwqDTGuSczxXz8UPm U5mKpRklCKx+qfbjA0q6Tjwqn1SOKcoJxfz/ioW4ZbkoaLOnfXggcOad/v1717e1Hip81/V+ TaKDbt0k3/vUp4/NTHqzMqye50nfjxnG3fvrbM6EhseB8Edr6zopm5a0I/2D7dGXS0t/7HHv S+t59fC+md3LB+tTn5rkhu7FUus90+U9q966L6Y+W5kdS/4kLzS0t0rHqK+ZjnrcXb/6xxxb 9KwlQ05ex5gt8r+Be7T2LgMAAA== X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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-ext4@vger.kernel.org It'd be useful to show Dept internal stats and dependency graph on runtime via proc for better information. Introduced the knobs. Signed-off-by: Byungchul Park --- kernel/dependency/Makefile | 1 + kernel/dependency/dept.c | 24 +++----- kernel/dependency/dept_internal.h | 26 +++++++++ kernel/dependency/dept_proc.c | 95 +++++++++++++++++++++++++++++++ 4 files changed, 131 insertions(+), 15 deletions(-) create mode 100644 kernel/dependency/dept_internal.h create mode 100644 kernel/dependency/dept_proc.c diff --git a/kernel/dependency/Makefile b/kernel/dependency/Makefile index b5cfb8a03c0c..92f165400187 100644 --- a/kernel/dependency/Makefile +++ b/kernel/dependency/Makefile @@ -1,3 +1,4 @@ # SPDX-License-Identifier: GPL-2.0 obj-$(CONFIG_DEPT) += dept.o +obj-$(CONFIG_DEPT) += dept_proc.o diff --git a/kernel/dependency/dept.c b/kernel/dependency/dept.c index d3b6d2f4cd7b..c5e23e9184b8 100644 --- a/kernel/dependency/dept.c +++ b/kernel/dependency/dept.c @@ -74,6 +74,7 @@ #include #include #include +#include "dept_internal.h" static int dept_stop; static int dept_per_cpu_ready; @@ -261,20 +262,13 @@ static inline bool valid_key(struct dept_key *k) * have been freed will be placed. */ -enum object_t { -#define OBJECT(id, nr) OBJECT_##id, - #include "dept_object.h" -#undef OBJECT - OBJECT_NR, -}; - #define OBJECT(id, nr) \ static struct dept_##id spool_##id[nr]; \ static DEFINE_PER_CPU(struct llist_head, lpool_##id); #include "dept_object.h" #undef OBJECT -static struct dept_pool pool[OBJECT_NR] = { +struct dept_pool dept_pool[OBJECT_NR] = { #define OBJECT(id, nr) { \ .name = #id, \ .obj_sz = sizeof(struct dept_##id), \ @@ -304,7 +298,7 @@ static void *from_pool(enum object_t t) if (DEPT_WARN_ON(!irqs_disabled())) return NULL; - p = &pool[t]; + p = &dept_pool[t]; /* * Try local pool first. @@ -339,7 +333,7 @@ static void *from_pool(enum object_t t) static void to_pool(void *o, enum object_t t) { - struct dept_pool *p = &pool[t]; + struct dept_pool *p = &dept_pool[t]; struct llist_head *h; preempt_disable(); @@ -2136,7 +2130,7 @@ void dept_map_copy(struct dept_map *to, struct dept_map *from) clean_classes_cache(&to->map_key); } -static LIST_HEAD(classes); +LIST_HEAD(dept_classes); static inline bool within(const void *addr, void *start, unsigned long size) { @@ -2168,7 +2162,7 @@ void dept_free_range(void *start, unsigned int sz) while (unlikely(!dept_lock())) cpu_relax(); - list_for_each_entry_safe(c, n, &classes, all_node) { + list_for_each_entry_safe(c, n, &dept_classes, all_node) { if (!within((void *)c->key, start, sz) && !within(c->name, start, sz)) continue; @@ -2244,7 +2238,7 @@ static struct dept_class *check_new_class(struct dept_key *local, c->sub_id = sub_id; c->key = (unsigned long)(k->base + sub_id); hash_add_class(c); - list_add(&c->all_node, &classes); + list_add(&c->all_node, &dept_classes); unlock: dept_unlock(); caching: @@ -2958,8 +2952,8 @@ static void migrate_per_cpu_pool(void) struct llist_head *from; struct llist_head *to; - from = &pool[i].boot_pool; - to = per_cpu_ptr(pool[i].lpool, boot_cpu); + from = &dept_pool[i].boot_pool; + to = per_cpu_ptr(dept_pool[i].lpool, boot_cpu); move_llist(to, from); } } diff --git a/kernel/dependency/dept_internal.h b/kernel/dependency/dept_internal.h new file mode 100644 index 000000000000..007c1eec6bab --- /dev/null +++ b/kernel/dependency/dept_internal.h @@ -0,0 +1,26 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Dept(DEPendency Tracker) - runtime dependency tracker internal header + * + * Started by Byungchul Park : + * + * Copyright (c) 2020 LG Electronics, Inc., Byungchul Park + */ + +#ifndef __DEPT_INTERNAL_H +#define __DEPT_INTERNAL_H + +#ifdef CONFIG_DEPT + +enum object_t { +#define OBJECT(id, nr) OBJECT_##id, + #include "dept_object.h" +#undef OBJECT + OBJECT_NR, +}; + +extern struct list_head dept_classes; +extern struct dept_pool dept_pool[]; + +#endif +#endif /* __DEPT_INTERNAL_H */ diff --git a/kernel/dependency/dept_proc.c b/kernel/dependency/dept_proc.c new file mode 100644 index 000000000000..7d61dfbc5865 --- /dev/null +++ b/kernel/dependency/dept_proc.c @@ -0,0 +1,95 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Procfs knobs for Dept(DEPendency Tracker) + * + * Started by Byungchul Park : + * + * Copyright (C) 2021 LG Electronics, Inc. , Byungchul Park + */ +#include +#include +#include +#include "dept_internal.h" + +static void *l_next(struct seq_file *m, void *v, loff_t *pos) +{ + /* + * XXX: Serialize list traversal if needed. The following might + * give a wrong information on contention. + */ + return seq_list_next(v, &dept_classes, pos); +} + +static void *l_start(struct seq_file *m, loff_t *pos) +{ + /* + * XXX: Serialize list traversal if needed. The following might + * give a wrong information on contention. + */ + return seq_list_start_head(&dept_classes, *pos); +} + +static void l_stop(struct seq_file *m, void *v) +{ +} + +static int l_show(struct seq_file *m, void *v) +{ + struct dept_class *fc = list_entry(v, struct dept_class, all_node); + struct dept_dep *d; + const char *prefix; + + if (v == &dept_classes) { + seq_puts(m, "All classes:\n\n"); + return 0; + } + + prefix = fc->sched_map ? " " : ""; + seq_printf(m, "[%p] %s%s\n", (void *)fc->key, prefix, fc->name); + + /* + * XXX: Serialize list traversal if needed. The following might + * give a wrong information on contention. + */ + list_for_each_entry(d, &fc->dep_head, dep_node) { + struct dept_class *tc = d->wait->class; + + prefix = tc->sched_map ? " " : ""; + seq_printf(m, " -> [%p] %s%s\n", (void *)tc->key, prefix, tc->name); + } + seq_puts(m, "\n"); + + return 0; +} + +static const struct seq_operations dept_deps_ops = { + .start = l_start, + .next = l_next, + .stop = l_stop, + .show = l_show, +}; + +static int dept_stats_show(struct seq_file *m, void *v) +{ + int r; + + seq_puts(m, "Availability in the static pools:\n\n"); +#define OBJECT(id, nr) \ + r = atomic_read(&dept_pool[OBJECT_##id].obj_nr); \ + if (r < 0) \ + r = 0; \ + seq_printf(m, "%s\t%d/%d(%d%%)\n", #id, r, nr, (r * 100) / (nr)); + #include "dept_object.h" +#undef OBJECT + + return 0; +} + +static int __init dept_proc_init(void) +{ + proc_create_seq("dept_deps", S_IRUSR, NULL, &dept_deps_ops); + proc_create_single("dept_stats", S_IRUSR, NULL, dept_stats_show); + return 0; +} + +__initcall(dept_proc_init); -- 2.17.1