linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3] kcov, usbip: collect coverage from vhci_rx_loop
@ 2020-10-19 17:20 Andrey Konovalov
  2020-10-19 18:49 ` Shuah Khan
  0 siblings, 1 reply; 4+ messages in thread
From: Andrey Konovalov @ 2020-10-19 17:20 UTC (permalink / raw)
  To: Shuah Khan
  Cc: Dmitry Vyukov, Greg Kroah-Hartman, linux-usb, linux-kernel,
	Alexander Potapenko, Marco Elver, Aleksandr Nogikh,
	Nazime Hande Harputluoglu, Nazime Hande Harputluoglu,
	Andrey Konovalov

From: Nazime Hande Harputluoglu <handeharputlu@google.com>

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.

Signed-off-by: Nazime Hande Harputluoglu <handeharputlu@google.com>
Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
---

Changes v2->v3:
- Fix build without KCOV enabled.

---
 drivers/usb/usbip/usbip_common.h | 4 ++++
 drivers/usb/usbip/vhci_rx.c      | 7 +++++++
 drivers/usb/usbip/vhci_sysfs.c   | 4 ++++
 3 files changed, 15 insertions(+)

diff --git a/drivers/usb/usbip/usbip_common.h b/drivers/usb/usbip/usbip_common.h
index 8be857a4fa13..0906182011d6 100644
--- a/drivers/usb/usbip/usbip_common.h
+++ b/drivers/usb/usbip/usbip_common.h
@@ -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, ...)			   \
diff --git a/drivers/usb/usbip/vhci_rx.c b/drivers/usb/usbip/vhci_rx.c
index 266024cbb64f..68ec0aa64f69 100644
--- a/drivers/usb/usbip/vhci_rx.c
+++ b/drivers/usb/usbip/vhci_rx.c
@@ -3,6 +3,7 @@
  * Copyright (C) 2003-2008 Takahiro Hirofuchi
  */
 
+#include <linux/kcov.h>
 #include <linux/kthread.h>
 #include <linux/slab.h>
 
@@ -261,7 +262,13 @@ int vhci_rx_loop(void *data)
 		if (usbip_event_happened(ud))
 			break;
 
+#ifdef CONFIG_KCOV
+		kcov_remote_start_common(ud->kcov_handle);
+#endif
 		vhci_rx_pdu(ud);
+#ifdef CONFIG_KCOV
+		kcov_remote_stop();
+#endif
 	}
 
 	return 0;
diff --git a/drivers/usb/usbip/vhci_sysfs.c b/drivers/usb/usbip/vhci_sysfs.c
index be37aec250c2..e167b8a445ad 100644
--- a/drivers/usb/usbip/vhci_sysfs.c
+++ b/drivers/usb/usbip/vhci_sysfs.c
@@ -4,6 +4,7 @@
  * Copyright (C) 2015-2016 Nobuo Iwata
  */
 
+#include <linux/kcov.h>
 #include <linux/kthread.h>
 #include <linux/file.h>
 #include <linux/net.h>
@@ -383,6 +384,9 @@ 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;
+#ifdef CONFIG_KCOV
+	vdev->ud.kcov_handle = kcov_common_handle();
+#endif
 
 	spin_unlock(&vdev->ud.lock);
 	spin_unlock_irqrestore(&vhci->lock, flags);
-- 
2.29.0.rc1.297.gfa9743e501-goog


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v3] kcov, usbip: collect coverage from vhci_rx_loop
  2020-10-19 17:20 [PATCH v3] kcov, usbip: collect coverage from vhci_rx_loop Andrey Konovalov
@ 2020-10-19 18:49 ` Shuah Khan
  2020-10-19 18:52   ` Shuah Khan
  0 siblings, 1 reply; 4+ messages in thread
From: Shuah Khan @ 2020-10-19 18:49 UTC (permalink / raw)
  To: Andrey Konovalov, Shuah Khan
  Cc: Dmitry Vyukov, Greg Kroah-Hartman, linux-usb, linux-kernel,
	Alexander Potapenko, Marco Elver, Aleksandr Nogikh,
	Nazime Hande Harputluoglu, Nazime Hande Harputluoglu, Shuah Khan

On 10/19/20 11:20 AM, Andrey Konovalov wrote:
> From: Nazime Hande Harputluoglu <handeharputlu@google.com>
> 
> 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.
> 
> Signed-off-by: Nazime Hande Harputluoglu <handeharputlu@google.com>
> Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
> ---
> 
> Changes v2->v3:
> - Fix build without KCOV enabled.
> 
> ---
>   drivers/usb/usbip/usbip_common.h | 4 ++++
>   drivers/usb/usbip/vhci_rx.c      | 7 +++++++
>   drivers/usb/usbip/vhci_sysfs.c   | 4 ++++
>   3 files changed, 15 insertions(+)
> 
> diff --git a/drivers/usb/usbip/usbip_common.h b/drivers/usb/usbip/usbip_common.h
> index 8be857a4fa13..0906182011d6 100644
> --- a/drivers/usb/usbip/usbip_common.h
> +++ b/drivers/usb/usbip/usbip_common.h
> @@ -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, ...)			   \
> diff --git a/drivers/usb/usbip/vhci_rx.c b/drivers/usb/usbip/vhci_rx.c
> index 266024cbb64f..68ec0aa64f69 100644
> --- a/drivers/usb/usbip/vhci_rx.c
> +++ b/drivers/usb/usbip/vhci_rx.c
> @@ -3,6 +3,7 @@
>    * Copyright (C) 2003-2008 Takahiro Hirofuchi
>    */
>   
> +#include <linux/kcov.h>
>   #include <linux/kthread.h>
>   #include <linux/slab.h>
>   
> @@ -261,7 +262,13 @@ int vhci_rx_loop(void *data)
>   		if (usbip_event_happened(ud))
>   			break;
>   
> +#ifdef CONFIG_KCOV
> +		kcov_remote_start_common(ud->kcov_handle);
> +#endif
>   		vhci_rx_pdu(ud);
> +#ifdef CONFIG_KCOV
> +		kcov_remote_stop();
> +#endif
>   	}

Let's move these into usbip_common.h as inline functions along
the line of

#ifdef CONFIG_KCOV
usbip_kcov_remote_start_common(ud)
{
   kcov_remote_start_common(ud->kcov_handle);
}

usbip_kcov_remote_stop_common(ud)
{
   kcov_remote_stop_common(ud->kcov_handle);
}
#else
stubs that do nothing
#endif

>   
>   	return 0;
> diff --git a/drivers/usb/usbip/vhci_sysfs.c b/drivers/usb/usbip/vhci_sysfs.c
> index be37aec250c2..e167b8a445ad 100644
> --- a/drivers/usb/usbip/vhci_sysfs.c
> +++ b/drivers/usb/usbip/vhci_sysfs.c
> @@ -4,6 +4,7 @@
>    * Copyright (C) 2015-2016 Nobuo Iwata
>    */
>   
> +#include <linux/kcov.h>
>   #include <linux/kthread.h>
>   #include <linux/file.h>
>   #include <linux/net.h>
> @@ -383,6 +384,9 @@ 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;
> +#ifdef CONFIG_KCOV
> +	vdev->ud.kcov_handle = kcov_common_handle();
> +#endif


Same here add a usbip_kcov_handle_init(ud)

thanks,
-- Shuah

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v3] kcov, usbip: collect coverage from vhci_rx_loop
  2020-10-19 18:49 ` Shuah Khan
@ 2020-10-19 18:52   ` Shuah Khan
  2020-11-23 23:41     ` Andrey Konovalov
  0 siblings, 1 reply; 4+ messages in thread
From: Shuah Khan @ 2020-10-19 18:52 UTC (permalink / raw)
  To: Andrey Konovalov, Shuah Khan
  Cc: Dmitry Vyukov, Greg Kroah-Hartman, linux-usb, linux-kernel,
	Alexander Potapenko, Marco Elver, Aleksandr Nogikh,
	Nazime Hande Harputluoglu, Nazime Hande Harputluoglu, Shuah Khan

On 10/19/20 12:49 PM, Shuah Khan wrote:
> On 10/19/20 11:20 AM, Andrey Konovalov wrote:
>> From: Nazime Hande Harputluoglu <handeharputlu@google.com>
>>
>> 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.
>>
>> Signed-off-by: Nazime Hande Harputluoglu <handeharputlu@google.com>
>> Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
>> ---
>>
>> Changes v2->v3:
>> - Fix build without KCOV enabled.
>>
>> ---
>>   drivers/usb/usbip/usbip_common.h | 4 ++++
>>   drivers/usb/usbip/vhci_rx.c      | 7 +++++++
>>   drivers/usb/usbip/vhci_sysfs.c   | 4 ++++
>>   3 files changed, 15 insertions(+)
>>
>> diff --git a/drivers/usb/usbip/usbip_common.h 
>> b/drivers/usb/usbip/usbip_common.h
>> index 8be857a4fa13..0906182011d6 100644
>> --- a/drivers/usb/usbip/usbip_common.h
>> +++ b/drivers/usb/usbip/usbip_common.h
>> @@ -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, ...)               \
>> diff --git a/drivers/usb/usbip/vhci_rx.c b/drivers/usb/usbip/vhci_rx.c
>> index 266024cbb64f..68ec0aa64f69 100644
>> --- a/drivers/usb/usbip/vhci_rx.c
>> +++ b/drivers/usb/usbip/vhci_rx.c
>> @@ -3,6 +3,7 @@
>>    * Copyright (C) 2003-2008 Takahiro Hirofuchi
>>    */
>> +#include <linux/kcov.h>
>>   #include <linux/kthread.h>
>>   #include <linux/slab.h>
>> @@ -261,7 +262,13 @@ int vhci_rx_loop(void *data)
>>           if (usbip_event_happened(ud))
>>               break;
>> +#ifdef CONFIG_KCOV
>> +        kcov_remote_start_common(ud->kcov_handle);
>> +#endif
>>           vhci_rx_pdu(ud);
>> +#ifdef CONFIG_KCOV
>> +        kcov_remote_stop();
>> +#endif
>>       }
> 
> Let's move these into usbip_common.h as inline functions along
> the line of
> 
> #ifdef CONFIG_KCOV
> usbip_kcov_remote_start_common(ud)
> {
>    kcov_remote_start_common(ud->kcov_handle);
> }
> 
> usbip_kcov_remote_stop_common(ud)
> {
>    kcov_remote_stop_common(ud->kcov_handle);
> }
> #else
> stubs that do nothing
> #endif
> 
>>       return 0;
>> diff --git a/drivers/usb/usbip/vhci_sysfs.c 
>> b/drivers/usb/usbip/vhci_sysfs.c
>> index be37aec250c2..e167b8a445ad 100644
>> --- a/drivers/usb/usbip/vhci_sysfs.c
>> +++ b/drivers/usb/usbip/vhci_sysfs.c
>> @@ -4,6 +4,7 @@
>>    * Copyright (C) 2015-2016 Nobuo Iwata
>>    */
>> +#include <linux/kcov.h>
>>   #include <linux/kthread.h>
>>   #include <linux/file.h>
>>   #include <linux/net.h>
>> @@ -383,6 +384,9 @@ 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;
>> +#ifdef CONFIG_KCOV
>> +    vdev->ud.kcov_handle = kcov_common_handle();
>> +#endif
> 
> 
> Same here add a usbip_kcov_handle_init(ud)
> 

btw - I am seeing bounces on handeharputlu@google.com address.

thanks,
-- Shuah

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v3] kcov, usbip: collect coverage from vhci_rx_loop
  2020-10-19 18:52   ` Shuah Khan
@ 2020-11-23 23:41     ` Andrey Konovalov
  0 siblings, 0 replies; 4+ messages in thread
From: Andrey Konovalov @ 2020-11-23 23:41 UTC (permalink / raw)
  To: Shuah Khan
  Cc: Shuah Khan, Dmitry Vyukov, Greg Kroah-Hartman, USB list, LKML,
	Alexander Potapenko, Marco Elver, Aleksandr Nogikh,
	Nazime Hande Harputluoglu, Nazime Hande Harputluoglu

On Mon, Oct 19, 2020 at 8:52 PM Shuah Khan <skhan@linuxfoundation.org> wrote:
>
> On 10/19/20 12:49 PM, Shuah Khan wrote:
> > On 10/19/20 11:20 AM, Andrey Konovalov wrote:
> >> From: Nazime Hande Harputluoglu <handeharputlu@google.com>
> >>
> >> 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.
> >>
> >> Signed-off-by: Nazime Hande Harputluoglu <handeharputlu@google.com>
> >> Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
> >> ---
> >>
> >> Changes v2->v3:
> >> - Fix build without KCOV enabled.
> >>
> >> ---
> >>   drivers/usb/usbip/usbip_common.h | 4 ++++
> >>   drivers/usb/usbip/vhci_rx.c      | 7 +++++++
> >>   drivers/usb/usbip/vhci_sysfs.c   | 4 ++++
> >>   3 files changed, 15 insertions(+)
> >>
> >> diff --git a/drivers/usb/usbip/usbip_common.h
> >> b/drivers/usb/usbip/usbip_common.h
> >> index 8be857a4fa13..0906182011d6 100644
> >> --- a/drivers/usb/usbip/usbip_common.h
> >> +++ b/drivers/usb/usbip/usbip_common.h
> >> @@ -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, ...)               \
> >> diff --git a/drivers/usb/usbip/vhci_rx.c b/drivers/usb/usbip/vhci_rx.c
> >> index 266024cbb64f..68ec0aa64f69 100644
> >> --- a/drivers/usb/usbip/vhci_rx.c
> >> +++ b/drivers/usb/usbip/vhci_rx.c
> >> @@ -3,6 +3,7 @@
> >>    * Copyright (C) 2003-2008 Takahiro Hirofuchi
> >>    */
> >> +#include <linux/kcov.h>
> >>   #include <linux/kthread.h>
> >>   #include <linux/slab.h>
> >> @@ -261,7 +262,13 @@ int vhci_rx_loop(void *data)
> >>           if (usbip_event_happened(ud))
> >>               break;
> >> +#ifdef CONFIG_KCOV
> >> +        kcov_remote_start_common(ud->kcov_handle);
> >> +#endif
> >>           vhci_rx_pdu(ud);
> >> +#ifdef CONFIG_KCOV
> >> +        kcov_remote_stop();
> >> +#endif
> >>       }
> >
> > Let's move these into usbip_common.h as inline functions along
> > the line of
> >
> > #ifdef CONFIG_KCOV
> > usbip_kcov_remote_start_common(ud)
> > {
> >    kcov_remote_start_common(ud->kcov_handle);
> > }
> >
> > usbip_kcov_remote_stop_common(ud)
> > {
> >    kcov_remote_stop_common(ud->kcov_handle);
> > }
> > #else
> > stubs that do nothing
> > #endif

Sounds good, will mail a new version shortly. Sorry for a delay, I was
busy with other work.

> >
> >>       return 0;
> >> diff --git a/drivers/usb/usbip/vhci_sysfs.c
> >> b/drivers/usb/usbip/vhci_sysfs.c
> >> index be37aec250c2..e167b8a445ad 100644
> >> --- a/drivers/usb/usbip/vhci_sysfs.c
> >> +++ b/drivers/usb/usbip/vhci_sysfs.c
> >> @@ -4,6 +4,7 @@
> >>    * Copyright (C) 2015-2016 Nobuo Iwata
> >>    */
> >> +#include <linux/kcov.h>
> >>   #include <linux/kthread.h>
> >>   #include <linux/file.h>
> >>   #include <linux/net.h>
> >> @@ -383,6 +384,9 @@ 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;
> >> +#ifdef CONFIG_KCOV
> >> +    vdev->ud.kcov_handle = kcov_common_handle();
> >> +#endif
> >
> >
> > Same here add a usbip_kcov_handle_init(ud)
> >
>
> btw - I am seeing bounces on handeharputlu@google.com address.

Hande is no longer at Google, so the email is no longer valid. I think
it makes sense to preserve the original email address in the patch.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-11-23 23:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-19 17:20 [PATCH v3] kcov, usbip: collect coverage from vhci_rx_loop Andrey Konovalov
2020-10-19 18:49 ` Shuah Khan
2020-10-19 18:52   ` Shuah Khan
2020-11-23 23:41     ` Andrey Konovalov

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).