Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp1668109pxm; Fri, 4 Mar 2022 00:52:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJxO3JJLPrRDbeK7eUoQ/zqpwENTYqbhlfOldqB9miwQ4bczN5N9sM+Qw44XJ37W04lqJ74b X-Received: by 2002:a05:6a00:803:b0:4cd:ae61:ea66 with SMTP id m3-20020a056a00080300b004cdae61ea66mr42424536pfk.57.1646383929736; Fri, 04 Mar 2022 00:52:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646383929; cv=none; d=google.com; s=arc-20160816; b=qVJwP72f/i/pv1ISfUVmZ7wovgjXfx3dXWTgb+fFWch5aHdau9YAUeeqVWeLaYwUMU D+8i3HK8zfOobIfiB19iUks4pZ8Z1qa+cxqpBlkXVMUsD2Qt5mhXcA7OVIeBX00kspmz ZwjP+QO0phSmg2R8MNl6BuZv+gEdwNQIlh0dNrtJxKFMK+YXZCAkPGCxyie6bjU44YdF xCzdcX6GCAV+1iWs9NXydexu3tVP4DJ5fEqWK0lQflgqjAnvF0RckuxfIZc6kfLAXTqO ra6hSGlobtHQQhb295dYbrqdZkGLlux46szEB+WC1lGvmSblhjyw5OpeCHv8yDrSOiuT 9hzQ== 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=o98nkiODUnsnEBDshWjrP1fPe6sDjS0+ldj7C8mzEGs=; b=OL+CJ9C8+TTCbljZEF+kvO8wnnPw4ZFoj1EF7C2TwRWQFTrJVCe+VbYxwtvV8FWurP 8zRPFFSBNNWiy6YxbU8MCapeHoLYjUQOVOesg+QGGfAZBkOGP5JwwTxbn4KhSR48msej +yDA8WU8BXlGs0HuntNgUS6Crejk4N7JXL09Pxh/xIRJIlmi37eABhfMjhBs+/YfmGZ7 3OQX7T4Nt+FylDIChXgLMDFlspWOmlwN8GZeKTc29w9Ck8VAESJ5gf+JwaKh+MzQSB3n R0rH17aMzbbd4S/7x6FbZj13jCiSooMpMlmsEJY4CZST5tVawxoTNz+ITCsuGOqm7nil 9hHA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-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 s5-20020a170903214500b0015183911c8fsi3688258ple.507.2022.03.04.00.51.54; Fri, 04 Mar 2022 00:52:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238860AbiCDHKJ (ORCPT + 99 others); Fri, 4 Mar 2022 02:10:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39132 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238730AbiCDHIt (ORCPT ); Fri, 4 Mar 2022 02:08:49 -0500 Received: from lgeamrelo11.lge.com (lgeamrelo13.lge.com [156.147.23.53]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8D49218FAC1 for ; Thu, 3 Mar 2022 23:07:09 -0800 (PST) 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-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE 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-kernel@vger.kernel.org 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 -- 1.9.1