From patchwork Mon Jun 26 11:56:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Byungchul Park X-Patchwork-Id: 13292762 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 95855EB64D7 for ; Mon, 26 Jun 2023 11:58:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4AA958D0003; Mon, 26 Jun 2023 07:58:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 45AA18D0001; Mon, 26 Jun 2023 07:58:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2FAA58D0003; Mon, 26 Jun 2023 07:58:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 21B8F8D0001 for ; Mon, 26 Jun 2023 07:58:41 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id E7BF712065D for ; Mon, 26 Jun 2023 11:58:40 +0000 (UTC) X-FDA: 80944752000.05.6868548 Received: from invmail4.hynix.com (exvmail4.hynix.com [166.125.252.92]) by imf06.hostedemail.com (Postfix) with ESMTP id C6FA2180003 for ; Mon, 26 Jun 2023 11:58:37 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=none; spf=pass (imf06.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=1687780719; 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=gkWagE8Kt7Cwe+us5RDm60CiYLPbn6X/Tq+kg4hDFjMBveh29gi5kSmmYt4Pvbe8L06FuU ytBUc39+d+xRaS3F2KYklqHCce+oRVlxTfyhQ3yf7EpGOQZb3owF+5O/wrSdO4UMm8YfxZ krK7E9LHOFtaaDbT+m9H5jHuZAjxwxc= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1687780719; a=rsa-sha256; cv=none; b=w18JBUhKzNBAjo0aavOaybKyZPCn820rbU23WxMXfckuOemt+3nouYJtJdPqCB9GcRRlSX o7mrN18qsKM9mXq3SlIBI/6bSpfMZL3teOqJUNVexqeorPDIabWM5k+EH/kr7Sap3Iadzz /TXtXyk9jbkpm7lcUtpT2KlVzFUM8o8= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=none; spf=pass (imf06.hostedemail.com: domain of byungchul@sk.com designates 166.125.252.92 as permitted sender) smtp.mailfrom=byungchul@sk.com; dmarc=none X-AuditID: a67dfc5b-d85ff70000001748-b7-64997d6b4fa4 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 03/25] dept: Add single event dependency tracker APIs Date: Mon, 26 Jun 2023 20:56:38 +0900 Message-Id: <20230626115700.13873-4-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: H4sIAAAAAAAAAzWSf1CLcRzHfZ8f32eN8ZjwiKMbnZOTOD8+0Tn+4XHOHefOH/kjYw+NVSya cp0oLlESNapztZjUYrb8rCVLafJjqcu46TROUukuNpvmxwr/fO51n/fr3p9/PiJSWk+HiJQJ BwR1glwlw2JKPDBOt2Bv2kVFZG2ODM6ejgT3tywKSm4YMNivVyEw1BwloLdpHbzy9CMYfvaC BG2BHUFZ91sSapq7EFgqjmFo/zAeOtyDGGwFpzBklN/A0NbnJ8BZmE9AlWkjtObpCGjw9VCg 7cVQrM0gAuMTAT59JQP69DBwVRQx4O9eBLauThosb+bDxUtODHUWGwXNd10EtN8vwdBl+E1D a3MLBfazOTRUf9Fh6PPoSdC7Bxl42VBKgDEzUPTZbyHgxNdfNDzOaQjQ5ZsEdLyuRVCf9Y4A k6ETQ6O7nwCzqYCEH1ebELhyBxg4ftrHQPHRXASnjhdS8OLnYxoynUth2FuCV6/kG/sHST7T rOEt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DLN0OAzVpNwvtLfQgmDa9YKCoLsFB/2oDgbFENBQ8+DNCg9ybB 4kIDszMFu2bmSKy3/Ynt/kYK/93M42t1T1msvznG4kZrLra1xWJT7zSBm974aGxtP8Ng65sq Fpe+8hDYO9rL4Nn791k8WLtIHVj3qzhFIaiUWkG9ZXuGONNZUUcffxyR5zdG6ZBHWorCRDz3 E//MHUTLzHAx/JMnAXKZw7kNvK38OV2KxCKSM33FTw3eZpeDr7k9/JTLuVKiuGj+eWB4hSVc Ej/R30p9Ho3iO7odK34Yt5W/cbd55YA01CnwOpkKJG5Eq9pRuDJHmy1XqpLiNVmZ+TnKvPij x7KtKPQ45lPByh40P7zbiTgRkq2WJKyvVUhpuVaTn+1EvIiUhUvWLhgVUolCnn9SUB9LV+eq BI0TfSuiZBGSvb8IGVLud/kJIUsQjgvqLykhCovUodi0vGtLuTFzNZ0v3g6sNhlHdqSm93Tp Du3TJr7b44n9LxkVbWjTL8UdNHw83HJA67b0FqRs3FTcao2xRbYmrh3Zdj1iNmXsmyO1S7tU aTjuj/KoluiFNIf/+w9lCXeNI7c6CjcZqr5LGtcN1Zzb7BIf4q+GVxiI+tSo34p/fL3ddFJG aTLlibGkWiP/BA+c/uo0AwAA X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: C6FA2180003 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: jd6e4iazcorwgndfzcon1z76g85pxafn X-HE-Tag: 1687780717-989163 X-HE-Meta: U2FsdGVkX19sC2/FaOaHTDSk5MijRQmh65DqPInkg1UdSA2voxKkJ2m2J2+CKMnpxhtwWQklPDfFfAkm6xMmngrAZFV3ZHL5Ln0Sh8mqz6xlPa2XBvd73udToMw5tor2jzsglQA+mcoUwDcYUwNuZzWOFHWjUBf+4dleCjZFZvvqRb30UAmv9KmKsw81UAgDJy1g1O/NQEzoe8dMdBOaHS2fZnl3oa3DncUPq1NKbVNoJA2Y2orLDY9nromUjdc3+2dCKscN6K0JhDijcrLy2fWYgStoSEfM+WQN2a0ejkBF5rX1H5FXng04JYDOm7k2dZZwKVKxtqr0UsvnRjSuDflBS4d3qA18SR/dQfkisPvtTpyobWggms3VFZGapY1GEiquKA1UtrVp8vI3zDOuEArJk3OzwJ8hjfWW5xqa+jGzNwwNsuhBNgEzwnujFI4tkdHkG2GAlxwrQvvEcBy/VMlcGIwyAzPD7HQh1HCAIzHPG/qqb67p07CgJmKPeBFowat+yQJ17ADpEWsP1TsewRMpNNAF3H7quBp7K6lu7oKv1M6I85RqUctEEZedbLXskMmidiBXi4o9/ElVjHdVHIMuaEWduzDRSu/YZ7vrOE4QpTzcR7Z3nl3KFDNz+UuFOWycMSmVtJVt+A04aMZ9pZgsWSOtYs2XMg6XSEoxzcd1yR+QGnIGCWeITfVma2L2sK1KCwBJ2LUj58t6k21HrY0oUXpGU9n9yqBJiks5LCQjgMfhLYW2jFjxb3jer0JBVA4mrCpRveVZBk0IdM1LPi5Olo6I/rSV7JuPUHWn6s/nvIRdNL8adJEknZEJa30Qp/KcPUI2Iw10KsP3fqhV12IoB0COnFM1Rr2qSo+9z7jB/BBXGk5KXtecYnrh0LLLrRFWqehTtCej4FnU9Y0Y3YS5FTnmq34zPPZX//usQf6ikZq6IJbZu2RdhX0RTDfDw/wD2TivU9azALBCkkZ 0ZfA2s3O tuJuDVzh/7VHhN0bZtvwDzqltSbmZkjBoc8L1gv67IErYNhCSCCdE9tHhP6LmNOEw5SHRs+Ie0BtIPLOROARCRCy6QA== 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: 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 */