Re: [PATCH] usbip, kcov: collect coverage from usbip client

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Oct 09, 2020 at 03:22:55PM +0000, NazimeHandeHarputluogluhandeharput@xxxxxxxxx wrote:
> From: Nazime Hande Harputluoglu <handeharputlu@xxxxxxxxxx>
> 
> Add kcov_remote_start()/kcov_remote_stop() annotations to the
> vhci_rx_loop() function, which is responsible for parsing USB/IP packets
> in USB/IP client.
> 
> Since vhci_rx_loop() threads are spawned per usbip 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.
> 
> Signed-off-by: Nazime Hande Harputluoglu <handeharputlu@xxxxxxxxxx>
> ---
>  drivers/usb/usbip/usbip_common.h | 2 ++
>  drivers/usb/usbip/vhci_rx.c      | 6 ++++--
>  drivers/usb/usbip/vhci_sysfs.c   | 2 ++
>  3 files changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/usb/usbip/usbip_common.h b/drivers/usb/usbip/usbip_common.h
> index 8be857a4fa13..cbbf2aa8ac73 100644
> --- a/drivers/usb/usbip/usbip_common.h
> +++ b/drivers/usb/usbip/usbip_common.h
> @@ -277,6 +277,8 @@ struct usbip_device {
>  		void (*reset)(struct usbip_device *);
>  		void (*unusable)(struct usbip_device *);
>  	} eh_ops;
> +
> +        u64 kcov_handle;
>  };
>  
>  #define kthread_get_run(threadfn, data, namefmt, ...)			   \
> diff --git a/drivers/usb/usbip/vhci_rx.c b/drivers/usb/usbip/vhci_rx.c
> index 266024cbb64f..b2eb3e8c04b9 100644
> --- a/drivers/usb/usbip/vhci_rx.c
> +++ b/drivers/usb/usbip/vhci_rx.c
> @@ -260,8 +260,10 @@ int vhci_rx_loop(void *data)
>  	while (!kthread_should_stop()) {
>  		if (usbip_event_happened(ud))
>  			break;
> -
> -		vhci_rx_pdu(ud);
> +                
> +                kcov_remote_start_common(ud->kcov_handle);
> +                vhci_rx_pdu(ud);
> +                kcov_remote_stop();
>  	}
>  
>  	return 0;
> diff --git a/drivers/usb/usbip/vhci_sysfs.c b/drivers/usb/usbip/vhci_sysfs.c
> index be37aec250c2..4dfe3809ebbb 100644
> --- a/drivers/usb/usbip/vhci_sysfs.c
> +++ b/drivers/usb/usbip/vhci_sysfs.c
> @@ -9,6 +9,7 @@
>  #include <linux/net.h>
>  #include <linux/platform_device.h>
>  #include <linux/slab.h>
> +#include <linux/kcov.h>
>  
>  /* Hardening for Spectre-v1 */
>  #include <linux/nospec.h>
> @@ -383,6 +384,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;
> +        vdev->ud.kcov_handle = kcov_common_handle();
>  
>  	spin_unlock(&vdev->ud.lock);
>  	spin_unlock_irqrestore(&vhci->lock, flags);
> -- 
> 2.28.0.1011.ga647a8990f-goog
> 

Please run checkpatch.pl on your patches before sending them out, so you
don't get grumpy maintainers telling you to run checkpatch.pl on your
patch...

thanks,

greg k-h



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux