Received: by 2002:a89:288:0:b0:1f7:eeee:6653 with SMTP id j8csp83165lqh; Mon, 6 May 2024 12:00:17 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXa6w24vqfp9OdYouhiT3qFQoZjTVzZI6/ljkG3OZpMO8zxH6Hg2L1oLgWbL/arS5Z8jrs2Ol4lx697TMc7N3jQd2Ezj8SOj0XiPYbpNg== X-Google-Smtp-Source: AGHT+IHXOXo/lhsJEmj8oewPA6s5EkaZg1LMek+2ii960aW+6+xxT4l0XkBo1uQsQ8FmHjrSsGRH X-Received: by 2002:a05:6122:368b:b0:4d8:7789:dd0d with SMTP id ec11-20020a056122368b00b004d87789dd0dmr9866469vkb.15.1715022017333; Mon, 06 May 2024 12:00:17 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715022017; cv=pass; d=google.com; s=arc-20160816; b=nvoAs+QURTNU8tZMzcB2QCPpF0QBzIGm6jDea43tPYuopgXVdIUL/lCHIKfxMOQ5sR MHPqPw9Zr5J95XfEuqKpM+MqIyIRBKdt2Y4/tBISSArkCEChHVWLsk027G/xL/18Owaz IKKcQhUuG6pKEddXE4H38PFLlWXU/UATAhVeWyyNP50QlFIYVSSS2rNNAWSa36l5r2Jv CldRIWQQ2P7gCN9N1V+4J2ppTWzq0V3yc3zTeJj8F0N5TbQAPxeItrgRxvhIdmNEudwZ 614zgF1ND3TbQqeicg2sMGu1jGz/QR7sV7zK+dMAHfnHKNE9CQbagxzwbb7pnhySSL31 E2Eg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=t1YnA/Zsc4cP/hbhAnETxlNoXYIzyDi5A3TW6+oTvWk=; fh=ZwNz1elH4q2qB3ULrTSqcjmVqJptxhcFWtKuvMBRw/k=; b=E4BtVxU9LNNzqH/3CE94WbTdSdd4QowrvsjsM8+TCoQRYtNmHRlpS9FPiGFedrh2Ky b0KwzGfa52sXdVSxYpquk9uzCwLktnP9tabptcr1gYmd9otbXEp4kx9z2knL/aV4Tu3w kvNR/tLd1pcuSCi0qWUHEAxUxdR2RTRWxTQczAWLGtHBdU+gHRsDyGTq9EwoTb1/PTk5 8kIy4isMwd1AyaZDktXIlwFjhMCGrNTHO1iIDONM3vaGaHM8rimV4s7/wO/s3Sz4jIzK AuyENg5sFreJvMSPUkX//+uddVMzZEws+MxfhnehmbBW6JicfLx0fz29o41XrPiHbfn0 uPeg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@sipsolutions.net header.s=mail header.b=A921KPvg; arc=pass (i=1 spf=pass spfdomain=sipsolutions.net dkim=pass dkdomain=sipsolutions.net dmarc=pass fromdomain=sipsolutions.net); spf=pass (google.com: domain of linux-wireless+bounces-7233-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-wireless+bounces-7233-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=sipsolutions.net Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id q19-20020a05622a04d300b004367c34191fsi10135638qtx.548.2024.05.06.12.00.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 May 2024 12:00:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless+bounces-7233-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@sipsolutions.net header.s=mail header.b=A921KPvg; arc=pass (i=1 spf=pass spfdomain=sipsolutions.net dkim=pass dkdomain=sipsolutions.net dmarc=pass fromdomain=sipsolutions.net); spf=pass (google.com: domain of linux-wireless+bounces-7233-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-wireless+bounces-7233-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=sipsolutions.net Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 052D71C218CB for ; Mon, 6 May 2024 19:00:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 76A02158DC9; Mon, 6 May 2024 19:00:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sipsolutions.net header.i=@sipsolutions.net header.b="A921KPvg" X-Original-To: linux-wireless@vger.kernel.org Received: from sipsolutions.net (s3.sipsolutions.net [168.119.38.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 23E39158D96 for ; Mon, 6 May 2024 19:00:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=168.119.38.16 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715022011; cv=none; b=mS33fqJpLnY7ojOVgOEGw9nHlvbkOYZ+0pvEPwyAjayNb8RuXr/YUnLLJ9dAu2u/cwPKY+1jKuZmG7WMSvrlcgTMO9ndIOpF4LQwJkqs2PTBechZHUSprvqbCgRPrp81AB55yb8ZGWdBxiCt0ZCvki+0Synijfqzyk25KtDKSVs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715022011; c=relaxed/simple; bh=1TGk6rZZUvRjEK5RdFixJZVm2++6gzR7mVRaWq54rMA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=a74VbEhA+f5dOC3xnwjBMQq55nNNeNH5WuxrDBATR0l2Wyr1pAa5I6g65m+0Z+LOOV50IYR9s8GkiNkqq9qOGfvj4EgoCmZwy+IQyjd1Vy6ewP/TSk21WUv/TWM7IVS3lR8Jya9VEydFwAHuX8hfdaxBpS4oL18dQHOoOvw2QjQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sipsolutions.net; spf=pass smtp.mailfrom=sipsolutions.net; dkim=pass (2048-bit key) header.d=sipsolutions.net header.i=@sipsolutions.net header.b=A921KPvg; arc=none smtp.client-ip=168.119.38.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sipsolutions.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sipsolutions.net DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sipsolutions.net; s=mail; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Content-Type:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-To: Resent-Cc:Resent-Message-ID; bh=t1YnA/Zsc4cP/hbhAnETxlNoXYIzyDi5A3TW6+oTvWk=; t=1715022009; x=1716231609; b=A921KPvgf5XZ+WacIRCoW3jpGTzo+di5vWO2YtUqBVmuNdC Xg9CFQVaKLEqLJw56c6Ao3RuK3CKs/iT9DCMh9P/6iBWmxpx9nAoSOBxe5srF5DNpyNJi6tzzv8yh a3XSQZBNExNx0hWjBhRER1HY7sr1WLzsBnCi5Yf06DUTGrVXya/pxNu1TN38ShtZiDIC6JyRlD2YL 1hK0SoL9SI9LBirLtmozObQBzsZbbItsFkDU/KkvY9m585wzgO/Z6hmNIVEc5/WumROrjHONrnfl1 QFWkUeMKXAyn6KBHSjClXu72PIXAFETJEPeH8nO9PhuHzwUrkHVAU5z5m7FiiLJw==; Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.97) (envelope-from ) id 1s43ZF-0000000899m-3BGT; Mon, 06 May 2024 21:00:05 +0200 From: Johannes Berg To: linux-wireless@vger.kernel.org Cc: Johannes Berg , Miriam Rachel Korenblit , Benjamin Berg Subject: [PATCH 2/2] wifi: cfg80211: add tracing for wiphy work Date: Mon, 6 May 2024 21:00:03 +0200 Message-ID: <20240506210002.bf1840a1d22d.I4abba048c1c4017345640219cf1384a0b2288dd3@changeid> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240506210002.0b3a86a5d8d7.I5591c03223bdb95597e181de63a2eded424de34c@changeid> References: <20240506210002.0b3a86a5d8d7.I5591c03223bdb95597e181de63a2eded424de34c@changeid> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Johannes Berg Add trace events to trace when wiphy works are queued (or delayed ones scheduled), and other APIs are called. Also add an event when the worker starts, before acquiring the mutex, to be able to see potential delays due to locking. Reviewed-by: Miriam Rachel Korenblit Reviewed-by: Benjamin Berg Signed-off-by: Johannes Berg --- net/wireless/core.c | 12 +++++++ net/wireless/trace.h | 74 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 86 insertions(+) diff --git a/net/wireless/core.c b/net/wireless/core.c index 4b1f45e3070e..820c0ae610e3 100644 --- a/net/wireless/core.c +++ b/net/wireless/core.c @@ -421,6 +421,8 @@ static void cfg80211_wiphy_work(struct work_struct *work) rdev = container_of(work, struct cfg80211_registered_device, wiphy_work); + trace_wiphy_work_worker_start(&rdev->wiphy); + wiphy_lock(&rdev->wiphy); if (rdev->suspended) goto out; @@ -434,6 +436,7 @@ static void cfg80211_wiphy_work(struct work_struct *work) queue_work(system_unbound_wq, work); spin_unlock_irq(&rdev->wiphy_work_lock); + trace_wiphy_work_run(&rdev->wiphy, wk); wk->func(&rdev->wiphy, wk); } else { spin_unlock_irq(&rdev->wiphy_work_lock); @@ -1066,6 +1069,7 @@ void cfg80211_process_wiphy_works(struct cfg80211_registered_device *rdev, list_del_init(&wk->entry); spin_unlock_irqrestore(&rdev->wiphy_work_lock, flags); + trace_wiphy_work_run(&rdev->wiphy, wk); wk->func(&rdev->wiphy, wk); spin_lock_irqsave(&rdev->wiphy_work_lock, flags); @@ -1610,6 +1614,8 @@ void wiphy_work_queue(struct wiphy *wiphy, struct wiphy_work *work) struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy); unsigned long flags; + trace_wiphy_work_queue(wiphy, work); + spin_lock_irqsave(&rdev->wiphy_work_lock, flags); if (list_empty(&work->entry)) list_add_tail(&work->entry, &rdev->wiphy_work_list); @@ -1626,6 +1632,8 @@ void wiphy_work_cancel(struct wiphy *wiphy, struct wiphy_work *work) lockdep_assert_held(&wiphy->mtx); + trace_wiphy_work_cancel(wiphy, work); + spin_lock_irqsave(&rdev->wiphy_work_lock, flags); if (!list_empty(&work->entry)) list_del_init(&work->entry); @@ -1639,6 +1647,8 @@ void wiphy_work_flush(struct wiphy *wiphy, struct wiphy_work *work) unsigned long flags; bool run; + trace_wiphy_work_flush(wiphy, work); + spin_lock_irqsave(&rdev->wiphy_work_lock, flags); run = !work || !list_empty(&work->entry); spin_unlock_irqrestore(&rdev->wiphy_work_lock, flags); @@ -1660,6 +1670,8 @@ void wiphy_delayed_work_queue(struct wiphy *wiphy, struct wiphy_delayed_work *dwork, unsigned long delay) { + trace_wiphy_delayed_work_queue(wiphy, &dwork->work, delay); + if (!delay) { del_timer(&dwork->timer); wiphy_work_queue(wiphy, &dwork->work); diff --git a/net/wireless/trace.h b/net/wireless/trace.h index b76e3b21051a..14cfa0aba93a 100644 --- a/net/wireless/trace.h +++ b/net/wireless/trace.h @@ -242,6 +242,80 @@ } \ } while (0) +/************************************************************* + * wiphy work traces * + *************************************************************/ + +DECLARE_EVENT_CLASS(wiphy_work_event, + TP_PROTO(struct wiphy *wiphy, struct wiphy_work *work), + TP_ARGS(wiphy, work), + TP_STRUCT__entry( + WIPHY_ENTRY + __field(void *, instance) + __field(void *, func) + ), + TP_fast_assign( + WIPHY_ASSIGN; + __entry->instance = work; + __entry->func = work ? work->func : NULL; + ), + TP_printk(WIPHY_PR_FMT " instance=%p func=%pS", + WIPHY_PR_ARG, __entry->instance, __entry->func) +); + +DEFINE_EVENT(wiphy_work_event, wiphy_work_queue, + TP_PROTO(struct wiphy *wiphy, struct wiphy_work *work), + TP_ARGS(wiphy, work) +); + +DEFINE_EVENT(wiphy_work_event, wiphy_work_run, + TP_PROTO(struct wiphy *wiphy, struct wiphy_work *work), + TP_ARGS(wiphy, work) +); + +DEFINE_EVENT(wiphy_work_event, wiphy_work_cancel, + TP_PROTO(struct wiphy *wiphy, struct wiphy_work *work), + TP_ARGS(wiphy, work) +); + +DEFINE_EVENT(wiphy_work_event, wiphy_work_flush, + TP_PROTO(struct wiphy *wiphy, struct wiphy_work *work), + TP_ARGS(wiphy, work) +); + +TRACE_EVENT(wiphy_delayed_work_queue, + TP_PROTO(struct wiphy *wiphy, struct wiphy_work *work, + unsigned long delay), + TP_ARGS(wiphy, work, delay), + TP_STRUCT__entry( + WIPHY_ENTRY + __field(void *, instance) + __field(void *, func) + __field(unsigned long, delay) + ), + TP_fast_assign( + WIPHY_ASSIGN; + __entry->instance = work; + __entry->func = work->func; + __entry->delay = delay; + ), + TP_printk(WIPHY_PR_FMT " instance=%p func=%pS delay=%ld", + WIPHY_PR_ARG, __entry->instance, __entry->func, + __entry->delay) +); + +TRACE_EVENT(wiphy_work_worker_start, + TP_PROTO(struct wiphy *wiphy), + TP_ARGS(wiphy), + TP_STRUCT__entry( + WIPHY_ENTRY + ), + TP_fast_assign( + WIPHY_ASSIGN; + ), + TP_printk(WIPHY_PR_FMT, WIPHY_PR_ARG) +); + /************************************************************* * rdev->ops traces * *************************************************************/ -- 2.44.0