* [PATCH v2] kcov, usb: hide in_serving_softirq checks in __usb_hcd_giveback_urb
@ 2021-01-07 16:01 Andrey Konovalov
2021-01-07 16:08 ` Greg Kroah-Hartman
0 siblings, 1 reply; 2+ messages in thread
From: Andrey Konovalov @ 2021-01-07 16:01 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: linux-usb, linux-kernel, kasan-dev, Dmitry Vyukov,
Alexander Potapenko, Marco Elver, Andrey Konovalov
Done opencode in_serving_softirq() checks in __usb_hcd_giveback_urb() to
avoid cluttering the code, hide them in kcov helpers instead.
Fixes: aee9ddb1d371 ("kcov, usb: only collect coverage from __usb_hcd_giveback_urb in softirq")
Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
---
Changes v1->v2:
- Fix a typo in the commit description and in a comment in the patch.
---
drivers/usb/core/hcd.c | 8 +++-----
include/linux/kcov.h | 21 +++++++++++++++++++++
2 files changed, 24 insertions(+), 5 deletions(-)
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index 60886a7464c3..ad5a0f405a75 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -1649,14 +1649,12 @@ static void __usb_hcd_giveback_urb(struct urb *urb)
urb->status = status;
/*
* This function can be called in task context inside another remote
- * coverage collection section, but KCOV doesn't support that kind of
+ * coverage collection section, but kcov doesn't support that kind of
* recursion yet. Only collect coverage in softirq context for now.
*/
- if (in_serving_softirq())
- kcov_remote_start_usb((u64)urb->dev->bus->busnum);
+ kcov_remote_start_usb_softirq((u64)urb->dev->bus->busnum);
urb->complete(urb);
- if (in_serving_softirq())
- kcov_remote_stop();
+ kcov_remote_stop_softirq();
usb_anchor_resume_wakeups(anchor);
atomic_dec(&urb->use_count);
diff --git a/include/linux/kcov.h b/include/linux/kcov.h
index a10e84707d82..18306ef8ad5a 100644
--- a/include/linux/kcov.h
+++ b/include/linux/kcov.h
@@ -52,6 +52,25 @@ static inline void kcov_remote_start_usb(u64 id)
kcov_remote_start(kcov_remote_handle(KCOV_SUBSYSTEM_USB, id));
}
+/*
+ * The softirq flavor of kcov_remote_*() functions is introduced as a temporary
+ * workaround for kcov's lack of nested remote coverage sections support in
+ * task context. Adding suport for nested sections is tracked in:
+ * https://bugzilla.kernel.org/show_bug.cgi?id=210337
+ */
+
+static inline void kcov_remote_start_usb_softirq(u64 id)
+{
+ if (in_serving_softirq())
+ kcov_remote_start_usb(id);
+}
+
+static inline void kcov_remote_stop_softirq(void)
+{
+ if (in_serving_softirq())
+ kcov_remote_stop();
+}
+
#else
static inline void kcov_task_init(struct task_struct *t) {}
@@ -66,6 +85,8 @@ static inline u64 kcov_common_handle(void)
}
static inline void kcov_remote_start_common(u64 id) {}
static inline void kcov_remote_start_usb(u64 id) {}
+static inline void kcov_remote_start_usb_softirq(u64 id) {}
+static inline void kcov_remote_stop_softirq(void) {}
#endif /* CONFIG_KCOV */
#endif /* _LINUX_KCOV_H */
--
2.29.2.729.g45daf8777d-goog
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] kcov, usb: hide in_serving_softirq checks in __usb_hcd_giveback_urb
2021-01-07 16:01 [PATCH v2] kcov, usb: hide in_serving_softirq checks in __usb_hcd_giveback_urb Andrey Konovalov
@ 2021-01-07 16:08 ` Greg Kroah-Hartman
0 siblings, 0 replies; 2+ messages in thread
From: Greg Kroah-Hartman @ 2021-01-07 16:08 UTC (permalink / raw)
To: Andrey Konovalov
Cc: linux-usb, linux-kernel, kasan-dev, Dmitry Vyukov,
Alexander Potapenko, Marco Elver
On Thu, Jan 07, 2021 at 05:01:44PM +0100, Andrey Konovalov wrote:
> Done opencode in_serving_softirq() checks in __usb_hcd_giveback_urb() to
> avoid cluttering the code, hide them in kcov helpers instead.
>
> Fixes: aee9ddb1d371 ("kcov, usb: only collect coverage from __usb_hcd_giveback_urb in softirq")
> Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
> ---
>
> Changes v1->v2:
> - Fix a typo in the commit description and in a comment in the patch.
I can't drop the previous one, so can you just make a follow-on patch
please?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-01-07 16:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-07 16:01 [PATCH v2] kcov, usb: hide in_serving_softirq checks in __usb_hcd_giveback_urb Andrey Konovalov
2021-01-07 16:08 ` Greg Kroah-Hartman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).