2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2024-12-18 10:13:57 +08:00

kcov, usbip: collect coverage from vhci_rx_loop

Add kcov_remote_start()/kcov_remote_stop() annotations to the
vhci_rx_loop() function, which is responsible for parsing USB/IP packets
coming into USB/IP client.

Since vhci_rx_loop() threads are spawned per vhci_hcd device instance, the
common kcov handle is used for kcov_remote_start()/stop() annotations
(see Documentation/dev-tools/kcov.rst for details). As the result kcov
can now be used to collect coverage from vhci_rx_loop() threads.

Co-developed-by: Andrey Konovalov <andreyknvl@google.com>
Acked-by: Shuah Khan <skhan@linuxfoundation.org>
Signed-off-by: Nazime Hande Harputluoglu <handeharputlu@google.com>
Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
Link: https://lore.kernel.org/r/f8114050f8d65aa0bc801318b1db532d9f432447.1606175386.git.andreyknvl@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Nazime Hande Harputluoglu 2020-11-24 00:50:52 +01:00 committed by Greg Kroah-Hartman
parent 5c8fe583cc
commit 894f1f4f49
3 changed files with 32 additions and 0 deletions

View File

@ -277,6 +277,10 @@ struct usbip_device {
void (*reset)(struct usbip_device *);
void (*unusable)(struct usbip_device *);
} eh_ops;
#ifdef CONFIG_KCOV
u64 kcov_handle;
#endif
};
#define kthread_get_run(threadfn, data, namefmt, ...) \
@ -337,4 +341,29 @@ static inline int interface_to_devnum(struct usb_interface *interface)
return udev->devnum;
}
#ifdef CONFIG_KCOV
static inline void usbip_kcov_handle_init(struct usbip_device *ud)
{
ud->kcov_handle = kcov_common_handle();
}
static inline void usbip_kcov_remote_start(struct usbip_device *ud)
{
kcov_remote_start_common(ud->kcov_handle);
}
static inline void usbip_kcov_remote_stop(void)
{
kcov_remote_stop();
}
#else /* CONFIG_KCOV */
static inline void usbip_kcov_handle_init(struct usbip_device *ud) { }
static inline void usbip_kcov_remote_start(struct usbip_device *ud) { }
static inline void usbip_kcov_remote_stop(void) { }
#endif /* CONFIG_KCOV */
#endif /* __USBIP_COMMON_H */

View File

@ -261,7 +261,9 @@ int vhci_rx_loop(void *data)
if (usbip_event_happened(ud))
break;
usbip_kcov_remote_start(ud);
vhci_rx_pdu(ud);
usbip_kcov_remote_stop();
}
return 0;

View File

@ -383,6 +383,7 @@ static ssize_t attach_store(struct device *dev, struct device_attribute *attr,
vdev->ud.sockfd = sockfd;
vdev->ud.tcp_socket = socket;
vdev->ud.status = VDEV_ST_NOTASSIGNED;
usbip_kcov_handle_init(&vdev->ud);
spin_unlock(&vdev->ud.lock);
spin_unlock_irqrestore(&vhci->lock, flags);