From patchwork Mon Jun 26 11:56:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Byungchul Park X-Patchwork-Id: 13292831 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 51956EB64DC for ; Mon, 26 Jun 2023 12:23:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231130AbjFZMXD (ORCPT ); Mon, 26 Jun 2023 08:23:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230192AbjFZMWr (ORCPT ); Mon, 26 Jun 2023 08:22:47 -0400 Received: from invmail4.hynix.com (exvmail4.hynix.com [166.125.252.92]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D76612D79; Mon, 26 Jun 2023 05:21:06 -0700 (PDT) X-AuditID: a67dfc5b-d85ff70000001748-17-64997d6e5ce2 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, paolo.valente@linaro.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 23/25] dept: Record the latest one out of consecutive waits of the same class Date: Mon, 26 Jun 2023 20:56:58 +0900 Message-Id: <20230626115700.13873-24-byungchul@sk.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230626115700.13873-1-byungchul@sk.com> References: <20230626115700.13873-1-byungchul@sk.com> X-Brightmail-Tracker: H4sIAAAAAAAAAzWSa0hTYRjHe8/lPWfLyWHdThcqBhEVlXZ9oIj8EL0QURBR2Ie22kFXOmuW aRRYWth0lpJOTcpLLfGSNosuOllWpmWlqdNiWdnFtKlhznRbly3py8OP//95fp8enlbWsbN4 nf6IZNBrolRYzsgHggqX6k/makOqXDMgIy0E3CMpDORXlmNouVGGoPzWKQr6Hm+GzlEXAu/z lzSYs1oQFH54S8Othm4EtpLTGNo+BUO7ewhDU1YqhqTiSgyt33wUOLMzKSizboVnF4oosI/3 MmDuw3DJnET5x1cKxi2lHFgSF0BPSR4Hvg+h0NTtYMH2ZgnkXnZiqLU1MdBwt4eCtvv5GLrL /7DwrKGRgZYMEwsVg0UYvo1aaLC4hzh4ZS+goCrZL+r32Sg4++M3C09Mdj9dvUlB++saBHUp 7ymwljswPHS7KKi2ZtHguf4YQU/6AAdn0sY5uHQqHUHqmWwGXv56wkKyczV4x/LxxnXkoWuI JsnVx4httIAhT4tEci/vL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sD6aeGGDiXkoXgZHoeCU9+NVKQ5gqDkZ/F9Mpwob7P TQhpVfsE+6CJFB6aeeFO0StGSKt9yQgm216hqixQKK3pxULJgIcSbOWZtGAbOMMIhi9OLLg6 amihv7WVEZoKRsgNM7ZIw1VinDpJ1C5aHiWN+VBcQO3+MX6/8WktqUftEgOSsDy3mO8ZNmAf 09x8vrNziPCxPxfAVxk/UAYkZQmudDzf03SfMSCWncQp+bPuBN8Pyc3lK0s7kK+WcUt417VV /5SzeGtl3V+NxFtXPzIjH8u5MP6Yy0FnI6kJjStH/ur4JI1SHRcWrIuNSY5X7w/ekaCxIe9u LIdHc26j7+2RDsSxSDFBFjKzQCWnlEm6ZI0D8Syh8JdN/pmvkstUyuQDojZhu3ZvnKhzoOks qZgiW7tZjJJz0cpEMVYUd4va/1fMSqbpUezl00GujfMCLm1fmtsTYNfPOc7fjFrgrJfUpLQE XwkcHjP5rdjkMK+bmKhfvbMxepdk/td3+MhU/fCqkg3ZR4x7Ln4svKoJjzm0JvFgbeTsQEV/ Z9bR68Gh807cu+O6GzGhwW1C2yLSX2/J3GolWvdt6l5kUY85Dffzipb/sE40TJmqIHUxytBA QqtT/gH3/dofMwMAAA== X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org The current code records all the waits for later use to track relation between waits and events in each context. However, since the same class is handled the same way, it'd be okay to record only one on behalf of the others if they all have the same class. Even though it's the ideal to search the whole history buffer for that, since it'd cost too high, alternatively, let's keep the latest one at least when the same class'ed waits consecutively appear. Signed-off-by: Byungchul Park --- kernel/dependency/dept.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/kernel/dependency/dept.c b/kernel/dependency/dept.c index 52537c099b68..cdfda4acff58 100644 --- a/kernel/dependency/dept.c +++ b/kernel/dependency/dept.c @@ -1522,9 +1522,28 @@ static inline struct dept_wait_hist *new_hist(void) return wh; } +static inline struct dept_wait_hist *last_hist(void) +{ + int pos_n = hist_pos_next(); + struct dept_wait_hist *wh_n = hist(pos_n); + + /* + * This is the first try. + */ + if (!pos_n && !wh_n->wait) + return NULL; + + return hist(pos_n + DEPT_MAX_WAIT_HIST - 1); +} + static void add_hist(struct dept_wait *w, unsigned int wg, unsigned int ctxt_id) { - struct dept_wait_hist *wh = new_hist(); + struct dept_wait_hist *wh; + + wh = last_hist(); + + if (!wh || wh->wait->class != w->class || wh->ctxt_id != ctxt_id) + wh = new_hist(); if (likely(wh->wait)) put_wait(wh->wait);