From patchwork Mon Jan 9 03:33:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Byungchul Park X-Patchwork-Id: 13092891 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 18443C61DB3 for ; Mon, 9 Jan 2023 03:34:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 19DDF8E0003; Sun, 8 Jan 2023 22:33:59 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id EA387940009; Sun, 8 Jan 2023 22:33:58 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 59FB7900012; Sun, 8 Jan 2023 22:33:58 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 5F6EC900002 for ; Sun, 8 Jan 2023 22:33:57 -0500 (EST) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id D185C1A014D for ; Mon, 9 Jan 2023 03:33:56 +0000 (UTC) X-FDA: 80333841672.12.F625D30 Received: from lgeamrelo11.lge.com (lgeamrelo13.lge.com [156.147.23.53]) by imf25.hostedemail.com (Postfix) with ESMTP id 49311A0003 for ; Mon, 9 Jan 2023 03:33:53 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf25.hostedemail.com: domain of byungchul.park@lge.com designates 156.147.23.53 as permitted sender) smtp.mailfrom=byungchul.park@lge.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1673235235; 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=0aa0zM27ZT7ResDt6p2Fq08ChJ+6Fvt37GNzB+rmyQE=; b=H9Vib3kpXaiiK51c08PtJ/Y9uFtIBA6eHB3+lItKWmjKXjGxRQDCpnGd3Ipubm4dA67W36 tKRCxPRxEpnhFe8mw8rHgVSy8JQOSEpTSIJ1gBc49lGeOHg1zF4BhgNFNUylu8pDj28gyp aEnJm8r8KvgBC5IaQEEAXxF+5/w6Ntg= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf25.hostedemail.com: domain of byungchul.park@lge.com designates 156.147.23.53 as permitted sender) smtp.mailfrom=byungchul.park@lge.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1673235235; a=rsa-sha256; cv=none; b=kQIepwm/FI3G/fsNrCKWQktUGKhkHj2AsDG3PMeX2OH+Bz+hLC5+S0E5ynPWQZMQ6LhYUr NvV61+3ykA9mcxN/C3RI41mldhJQ3v0ebpVKGU2TsSV1AA6tfb9SMSjihZxluAt1QYkJYR g8h2yI4AuNYvpyu30Ba0mZkrOgVXiuc= Received: from unknown (HELO lgemrelse6q.lge.com) (156.147.1.121) by 156.147.23.53 with ESMTP; 9 Jan 2023 12:33:51 +0900 X-Original-SENDERIP: 156.147.1.121 X-Original-MAILFROM: byungchul.park@lge.com Received: from unknown (HELO localhost.localdomain) (10.177.244.38) by 156.147.1.121 with ESMTP; 9 Jan 2023 12:33:51 +0900 X-Original-SENDERIP: 10.177.244.38 X-Original-MAILFROM: byungchul.park@lge.com From: Byungchul Park To: linux-kernel@vger.kernel.org Cc: 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 Subject: [PATCH RFC v7 03/23] dept: Add single event dependency tracker APIs Date: Mon, 9 Jan 2023 12:33:31 +0900 Message-Id: <1673235231-30302-4-git-send-email-byungchul.park@lge.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1673235231-30302-1-git-send-email-byungchul.park@lge.com> References: <1673235231-30302-1-git-send-email-byungchul.park@lge.com> X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 49311A0003 X-Rspam-User: X-Stat-Signature: xbro7p895oz14pz1zr6hiomsrzw5gd3f X-HE-Tag: 1673235233-972971 X-HE-Meta: U2FsdGVkX19yOcD1Fpjq8ZILfv6gzGP9t8CdqpkWfV429zfushU+Gk0dTVInd8KE0QoVbjFf/PHvkwN9todvKfd+6udAo33KdZ9M6eUBTktzs9SAVobR3ptI+iPpitRXFbgErbixy/6XDL+x06F2xJMAqgTZoQeLKMm4yMtRl5QG56/CONsZu7jomGejZumJiKjc1GYjc7fCtSKDI2IsSbgIuiNqECk+YoeJupOfF7VeMBj+Q5+PNbEKQt2Xyyk0N8qjwi1HH6pbf5YJSNST9fFgHTgo84mwMWE5y/A6FLak90yo/lpRLrsYJkKOc5mIUnUpd9p2sXWc+mH9GsWUkttBQMleHDJm/2jBdrLGHp26j7CCCC4O8Ichja4WyAjveP8fQVLOIEaOyAIvn4yo9YWfAjMf/yHt+nyeddbKkUt2xdgG7tug4tahigxxXvuisRISsvj5TvCLu3rS6cwMXfi8LQBdXX9lYIFKpAbIZm/9+5GVXMqGrZUJf4tGX/facFUxhD47+VWXPN2WIapXxRrT4rrnl6s43rNgriYieU7Q+TBr7/sTILJEfx095Rum25txff89TEsBCS+ArIXA4kJTJ1ukD9LRbZJONv4eGvQiJxKa7kE8c/vlpkZvKVjvU8Br1hrF28myUf0NiStKvg9jbrFk9X7M3yjiUOo6DoK/7QqkME3aFKys1XlK+GZpHnPQn9yOgz7RghAv8OlWeyxxg0UBhcGafTRjIDl5Kq25fNI0KJ05uTmdYNTM/Y7jBbU9PFf1R68D6GXTqpu+P4YFFzCLpzj316JFt8D993BQbpJp8S70beTIAupa4SwcHm4Xs7Fv5w8= 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 | 72 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 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 00000000..2644e77 --- /dev/null +++ b/include/linux/dept_sdt.h @@ -0,0 +1,72 @@ +/* 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 + +#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_strong(m) \ + do { \ + struct dept_map *__m = m; \ + static struct dept_key __key; \ + dept_stage_wait(__m, __m ? NULL : &__key, _THIS_IP_, __func__, true);\ + } while (0) + +/* + * Use the code location as the class key if an explicit map is not used. + */ +#define sdt_might_sleep_weak(m) \ + do { \ + struct dept_map *__m = m; \ + static struct dept_key __key; \ + dept_stage_wait(__m, __m ? NULL : &__key, _THIS_IP_, __func__, false);\ + } while (0) + +#define sdt_might_sleep_finish() 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_strong(m) do { } while (0) +#define sdt_might_sleep_weak(m) do { } while (0) +#define sdt_might_sleep_finish() 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 */