Skip to content

Commit e89eed0

Browse files
xairygregkh
authored andcommitted
kcov, usb: hide in_serving_softirq checks in __usb_hcd_giveback_urb
Done opencode in_serving_softirq() checks in in_serving_softirq() to avoid cluttering the code, hide them in kcov helpers instead. Fixes: aee9ddb ("kcov, usb: only collect coverage from __usb_hcd_giveback_urb in softirq") Signed-off-by: Andrey Konovalov <andreyknvl@google.com> Link: https://lore.kernel.org/r/aeb430c5bb90b0ccdf1ec302c70831c1a47b9c45.1609876340.git.andreyknvl@google.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 10a0540 commit e89eed0

2 files changed

Lines changed: 24 additions & 5 deletions

File tree

drivers/usb/core/hcd.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1649,14 +1649,12 @@ static void __usb_hcd_giveback_urb(struct urb *urb)
16491649
urb->status = status;
16501650
/*
16511651
* This function can be called in task context inside another remote
1652-
* coverage collection section, but KCOV doesn't support that kind of
1652+
* coverage collection section, but kcov doesn't support that kind of
16531653
* recursion yet. Only collect coverage in softirq context for now.
16541654
*/
1655-
if (in_serving_softirq())
1656-
kcov_remote_start_usb((u64)urb->dev->bus->busnum);
1655+
kcov_remote_start_usb_softirq((u64)urb->dev->bus->busnum);
16571656
urb->complete(urb);
1658-
if (in_serving_softirq())
1659-
kcov_remote_stop();
1657+
kcov_remote_stop_softirq();
16601658

16611659
usb_anchor_resume_wakeups(anchor);
16621660
atomic_dec(&urb->use_count);

include/linux/kcov.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,25 @@ static inline void kcov_remote_start_usb(u64 id)
5252
kcov_remote_start(kcov_remote_handle(KCOV_SUBSYSTEM_USB, id));
5353
}
5454

55+
/*
56+
* The softirq flavor of kcov_remote_*() functions is introduced as a temporary
57+
* work around for kcov's lack of nested remote coverage sections support in
58+
* task context. Adding suport for nested sections is tracked in:
59+
* https://bugzilla.kernel.org/show_bug.cgi?id=210337
60+
*/
61+
62+
static inline void kcov_remote_start_usb_softirq(u64 id)
63+
{
64+
if (in_serving_softirq())
65+
kcov_remote_start_usb(id);
66+
}
67+
68+
static inline void kcov_remote_stop_softirq(void)
69+
{
70+
if (in_serving_softirq())
71+
kcov_remote_stop();
72+
}
73+
5574
#else
5675

5776
static inline void kcov_task_init(struct task_struct *t) {}
@@ -66,6 +85,8 @@ static inline u64 kcov_common_handle(void)
6685
}
6786
static inline void kcov_remote_start_common(u64 id) {}
6887
static inline void kcov_remote_start_usb(u64 id) {}
88+
static inline void kcov_remote_start_usb_softirq(u64 id) {}
89+
static inline void kcov_remote_stop_softirq(void) {}
6990

7091
#endif /* CONFIG_KCOV */
7192
#endif /* _LINUX_KCOV_H */

0 commit comments

Comments
 (0)