From patchwork Mon Aug 21 03:46:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Byungchul Park X-Patchwork-Id: 13359163 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 879DBEE49AB for ; Mon, 21 Aug 2023 04:35:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233008AbjHUEfC (ORCPT ); Mon, 21 Aug 2023 00:35:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232996AbjHUEfB (ORCPT ); Mon, 21 Aug 2023 00:35:01 -0400 Received: from invmail4.hynix.com (exvmail4.hynix.com [166.125.252.92]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 63C60B2; Sun, 20 Aug 2023 21:34:58 -0700 (PDT) X-AuditID: a67dfc5b-d6dff70000001748-1b-64e2ded4b3b0 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: [RESEND PATCH v10 03/25] dept: Add single event dependency tracker APIs Date: Mon, 21 Aug 2023 12:46:15 +0900 Message-Id: <20230821034637.34630-4-byungchul@sk.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230821034637.34630-1-byungchul@sk.com> References: <20230821034637.34630-1-byungchul@sk.com> X-Brightmail-Tracker: H4sIAAAAAAAAAzWSa0yTZxTHfZ731nbUvHkx8RGWuTUhGo0iBszJNHPZYnz2YQnJRkwciTT0 jTRycUVRXJaA1upAFEiw45INcOmagre3GC9YgzXlIgK1VmUEq1TCbCx324mgDkv8cvLL+f/P 79NRMdJ1LkFlzD8gm/L1uTpew2rG45o2+ANBw6apPwGqTm2CyKuTLDRcbOXBe6EFQWtbKYaQ Zyc8joYRzPcNMGCt8SJoGnnCQFtnAIHLfpSHB6PLwR+Z5KGnppyHY+cu8nD/5QKG4bPVGFqU 76G3shlDx9y/LFhDPNRbj+HF8QLDnM0hgK0kCYL2OgEWRlKgJ/CIA9fQeqj9Y5iHm64eFjqv BTE8uNHAQ6D1PQe9nd0seKsqODg/0czDy6iNAVtkUgBfRyOGS+ZFkWX2HQddFR0YLH9dxuD/ px3BrZPPMCitj3i4EwljcCo1DLz524MgeHpcgOOn5gSoLz2NoPz4WRYG3nZxYB5Og/nXDfzX X9I74UmGmp2HqCvayNK7zYR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L7DB0Z+ZpEtvrSqb4Ch 8ZYoWjaUy9J6o0gfZ3TyNP5pO09zzSeoJd+T3iztwfTGoJOj5oJLhJoH03ia+NmGaX9jI0/r ro2wtNtmwP7z9sk3aqRQbaSkW7MpUB5cmZLBRbx0OzlkWBiLbMpE5CIThXVi82AfmvBEWCq+ ejXMTHhXYZFoSX7PJSK5jBEuTBXzvzwjE8UswV8sybROHrCCh/i1u2UyVwg+4ouxb/gfdKFY eLdiEuQirBfNJU8m98rxzVf7OzYFyXPRlALkqg2PDFNrQ31W60OCo8O1J1cfOhZmRuM/Y4oZ TX2EvrfuqESCDKmmKQLnOTRKTh2pjw6rRKKMUbkq3H/YNUqFRh19StIdO6g7ESrpK5G7jFW5 KXbukQKVwhH1cSlEkiIk3f8Wy1zmxiKyL8gYYtnQOXM3Xem1xHet30rvpI4pNQaDyjsIx3xs mfOW9MaMLU442uJWVxqgjfLfemCGkNbZFLDfb1V5fyzOeTj4mJVCThV/Wr5sW47b6ekKj/rs Npex0jxd0O/tKeoFZ7ZXN5ZH2Y8e9tu8bE59/Z2Agb17AhOts1+veeCeZyxQsfpgtbcno9Or /wI+DQQ/LwMAAA== X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Wrapped the base APIs for easier annotation on wait and event. Start with supporting waiters on each single event. More general support for multiple events is a future work. Do more when the need arises. How to annotate (the simplest way): 1. Initaialize a map for the interesting wait. /* * Recommand to place along with the wait instance. */ struct dept_map my_wait; /* * Recommand to place in the initialization code. */ sdt_map_init(&my_wait); 2. Place the following at the wait code. sdt_wait(&my_wait); 3. Place the following at the event code. sdt_event(&my_wait); That's it! Signed-off-by: Byungchul Park --- include/linux/dept_sdt.h | 62 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 include/linux/dept_sdt.h diff --git a/include/linux/dept_sdt.h b/include/linux/dept_sdt.h new file mode 100644 index 000000000000..12a793b90c7e --- /dev/null +++ b/include/linux/dept_sdt.h @@ -0,0 +1,62 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Single-event Dependency Tracker + * + * Started by Byungchul Park : + * + * Copyright (c) 2020 LG Electronics, Inc., Byungchul Park + */ + +#ifndef __LINUX_DEPT_SDT_H +#define __LINUX_DEPT_SDT_H + +#include +#include + +#ifdef CONFIG_DEPT +#define sdt_map_init(m) \ + do { \ + static struct dept_key __key; \ + dept_map_init(m, &__key, 0, #m); \ + } while (0) + +#define sdt_map_init_key(m, k) dept_map_init(m, k, 0, #m) + +#define sdt_wait(m) \ + do { \ + dept_request_event(m); \ + dept_wait(m, 1UL, _THIS_IP_, __func__, 0); \ + } while (0) + +/* + * sdt_might_sleep() and its family will be committed in __schedule() + * when it actually gets to __schedule(). Both dept_request_event() and + * dept_wait() will be performed on the commit. + */ + +/* + * Use the code location as the class key if an explicit map is not used. + */ +#define sdt_might_sleep_start(m) \ + do { \ + struct dept_map *__m = m; \ + static struct dept_key __key; \ + dept_stage_wait(__m, __m ? NULL : &__key, _THIS_IP_, __func__);\ + } while (0) + +#define sdt_might_sleep_end() dept_clean_stage() + +#define sdt_ecxt_enter(m) dept_ecxt_enter(m, 1UL, _THIS_IP_, "start", "event", 0) +#define sdt_event(m) dept_event(m, 1UL, _THIS_IP_, __func__) +#define sdt_ecxt_exit(m) dept_ecxt_exit(m, 1UL, _THIS_IP_) +#else /* !CONFIG_DEPT */ +#define sdt_map_init(m) do { } while (0) +#define sdt_map_init_key(m, k) do { (void)(k); } while (0) +#define sdt_wait(m) do { } while (0) +#define sdt_might_sleep_start(m) do { } while (0) +#define sdt_might_sleep_end() do { } while (0) +#define sdt_ecxt_enter(m) do { } while (0) +#define sdt_event(m) do { } while (0) +#define sdt_ecxt_exit(m) do { } while (0) +#endif +#endif /* __LINUX_DEPT_SDT_H */