From patchwork Wed May 8 09:47:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Byungchul Park X-Patchwork-Id: 13658321 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 03849C04FFE for ; Wed, 8 May 2024 09:47:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 77FF96B00D3; Wed, 8 May 2024 05:47:45 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 724366B00D5; Wed, 8 May 2024 05:47:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 59D4B6B00D4; Wed, 8 May 2024 05:47:45 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 3B7816B00D2 for ; Wed, 8 May 2024 05:47:45 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id D466B12144D for ; Wed, 8 May 2024 09:47:44 +0000 (UTC) X-FDA: 82094751648.10.42D1868 Received: from invmail4.hynix.com (exvmail4.hynix.com [166.125.252.92]) by imf17.hostedemail.com (Postfix) with ESMTP id 1882340013 for ; Wed, 8 May 2024 09:47:40 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf17.hostedemail.com: domain of byungchul@sk.com designates 166.125.252.92 as permitted sender) smtp.mailfrom=byungchul@sk.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1715161663; 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=BcbuW6j4Ej+hM7Kcf16wALY98oaIMNkWh5zceqBk1DTVydRptq1/aME6q0L9C0eEiHrxm0 XXN6Fh2RLKNfg1vqWVbK6GIz/87b5PcV06EAhYY31Dpi438xsBDJvpgOzjHCj/RB9WTjvG aXfnFY5hOMfGSVjqhCs+mD4lNPEbxVg= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf17.hostedemail.com: domain of byungchul@sk.com designates 166.125.252.92 as permitted sender) smtp.mailfrom=byungchul@sk.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1715161663; a=rsa-sha256; cv=none; b=Ds0rG46pLo/DbLAmq9LoAq6/Zb+YpaGQYHGnAaxk3LRUC2b/8AT2s0ermtYTOnu5lsHmgv qlINW7OLzLOmbYxHxuuHI/+XxGcC9i7DtVnZMzIMqCrZwKsBfrJm2xBLgbwpa/HQQ+nQKk UWSxx3tjGINz4UHD4eiGy72YpMZr1Jc= X-AuditID: a67dfc5b-d85ff70000001748-45-663b4a3836b1 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, 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 v14 03/28] dept: Add single event dependency tracker APIs Date: Wed, 8 May 2024 18:47:00 +0900 Message-Id: <20240508094726.35754-4-byungchul@sk.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240508094726.35754-1-byungchul@sk.com> References: <20240508094726.35754-1-byungchul@sk.com> X-Brightmail-Tracker: H4sIAAAAAAAAAzWSbUxTZxTH9zz3lTs6r5XIFT64dFETDSoG9PgSs8RE74y6RY0f9ANWe7HV gloERWMCUhgW0WrEbpUpINYGqmBrjC+AtaQoELFqVTCUCKljjVC02moFpwXjl5Nfzvn/f58O S8gdVBKryd4n6bKVWgXNkdxwfHXK4tVLM+dfHOXg5LH5EH5fSkJlg40Gz5V6BLZrhRgC7lXw PDKEYPTBQwJMFR4E1f0+Aq619SFoth6h4Yn/J/CGR2horyijoehCAw2PXo9h6D1zCkO9fS10 GmswOKODJJgCNJw1FeHY+A9D1FLHgKVgBgxYzQyM9adCe98zCppfzIG/z/XS0NTcTkLbjQEM T25V0tBn+0JBZ9t9Ejwnyym4HKyh4XXEQoAlPMLAY2cVhkZ9TFTy7n8K7pU7MZTUXsXg7bmN oKX0JQa77RkNreEhDA57BQGfLrkRDBwfZqD4WJSBs4XHEZQVnyFB35sOox8r6V8Xi61DI4So d+wXmyNVpNhRI4g3zT5G1Le8YMQqe67osM4WLzQFsFgdClOive4oLdpD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AoaZ1EgtVXxyUYKzLpQXjl/OMkPfRgoWp3l5G6LowQwrj Fh3e5b9PsjZajFemiOrg9Qclse2FpdTRAb/jTl1ABrLI8pAXy3Oh/Ge9gfAwzS3lBwddf9mX W8Q3FryjPExwdgl/uTfSwz7cNv5FwycmD7EsyS3mrYU+nljKhfG2kR78TxnA1zeY/mq8uNW8 dWIKeVg2u7mnLWUKkaQSzalDvkpVSoJCGR8WpImLTVUpjwcdSkwwotln0ae7i1rQt/6t7Yhj kXyutI+OiJFRihRNakI74llC7ivtPLMmRiaNVqSeENWJB9TJ8aKmHfmzpNxPun2PeFDGHVYk iXGieFRU/28x67UwA+2TOVOhaUVGy25r8o7DEYMtFa+cri0ynb8k3b3Otlb6uOzW5qr5reb1 u3NfaJWbUqrqLHRIbqItMHf/kYAN7gfRzeFBWwzWS2yFd7B3GsoPDm2+ElewyGEPjEyf9yZ8 geL2yZ+R3hO39pY8cS9JOyBvjqqGZa2rxNdvs0wq81iUnNTEKkICCbVG8QdySKOkKAMAAA== X-CFilter-Loop: Reflected X-Rspamd-Server: rspam01 X-Stat-Signature: bpn3m8jrjbuothma6wsz58m5jdr9f6ks X-Rspam-User: X-Rspamd-Queue-Id: 1882340013 X-HE-Tag: 1715161660-282068 X-HE-Meta: U2FsdGVkX1+A/rnSWeKVKWin2tTolFTqGkcj1eQseJSzORsu5PDeBpsqapLmV8GVRMYE7N5gjrpcbHjWCE79EEepdstNGYAyN6rNNaDUEjKSd8uknPGoevaAUAMag06V+lQinj+XzFsZgvgwV/KBmrw5oR7YU0TJWP+dIUsdsJm4CackGLugzDBeXlF/FA3y8x6mhdTCgeCOt8I6cc3pen7GAhoCgtMzO3o3FFwYDyagg8tM2drv76mRJJNG1tG1i0//B2kMqgMYKak3J3wLHhcwQJus3uL8ycV8GPnQ8oPbbOfbiSJ7rhipCTAa3yhL4Ri37rMxXreZWaeUqU/ViiwYzrpfrCu+RgwdxIvz0nkrznWVjNVYE+yd3xzeJigRN37Sb64U05aWtzHf5HSGyJp3RmUDLZtA4YsF9dfSk2cjxEJFsPHYDb8xBypASfc4Xe4G5uk3qlwzHawDUJKp/2IDW0JO7l0Iax0Jw9DsUX3LeNe17fiNGX7FnM4nLp8Ock/qnWQ5zGd2l/QIqbSgRS7mGVtNmBOaALUqbuPn0If6xgMZi6FzD/n52QTLm6O9Tl0HD3OxB0LF2Htdi29EMlXwxo+v52Qk1+qehz2eCDo+41GDQZCmWwIvU52oQjBL/jYfueQjeGHbA2FPoFZZZw2B1trFqf/eqBNuL8/TL5EHzwNcYALl9q3qQ61udrK8RZ/5ShrylU647QTSLDqxqQZIp4OMOQvo1PGSzdo9dJondKsUeFxeLT52W4SW6ani/O/vsrQ31/dtQdNvfq08QTg1GIBtie+5HYc+zEbuKS3qUIYW5LmG12G796W66qmsL4ak7WgK41kY/wLCVq5/7LKhL6ijbleVDqNmv9/Jcdekqy7/7uKspEVinVJFrBVf19o1aupk9LfKCXsFSa/seRR95Dag1UYTBHDifunhYiwXy/5WnCLHDZO6c4w/zl7CLvqJgjfEf5IQyxLuQcN DljJ2ZWC hvKSb/0L2TesyFweWM4ZTj/xaE9+fu+JgdnkQAALp7By6DxLlqSbTRvSR9IN72Z3mR48zd7TPK8ZlQWuc6wlys2UbPA== 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 */