Linux-USB Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH v2] kcov, usbip: collect coverage from vhci_rx_loop
@ 2020-10-12 17:08 Andrey Konovalov
  2020-10-12 17:10 ` Andrey Konovalov
  2020-10-13 17:28 ` Shuah Khan
  0 siblings, 2 replies; 6+ messages in thread
From: Andrey Konovalov @ 2020-10-12 17:08 UTC (permalink / raw)
  To: Dmitry Vyukov, Greg Kroah-Hartman
  Cc: Andrew Morton, linux-usb, linux-kernel, Alan Stern, Shuah Khan,
	Alexander Potapenko, Marco Elver, Aleksandr Nogikh,
	Nazime Hande Harputluoglu, Nazime Hande Harputluoglu

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

Changes v1->v2:
- Fix spacing issues.
- Add ifdef CONFIG_KCOV around kcov_handle in usbip_device struct.

---
 drivers/usb/usbip/usbip_common.h |  4 ++++
 drivers/usb/usbip/vhci_rx.c      |  3 +++
 drivers/usb/usbip/vhci_sysfs.c   | 12 +++++++-----
 3 files changed, 14 insertions(+), 5 deletions(-)

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..473f14587bd5 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,9 @@ int vhci_rx_loop(void *data)
 		if (usbip_event_happened(ud))
 			break;
 
+		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..966f1f5cafb1 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>
@@ -378,11 +379,12 @@ static ssize_t attach_store(struct device *dev, struct device_attribute *attr,
 	dev_info(dev, "devid(%u) speed(%u) speed_str(%s)\n",
 		 devid, speed, usb_speed_string(speed));
 
-	vdev->devid         = devid;
-	vdev->speed         = speed;
-	vdev->ud.sockfd     = sockfd;
-	vdev->ud.tcp_socket = socket;
-	vdev->ud.status     = VDEV_ST_NOTASSIGNED;
+	vdev->devid          = devid;
+	vdev->speed          = speed;
+	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


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

* [PATCH v2] kcov, usbip: collect coverage from vhci_rx_loop
  2020-10-12 17:08 [PATCH v2] kcov, usbip: collect coverage from vhci_rx_loop Andrey Konovalov
@ 2020-10-12 17:10 ` Andrey Konovalov
  2020-10-13 17:28 ` Shuah Khan
  1 sibling, 0 replies; 6+ messages in thread
From: Andrey Konovalov @ 2020-10-12 17:10 UTC (permalink / raw)
  To: Dmitry Vyukov, Greg Kroah-Hartman
  Cc: Andrew Morton, linux-usb, linux-kernel, Alan Stern, Shuah Khan,
	Alexander Potapenko, Marco Elver, Aleksandr Nogikh,
	Nazime Hande Harputluoglu, Andrey Konovalov,
	Nazime Hande Harputluoglu

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

Changes v1->v2:
- Fix spacing issues.
- Add ifdef CONFIG_KCOV around kcov_handle in usbip_device struct.

---
 drivers/usb/usbip/usbip_common.h |  4 ++++
 drivers/usb/usbip/vhci_rx.c      |  3 +++
 drivers/usb/usbip/vhci_sysfs.c   | 12 +++++++-----
 3 files changed, 14 insertions(+), 5 deletions(-)

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..473f14587bd5 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,9 @@ int vhci_rx_loop(void *data)
 		if (usbip_event_happened(ud))
 			break;
 
+		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..966f1f5cafb1 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>
@@ -378,11 +379,12 @@ static ssize_t attach_store(struct device *dev, struct device_attribute *attr,
 	dev_info(dev, "devid(%u) speed(%u) speed_str(%s)\n",
 		 devid, speed, usb_speed_string(speed));
 
-	vdev->devid         = devid;
-	vdev->speed         = speed;
-	vdev->ud.sockfd     = sockfd;
-	vdev->ud.tcp_socket = socket;
-	vdev->ud.status     = VDEV_ST_NOTASSIGNED;
+	vdev->devid          = devid;
+	vdev->speed          = speed;
+	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


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

* Re: [PATCH v2] kcov, usbip: collect coverage from vhci_rx_loop
  2020-10-12 17:08 [PATCH v2] kcov, usbip: collect coverage from vhci_rx_loop Andrey Konovalov
  2020-10-12 17:10 ` Andrey Konovalov
@ 2020-10-13 17:28 ` Shuah Khan
  2020-10-14 15:54   ` Andrey Konovalov
  2020-10-16 14:18   ` Andrey Konovalov
  1 sibling, 2 replies; 6+ messages in thread
From: Shuah Khan @ 2020-10-13 17:28 UTC (permalink / raw)
  To: Andrey Konovalov, Dmitry Vyukov, Greg Kroah-Hartman
  Cc: Andrew Morton, linux-usb, linux-kernel, Alan Stern, Shuah Khan,
	Alexander Potapenko, Marco Elver, Aleksandr Nogikh,
	Nazime Hande Harputluoglu, Nazime Hande Harputluoglu, Shuah Khan

On 10/12/20 11:10 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>
> ---
> 
> Changes v1->v2:
> - Fix spacing issues.
> - Add ifdef CONFIG_KCOV around kcov_handle in usbip_device struct.
> 

Does this compile without CONFIG_KCOV?

> ---
>   drivers/usb/usbip/usbip_common.h |  4 ++++
>   drivers/usb/usbip/vhci_rx.c      |  3 +++
>   drivers/usb/usbip/vhci_sysfs.c   | 12 +++++++-----
>   3 files changed, 14 insertions(+), 5 deletions(-)
> 
> 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..473f14587bd5 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,9 @@ int vhci_rx_loop(void *data)
>   		if (usbip_event_happened(ud))
>   			break;
>   
> +		kcov_remote_start_common(ud->kcov_handle);

You are referencing kcov_handle defined in CONFIG_KCOV scope
here. Does this compile for you without CONFIG_KCOV?

>   		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..966f1f5cafb1 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>
> @@ -378,11 +379,12 @@ static ssize_t attach_store(struct device *dev, struct device_attribute *attr,
>   	dev_info(dev, "devid(%u) speed(%u) speed_str(%s)\n",
>   		 devid, speed, usb_speed_string(speed));
>   
> -	vdev->devid         = devid;
> -	vdev->speed         = speed;
> -	vdev->ud.sockfd     = sockfd;
> -	vdev->ud.tcp_socket = socket;
> -	vdev->ud.status     = VDEV_ST_NOTASSIGNED;
> +	vdev->devid          = devid;
> +	vdev->speed          = speed;
> +	vdev->ud.sockfd      = sockfd;
> +	vdev->ud.tcp_socket  = socket;
> +	vdev->ud.status      = VDEV_ST_NOTASSIGNED;
> +	vdev->ud.kcov_handle = kcov_common_handle();

Don't change spacing for other variables. Add just the new
code. Don't you need CONFIG_KCOV around this new code?
>   
>   	spin_unlock(&vdev->ud.lock);
>   	spin_unlock_irqrestore(&vhci->lock, flags);
> 

thanks,
-- Shuah

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

* Re: [PATCH v2] kcov, usbip: collect coverage from vhci_rx_loop
  2020-10-13 17:28 ` Shuah Khan
@ 2020-10-14 15:54   ` Andrey Konovalov
  2020-10-16 14:18   ` Andrey Konovalov
  1 sibling, 0 replies; 6+ messages in thread
From: Andrey Konovalov @ 2020-10-14 15:54 UTC (permalink / raw)
  To: Shuah Khan
  Cc: Dmitry Vyukov, Greg Kroah-Hartman, Andrew Morton, USB list, LKML,
	Alan Stern, Shuah Khan, Alexander Potapenko, Marco Elver,
	Aleksandr Nogikh, Nazime Hande Harputluoglu,
	Nazime Hande Harputluoglu

On Tue, Oct 13, 2020 at 7:28 PM Shuah Khan <skhan@linuxfoundation.org> wrote:
>
> On 10/12/20 11:10 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>
> > ---
> >
> > Changes v1->v2:
> > - Fix spacing issues.
> > - Add ifdef CONFIG_KCOV around kcov_handle in usbip_device struct.
> >
>
> Does this compile without CONFIG_KCOV?
>
> > ---
> >   drivers/usb/usbip/usbip_common.h |  4 ++++
> >   drivers/usb/usbip/vhci_rx.c      |  3 +++
> >   drivers/usb/usbip/vhci_sysfs.c   | 12 +++++++-----
> >   3 files changed, 14 insertions(+), 5 deletions(-)
> >
> > 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..473f14587bd5 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,9 @@ int vhci_rx_loop(void *data)
> >               if (usbip_event_happened(ud))
> >                       break;
> >
> > +             kcov_remote_start_common(ud->kcov_handle);
>
> You are referencing kcov_handle defined in CONFIG_KCOV scope
> here. Does this compile for you without CONFIG_KCOV?
>
> >               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..966f1f5cafb1 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>
> > @@ -378,11 +379,12 @@ static ssize_t attach_store(struct device *dev, struct device_attribute *attr,
> >       dev_info(dev, "devid(%u) speed(%u) speed_str(%s)\n",
> >                devid, speed, usb_speed_string(speed));
> >
> > -     vdev->devid         = devid;
> > -     vdev->speed         = speed;
> > -     vdev->ud.sockfd     = sockfd;
> > -     vdev->ud.tcp_socket = socket;
> > -     vdev->ud.status     = VDEV_ST_NOTASSIGNED;
> > +     vdev->devid          = devid;
> > +     vdev->speed          = speed;
> > +     vdev->ud.sockfd      = sockfd;
> > +     vdev->ud.tcp_socket  = socket;
> > +     vdev->ud.status      = VDEV_ST_NOTASSIGNED;
> > +     vdev->ud.kcov_handle = kcov_common_handle();
>
> Don't change spacing for other variables. Add just the new
> code. Don't you need CONFIG_KCOV around this new code?

Yeah, this breaks without CONFIG_KCOV, my bad.

I'll fix everything and submit v3.

Thank you!

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

* Re: [PATCH v2] kcov, usbip: collect coverage from vhci_rx_loop
  2020-10-13 17:28 ` Shuah Khan
  2020-10-14 15:54   ` Andrey Konovalov
@ 2020-10-16 14:18   ` Andrey Konovalov
  2020-10-16 17:03     ` Shuah Khan
  1 sibling, 1 reply; 6+ messages in thread
From: Andrey Konovalov @ 2020-10-16 14:18 UTC (permalink / raw)
  To: Shuah Khan
  Cc: Dmitry Vyukov, Greg Kroah-Hartman, Andrew Morton, USB list, LKML,
	Alan Stern, Shuah Khan, Alexander Potapenko, Marco Elver,
	Aleksandr Nogikh, Nazime Hande Harputluoglu,
	Nazime Hande Harputluoglu

On Tue, Oct 13, 2020 at 7:28 PM Shuah Khan <skhan@linuxfoundation.org> wrote:
>
> On 10/12/20 11:10 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>
> > ---
> >
> > Changes v1->v2:
> > - Fix spacing issues.
> > - Add ifdef CONFIG_KCOV around kcov_handle in usbip_device struct.
> >
>
> Does this compile without CONFIG_KCOV?
>
> > ---
> >   drivers/usb/usbip/usbip_common.h |  4 ++++
> >   drivers/usb/usbip/vhci_rx.c      |  3 +++
> >   drivers/usb/usbip/vhci_sysfs.c   | 12 +++++++-----
> >   3 files changed, 14 insertions(+), 5 deletions(-)
> >
> > 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

Hi Shuah,

We could have this field always defined, which allows us to not check
CONFIG_KCOV in the places where it's used (this is what we do for
vhost; the kcov functions will be optimized away). Or we could keep
the ifdef CONFIG_KCOV check here, and then add the same checks to
other places.

What would be your preference here?

Thanks!

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

* Re: [PATCH v2] kcov, usbip: collect coverage from vhci_rx_loop
  2020-10-16 14:18   ` Andrey Konovalov
@ 2020-10-16 17:03     ` Shuah Khan
  0 siblings, 0 replies; 6+ messages in thread
From: Shuah Khan @ 2020-10-16 17:03 UTC (permalink / raw)
  To: Andrey Konovalov
  Cc: Dmitry Vyukov, Greg Kroah-Hartman, Andrew Morton, USB list, LKML,
	Alan Stern, Shuah Khan, Alexander Potapenko, Marco Elver,
	Aleksandr Nogikh, Nazime Hande Harputluoglu,
	Nazime Hande Harputluoglu, Shuah Khan

On 10/16/20 8:18 AM, Andrey Konovalov wrote:
> On Tue, Oct 13, 2020 at 7:28 PM Shuah Khan <skhan@linuxfoundation.org> wrote:
>>
>> On 10/12/20 11:10 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>
>>> ---
>>>
>>> Changes v1->v2:
>>> - Fix spacing issues.
>>> - Add ifdef CONFIG_KCOV around kcov_handle in usbip_device struct.
>>>
>>
>> Does this compile without CONFIG_KCOV?
>>
>>> ---
>>>    drivers/usb/usbip/usbip_common.h |  4 ++++
>>>    drivers/usb/usbip/vhci_rx.c      |  3 +++
>>>    drivers/usb/usbip/vhci_sysfs.c   | 12 +++++++-----
>>>    3 files changed, 14 insertions(+), 5 deletions(-)
>>>
>>> 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
> 
> Hi Shuah,
> 
> We could have this field always defined, which allows us to not check
> CONFIG_KCOV in the places where it's used (this is what we do for
> vhost; the kcov functions will be optimized away). Or we could keep
> the ifdef CONFIG_KCOV check here, and then add the same checks to
> other places.
> 
> What would be your preference here?

Let's keep it in ifdef CONFIG_KCOV and add checks to keep this
limited to just the kcov case.

thanks,
-- Shuah





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

end of thread, back to index

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-12 17:08 [PATCH v2] kcov, usbip: collect coverage from vhci_rx_loop Andrey Konovalov
2020-10-12 17:10 ` Andrey Konovalov
2020-10-13 17:28 ` Shuah Khan
2020-10-14 15:54   ` Andrey Konovalov
2020-10-16 14:18   ` Andrey Konovalov
2020-10-16 17:03     ` Shuah Khan

Linux-USB Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-usb/0 linux-usb/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-usb linux-usb/ https://lore.kernel.org/linux-usb \
		linux-usb@vger.kernel.org
	public-inbox-index linux-usb

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-usb


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git