From patchwork Wed Jan 24 11:59:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Byungchul Park X-Patchwork-Id: 13529070 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id A78DAC46CD2 for ; Wed, 24 Jan 2024 11:59:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DF0546B0082; Wed, 24 Jan 2024 06:59:54 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DB8FE6B0088; Wed, 24 Jan 2024 06:59:54 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AE64F6B008A; Wed, 24 Jan 2024 06:59:54 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 852AB6B0082 for ; Wed, 24 Jan 2024 06:59:54 -0500 (EST) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 4FC61140133 for ; Wed, 24 Jan 2024 11:59:54 +0000 (UTC) X-FDA: 81714060708.21.E1BEA40 Received: from invmail4.hynix.com (exvmail4.hynix.com [166.125.252.92]) by imf27.hostedemail.com (Postfix) with ESMTP id 6C0EA40012 for ; Wed, 24 Jan 2024 11:59:51 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=none; spf=pass (imf27.hostedemail.com: domain of byungchul@sk.com designates 166.125.252.92 as permitted sender) smtp.mailfrom=byungchul@sk.com; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1706097592; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:in-reply-to: references:references; bh=ZnXU4oX1XIuBchFhMOWqhUh/vjN/lnC7AlZDxiu5KB0=; b=gpq8o77Cj2o+P+1ri6j+kBmla/aSHIw8XslmhkFDOMd8OyThx8NorjJCop9x6yxRcU1erd h0HBgBXm2x7l2yR6Ym1Fs1WhVmBAiDVF5JmWoSkbrF3/PA7FqcTqCCKUyGh2iyuIlYKVeY OtgQjypG6YwBTOG5Fh37YhzUCpQTuhc= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=none; spf=pass (imf27.hostedemail.com: domain of byungchul@sk.com designates 166.125.252.92 as permitted sender) smtp.mailfrom=byungchul@sk.com; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706097592; a=rsa-sha256; cv=none; b=Qaj6+EjgydR3mBSNZcDgwE8I0cvfO7/IuMVvmXuNmEhxf3r8eBUr/vo6wKKsM57EnPPf2Q sp+qk3BM81AJjSWhB69NabGloChy1ybI9I6CxK2ZHV9sgs7tB5eGJJ8jMJpmkxjHW+Hebk ryKCdbk6uuNuRmtc4rl8nmP3GVPbSQs= X-AuditID: a67dfc5b-d85ff70000001748-71-65b0fbb43154 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 v11 03/26] dept: Add single event dependency tracker APIs Date: Wed, 24 Jan 2024 20:59:14 +0900 Message-Id: <20240124115938.80132-4-byungchul@sk.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240124115938.80132-1-byungchul@sk.com> References: <20240124115938.80132-1-byungchul@sk.com> X-Brightmail-Tracker: H4sIAAAAAAAAAzWSa0iTYRTHe573ti1XL0vyLYtkEEGZmVgdIiqC6KkIKqEPSZeVLzqaU6Zp iwRLs7yVBroysamxxrzPgpoaXtjSQrNcaqKSYpk4L2hbmXaZRl8OP875nf/5ciSUwsaslai1 8aJOq9IoWRktm/Ap3vpsvloMdg1JITcrGNzfbtNQWFXOQmdlGYLyp9cxjNkPQY/HhWC+/S0F hrxOBMVDAxQ8dQwiaDDfYKFrZAU43VMstOVlspBSWsXCu/EFDP359zCUWY/Bm5wSDI1zozQY xlh4aEjB3vIVw5zJwoEpeSMMmws4WBjaDm2D3Qw09G2BB0X9LNQ3tNHgeD6MoctWyMJg+R8G 3jhaaejMzWagYrKEhXGPiQKTe4qD941GDNWp3qC02d8MvMpuxJD2uAaD82Mdgpe3P2Gwlnez 0OJ2Yai15lHw84kdwfCdCQ5uZs1x8PD6HQSZN/NpePvrFQOp/Ttg/kchu383aXFNUSS1NpE0 eIw0eV0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yIxOQhB//R4Frb/raIi1eMDMzyzG2wtXj4yTOLYk HFfYcijcmMvjlxndLI593cXiHPECLjFuxo/Khwn8cMJKY9F0m8HiRCqL40bNBB5raWFx/f0Z Cg+a9cTRdcelu/yEIJVWUG/b4ysNqErOoMM+ro6w6TdGIbM8DtlJeG4HX/5nlFlghnPhOzun yQW25zbxJYlf6DgklZDczaW88UfzorSSO8DHPytblCjOmR/qqaEWWMZ58JP11dS/0o18fnHl omPH7eQL07sW7/J5p890h01G0hy0xITsVSHaYKUqyMNNExigC1FFuJ0JDRbR/GYMV2ZTXqCp jv1ViJMgxTKZt6lIkNNKrUYXXIV4Camwl3WueSLIZX5K3UVBHXpKfSFI0FShtRJKsVp28Jjg K+f8leeFQEEIE9T/v4TEziEK1a2dsiXoLP0vM70dI+d88pyHJp97HmnyTNW+r0/TOn0Kd9r0 5YTqhNkyHDbnKd1b6rre0rt7n9jSN3D57WCvasXTn65J7/1dzjXiduO3lFVnl1xNXxejaP18 2N/RY+vEteiavuwt1pUbxNnOSFJ6uSz7tAzCfXyYNwC1l/q7dScVlCZAuX0zqdYo/wK06lAC LwMAAA== X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: 6C0EA40012 X-Rspam-User: X-Stat-Signature: w4ge78z9aojdfs4epbpe7jracbxrhjya X-Rspamd-Server: rspam01 X-HE-Tag: 1706097591-850928 X-HE-Meta: U2FsdGVkX1+oRusV564x9hPnYKGssHXr+9y26DIfUUhDejzetL5TBeohGhiGZ6554DHJv0zz84xpp0/gEj0T3414VZW0ISGWQwhCp0Q9X5+l1mf+q26C87YBwASwdznbRt0OKmQvwTDNnVl0hsczIT6QMgiirWLF/LNNXrh4csoMZ2anWSUiOk4uBhini16hRW+L16tSc4NIwUlMCPO/gkZpn/2g7fItbViYx2ZnFC5KPhllQphgzEfrdrZAAaocdCE5XhEhsGof14gSqY44NRIIRO7n7LtqugBr9zJlEQFYlZUbZkuZ4WR6rydzji+y3Iyi8pTV8/yG+jO/63/q+JxPASoCIEbbP6lkGEYlMG1rzB49itBxlpf+HjgNtUYyC/o6sYs4b/M6N0k7q5hJULzWuniuxNMBZvlBQiBHF1VBrOGm/5UUKwMMJzwX/SO9oqbkv7VGFHrzhWV7VqFGSJHWPBWMD+IgaPPmxTGpajDUgtc8K4WH2KJOjakFMpC14TCMkLa+L4E1NWkj7tCfSMp496kGGvPtetCE6sEfnGoAGOLv4BhR13eL1SDiBiUbDYuC1CB0C+bB4a49CYVOrXK09QGsb7oq9TwXfoOcO/wVz9bef4fMYCSzYkNRJfDkGAxe1ZhN/DuKMbGEcn5lnYeiuDg6FtZ5yZ0GynxrfRQnGVviK8AP3a1rRoX2roKpp6sznfGqhinlCJSOf791M/tm2DYH99x73zNSeDpCP/bu7LDB4YkPLo2U9Kn1UszMqYr5NwoGAVfZGs2uKoOfPJZt4D1amttyK1fCmxLD6XYGIzaqI1s1PoExpxw4rQ73LeSWzJvTOCriYGaXfT5O9INdxrZZ0J/uLNcmRVvhPIWPpPG31q8plgy0Xhye8Rga9/gHAb17/i7/e59m/EQ4XfJ8sghjgzEebuGrNTh2FQzmtrvqnjVzCdy19knI+IWoR2YTDu/UZMjILrrGOMy YnOzRK+X usLV+tf0n5OdQRL1wE9G2lX0V2waKDvuFE2jfMLdyyyRTrg5usSOCOp3eLr/X0YhFO2/zVO/OfYxkwe493ni89xaLOg== 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: List-Subscribe: List-Unsubscribe: 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 */