Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp5660926rwl; Sun, 8 Jan 2023 20:08:18 -0800 (PST) X-Google-Smtp-Source: AMrXdXtVlJCL5fWjMPh6tr6RIk6Q/zmyv5gblfRvfqcrPlZcThse2LD1gATrBgbtBidBKBHGR6Qx X-Received: by 2002:a17:90a:ee86:b0:226:b627:6779 with SMTP id i6-20020a17090aee8600b00226b6276779mr18390418pjz.5.1673237298396; Sun, 08 Jan 2023 20:08:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673237298; cv=none; d=google.com; s=arc-20160816; b=gwc7EfKsnJIC0m+Ktpg2qUwSFCj9qWs4vAm4qLsXMPz3b2xOIADD0IS8i/LwpdbLfl hn+eLRdk6FY8Kf/lXyBZuNaM8mihwfICzVI9LW9WXYdg8fRMP2ieVuXgRqqFU+n0ifHN ASLNH4qGqN52Cvs8YR5bDPc7/jiV9qOgNj1v99imZPtmkvaO77toc0AbfIDMNwJbeyZT iN2ZFLotDbS8HcWoxWz/uS0mDCziWlc2DWAlKQf/WDn94SvW01dSrzEbUDQyUdJlH9Sa CKeoHO6z12SQwYktVukzIXHijz7VEOVHKO5Mlj8Uwt1JnQnsbztKX+d00rlCuEyYrmlJ qbkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=0aa0zM27ZT7ResDt6p2Fq08ChJ+6Fvt37GNzB+rmyQE=; b=YjUK4/m+eFxxwXf3SEa7k1QCs/iVqGgY9eqlaMtfqormwFNog7c8WJ+D3aYIy8LewH 6lJC6/mewPR5yBjpJdeS2wi0rPL423FMdxaIUu2TU1fkMR8G3qyPUJSLv/bdqWvhf59f oRxGLPvP0WcrhKycPm5oZfNe736pGD/2bioVoPUY2AgV3mF4iqOQxhYzfIGnNuMiol2w LWZfpsfCGOTkQxaiULrWsF2EhxWTpvyxg4OOCyROPDsMAczlu7wteMCRPBmS959+hOHB aSBWW3dtw+yUyaoj1M8/Ont9MbunkV5ncuZllb0bftv7jcIwU6K5iWpeqew/0RVuARx6 m1tA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o44-20020a17090a0a2f00b002266f608cf8si11271817pjo.125.2023.01.08.20.08.02; Sun, 08 Jan 2023 20:08:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236407AbjAIEEc (ORCPT + 99 others); Sun, 8 Jan 2023 23:04:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54744 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236442AbjAIEED (ORCPT ); Sun, 8 Jan 2023 23:04:03 -0500 Received: from lgeamrelo11.lge.com (lgeamrelo13.lge.com [156.147.23.53]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 59E311181F for ; Sun, 8 Jan 2023 20:03:52 -0800 (PST) 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-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-ext4@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 | 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 */ -- 1.9.1