]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
wifi: cfg80211: add tracing for wiphy work
authorJohannes Berg <johannes.berg@intel.com>
Mon, 6 May 2024 19:00:03 +0000 (21:00 +0200)
committerJohannes Berg <johannes.berg@intel.com>
Thu, 23 May 2024 08:21:22 +0000 (10:21 +0200)
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 <miriam.rachel.korenblit@intel.com>
Reviewed-by: Benjamin Berg <benjamin.berg@intel.com>
Link: https://msgid.link/20240506210002.bf1840a1d22d.I4abba048c1c4017345640219cf1384a0b2288dd3@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
net/wireless/core.c
net/wireless/trace.h

index 3fb1b637352a9d0b469206d890601031ffd4c68f..61f7cd8a8e9cedaf75322daeaff0c27bea10712c 100644 (file)
@@ -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)
                        schedule_work(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);
index b76e3b21051a25b7202e6433f2539d3a3a4b8eba..14cfa0aba93a8df1c4bc8a7d9b24aa571508ef61 100644 (file)
                }                                               \
        } 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                     *
  *************************************************************/