From patchwork Fri Mar 4 07:06:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Byungchul Park X-Patchwork-Id: 12768600 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 AD52AC433FE for ; Fri, 4 Mar 2022 07:07:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 884B68D0012; Fri, 4 Mar 2022 02:07:14 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0217C8D0017; Fri, 4 Mar 2022 02:07:13 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 57A5D8D0006; Fri, 4 Mar 2022 02:07:13 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0193.hostedemail.com [216.40.44.193]) by kanga.kvack.org (Postfix) with ESMTP id 9173E8D0006 for ; Fri, 4 Mar 2022 02:07:11 -0500 (EST) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 760D6181C49A2 for ; Fri, 4 Mar 2022 07:07:10 +0000 (UTC) X-FDA: 79205822220.26.581CC68 Received: from lgeamrelo11.lge.com (lgeamrelo13.lge.com [156.147.23.53]) by imf04.hostedemail.com (Postfix) with ESMTP id 8584840009 for ; Fri, 4 Mar 2022 07:07:09 +0000 (UTC) Received: from unknown (HELO lgemrelse6q.lge.com) (156.147.1.121) by 156.147.23.53 with ESMTP; 4 Mar 2022 16:07:08 +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; 4 Mar 2022 16:07:08 +0900 X-Original-SENDERIP: 10.177.244.38 X-Original-MAILFROM: byungchul.park@lge.com From: Byungchul Park To: torvalds@linux-foundation.org Cc: damien.lemoal@opensource.wdc.com, linux-ide@vger.kernel.org, adilger.kernel@dilger.ca, linux-ext4@vger.kernel.org, mingo@redhat.com, linux-kernel@vger.kernel.org, peterz@infradead.org, will@kernel.org, tglx@linutronix.de, rostedt@goodmis.org, joel@joelfernandes.org, sashal@kernel.org, daniel.vetter@ffwll.ch, chris@chris-wilson.co.uk, duyuyang@gmail.com, johannes.berg@intel.com, tj@kernel.org, tytso@mit.edu, willy@infradead.org, david@fromorbit.com, amir73il@gmail.com, bfields@fieldses.org, 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, jack@suse.com, jlayton@kernel.org, dan.j.williams@intel.com, hch@infradead.org, djwong@kernel.org, dri-devel@lists.freedesktop.org, airlied@linux.ie, rodrigosiqueiramelo@gmail.com, melissa.srw@gmail.com, hamohammed.sa@gmail.com Subject: [PATCH v4 15/24] dept: Apply SDT to wait(waitqueue) Date: Fri, 4 Mar 2022 16:06:34 +0900 Message-Id: <1646377603-19730-16-git-send-email-byungchul.park@lge.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1646377603-19730-1-git-send-email-byungchul.park@lge.com> References: <1646377603-19730-1-git-send-email-byungchul.park@lge.com> X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 8584840009 X-Stat-Signature: hx13kqhpts9a3gqzxehjigmkdrfaywc9 Authentication-Results: imf04.hostedemail.com; dkim=none; spf=pass (imf04.hostedemail.com: domain of byungchul.park@lge.com designates 156.147.23.53 as permitted sender) smtp.mailfrom=byungchul.park@lge.com; dmarc=none X-HE-Tag: 1646377629-116213 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: Makes SDT able to track dependencies by wait(waitqueue). Signed-off-by: Byungchul Park --- include/linux/wait.h | 6 +++++- kernel/sched/wait.c | 16 ++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/include/linux/wait.h b/include/linux/wait.h index 851e07d..2133998 100644 --- a/include/linux/wait.h +++ b/include/linux/wait.h @@ -7,6 +7,7 @@ #include #include #include +#include #include #include @@ -37,6 +38,7 @@ struct wait_queue_entry { struct wait_queue_head { spinlock_t lock; struct list_head head; + struct dept_map dmap; }; typedef struct wait_queue_head wait_queue_head_t; @@ -56,7 +58,8 @@ struct wait_queue_head { #define __WAIT_QUEUE_HEAD_INITIALIZER(name) { \ .lock = __SPIN_LOCK_UNLOCKED(name.lock), \ - .head = LIST_HEAD_INIT(name.head) } + .head = LIST_HEAD_INIT(name.head), \ + .dmap = DEPT_SDT_MAP_INIT(name) } #define DECLARE_WAIT_QUEUE_HEAD(name) \ struct wait_queue_head name = __WAIT_QUEUE_HEAD_INITIALIZER(name) @@ -67,6 +70,7 @@ struct wait_queue_head { do { \ static struct lock_class_key __key; \ \ + sdt_map_init(&(wq_head)->dmap); \ __init_waitqueue_head((wq_head), #wq_head, &__key); \ } while (0) diff --git a/kernel/sched/wait.c b/kernel/sched/wait.c index eca3810..fc5a16a 100644 --- a/kernel/sched/wait.c +++ b/kernel/sched/wait.c @@ -105,6 +105,7 @@ static int __wake_up_common(struct wait_queue_head *wq_head, unsigned int mode, if (flags & WQ_FLAG_BOOKMARK) continue; + sdt_event(&wq_head->dmap); ret = curr->func(curr, mode, wake_flags, key); if (ret < 0) break; @@ -268,6 +269,9 @@ void __wake_up_pollfree(struct wait_queue_head *wq_head) __add_wait_queue(wq_head, wq_entry); set_current_state(state); spin_unlock_irqrestore(&wq_head->lock, flags); + + if (state & TASK_NORMAL) + sdt_wait_prepare(&wq_head->dmap); } EXPORT_SYMBOL(prepare_to_wait); @@ -286,6 +290,10 @@ void __wake_up_pollfree(struct wait_queue_head *wq_head) } set_current_state(state); spin_unlock_irqrestore(&wq_head->lock, flags); + + if (state & TASK_NORMAL) + sdt_wait_prepare(&wq_head->dmap); + return was_empty; } EXPORT_SYMBOL(prepare_to_wait_exclusive); @@ -331,6 +339,9 @@ long prepare_to_wait_event(struct wait_queue_head *wq_head, struct wait_queue_en } spin_unlock_irqrestore(&wq_head->lock, flags); + if (!ret && state & TASK_NORMAL) + sdt_wait_prepare(&wq_head->dmap); + return ret; } EXPORT_SYMBOL(prepare_to_wait_event); @@ -352,7 +363,9 @@ int do_wait_intr(wait_queue_head_t *wq, wait_queue_entry_t *wait) return -ERESTARTSYS; spin_unlock(&wq->lock); + sdt_wait_prepare(&wq->dmap); schedule(); + sdt_wait_finish(); spin_lock(&wq->lock); return 0; @@ -369,7 +382,9 @@ int do_wait_intr_irq(wait_queue_head_t *wq, wait_queue_entry_t *wait) return -ERESTARTSYS; spin_unlock_irq(&wq->lock); + sdt_wait_prepare(&wq->dmap); schedule(); + sdt_wait_finish(); spin_lock_irq(&wq->lock); return 0; @@ -389,6 +404,7 @@ void finish_wait(struct wait_queue_head *wq_head, struct wait_queue_entry *wq_en { unsigned long flags; + sdt_wait_finish(); __set_current_state(TASK_RUNNING); /* * We can check for list emptiness outside the lock