RE: [PATCH v6 1/2] drivers: hv: vmbus: Introduce latency testing

2019-10-03 Thread Michael Kelley
From: Branden Bonaby  Sent: Thursday, October 3, 
2019 2:02 PM
> 
> Introduce user specified latency in the packet reception path
> By exposing the test parameters as part of the debugfs channel
> attributes. We will control the testing state via these attributes.
> 
> Signed-off-by: Branden Bonaby 
> ---
> changes in v6:
>  - changed kernel version in
>Documentation/ABI/testing/debugfs-hyperv to 5.5
> 
>  - removed less than 0 if statement when dealing with
>u64 datatype, as suggested by Michael.
> 
> changes in v5:
>  - As per Stephen's suggestion, Moved CONFIG_HYPERV_TESTING
>to lib/Kconfig.debug.
> 
>  - Fixed build issue reported by Kbuild, with Michael's
>suggestion to make hv_debugfs part of the hv_vmbus
>module.
> 
>  - updated debugfs-hyperv to show kernel version 5.4
> 
> changes in v4:
>  - Combined v3 patch 2 into this patch, and changed the
>commit description to reflect this.
> 
>  - Moved debugfs code from "vmbus_drv.c" that was in
>previous v3 patch 2, into a new file "debugfs.c" in
>drivers/hv.
> 
>  - Updated the Makefile to compile "debugfs.c" if
>CONFIG_HYPERV_TESTING is enabled
> 
>  - As per Michael's comments, added empty implementations
>of the new functions, so the compiler will not generate
>code when CONFIG_HYPERV_TESTING is not enabled.
> 
>  - Added microseconds into description for files in
>Documentation/ABI/testing/debugfs-hyperv.
> 
> Changes in v2:
>  - Add #ifdef in Kconfig file so test code will not interfere
>with non-test code.
>  - Move test code functions for delay to hyperv_vmbus header
>file.
>  - Wrap test code under #ifdef statement.
> 
>  Documentation/ABI/testing/debugfs-hyperv |  23 +++
>  MAINTAINERS  |   1 +
>  drivers/hv/Makefile  |   1 +
>  drivers/hv/connection.c  |   1 +
>  drivers/hv/hv_debugfs.c  | 178 +++
>  drivers/hv/hyperv_vmbus.h|  31 
>  drivers/hv/ring_buffer.c |   2 +
>  drivers/hv/vmbus_drv.c   |   6 +
>  include/linux/hyperv.h   |  19 +++
>  lib/Kconfig.debug|   7 +
>  10 files changed, 269 insertions(+)
>  create mode 100644 Documentation/ABI/testing/debugfs-hyperv
>  create mode 100644 drivers/hv/hv_debugfs.c
> 

Reviewed-by: Michael Kelley 


[PATCH v6 1/2] drivers: hv: vmbus: Introduce latency testing

2019-10-03 Thread Branden Bonaby
Introduce user specified latency in the packet reception path
By exposing the test parameters as part of the debugfs channel
attributes. We will control the testing state via these attributes.

Signed-off-by: Branden Bonaby 
---
changes in v6:
 - changed kernel version in
   Documentation/ABI/testing/debugfs-hyperv to 5.5

 - removed less than 0 if statement when dealing with
   u64 datatype, as suggested by Michael.

changes in v5:
 - As per Stephen's suggestion, Moved CONFIG_HYPERV_TESTING
   to lib/Kconfig.debug.

 - Fixed build issue reported by Kbuild, with Michael's
   suggestion to make hv_debugfs part of the hv_vmbus
   module.

 - updated debugfs-hyperv to show kernel version 5.4

changes in v4:
 - Combined v3 patch 2 into this patch, and changed the
   commit description to reflect this.

 - Moved debugfs code from "vmbus_drv.c" that was in
   previous v3 patch 2, into a new file "debugfs.c" in
   drivers/hv.

 - Updated the Makefile to compile "debugfs.c" if
   CONFIG_HYPERV_TESTING is enabled

 - As per Michael's comments, added empty implementations
   of the new functions, so the compiler will not generate
   code when CONFIG_HYPERV_TESTING is not enabled.

 - Added microseconds into description for files in
   Documentation/ABI/testing/debugfs-hyperv.

Changes in v2:
 - Add #ifdef in Kconfig file so test code will not interfere
   with non-test code.
 - Move test code functions for delay to hyperv_vmbus header
   file.
 - Wrap test code under #ifdef statement.

 Documentation/ABI/testing/debugfs-hyperv |  23 +++
 MAINTAINERS  |   1 +
 drivers/hv/Makefile  |   1 +
 drivers/hv/connection.c  |   1 +
 drivers/hv/hv_debugfs.c  | 178 +++
 drivers/hv/hyperv_vmbus.h|  31 
 drivers/hv/ring_buffer.c |   2 +
 drivers/hv/vmbus_drv.c   |   6 +
 include/linux/hyperv.h   |  19 +++
 lib/Kconfig.debug|   7 +
 10 files changed, 269 insertions(+)
 create mode 100644 Documentation/ABI/testing/debugfs-hyperv
 create mode 100644 drivers/hv/hv_debugfs.c

diff --git a/Documentation/ABI/testing/debugfs-hyperv 
b/Documentation/ABI/testing/debugfs-hyperv
new file mode 100644
index ..9185e1b06bba
--- /dev/null
+++ b/Documentation/ABI/testing/debugfs-hyperv
@@ -0,0 +1,23 @@
+What:   /sys/kernel/debug/hyperv//fuzz_test_state
+Date:   October 2019
+KernelVersion:  5.5
+Contact:Branden Bonaby 
+Description:Fuzz testing status of a vmbus device, whether its in an ON
+state or a OFF state
+Users:  Debugging tools
+
+What:   
/sys/kernel/debug/hyperv//delay/fuzz_test_buffer_interrupt_delay
+Date:   October 2019
+KernelVersion:  5.5
+Contact:Branden Bonaby 
+Description:Fuzz testing buffer interrupt delay value between 0 - 1000
+microseconds (inclusive).
+Users:  Debugging tools
+
+What:   /sys/kernel/debug/hyperv//delay/fuzz_test_message_delay
+Date:   October 2019
+KernelVersion:  5.5
+Contact:Branden Bonaby 
+Description:Fuzz testing message delay value between 0 - 1000 microseconds
+(inclusive).
+Users:  Debugging tools
diff --git a/MAINTAINERS b/MAINTAINERS
index 55199ef7fa74..9801b1924213 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -7581,6 +7581,7 @@ F:include/uapi/linux/hyperv.h
 F: include/asm-generic/mshyperv.h
 F: tools/hv/
 F: Documentation/ABI/stable/sysfs-bus-vmbus
+F: Documentation/ABI/testing/debugfs-hyperv
 
 HYPERBUS SUPPORT
 M: Vignesh Raghavendra 
diff --git a/drivers/hv/Makefile b/drivers/hv/Makefile
index a1eec7177c2d..94daf8240c95 100644
--- a/drivers/hv/Makefile
+++ b/drivers/hv/Makefile
@@ -9,4 +9,5 @@ CFLAGS_hv_balloon.o = -I$(src)
 hv_vmbus-y := vmbus_drv.o \
 hv.o connection.o channel.o \
 channel_mgmt.o ring_buffer.o hv_trace.o
+hv_vmbus-$(CONFIG_HYPERV_TESTING)  += hv_debugfs.o
 hv_utils-y := hv_util.o hv_kvp.o hv_snapshot.o hv_fcopy.o hv_utils_transport.o
diff --git a/drivers/hv/connection.c b/drivers/hv/connection.c
index 6e4c015783ff..7001b1ab4cdd 100644
--- a/drivers/hv/connection.c
+++ b/drivers/hv/connection.c
@@ -361,6 +361,7 @@ void vmbus_on_event(unsigned long data)
 
trace_vmbus_on_event(channel);
 
+   hv_debug_delay_test(channel, INTERRUPT_DELAY);
do {
void (*callback_fn)(void *);
 
diff --git a/drivers/hv/hv_debugfs.c b/drivers/hv/hv_debugfs.c
new file mode 100644
index ..8a2878573582
--- /dev/null
+++ b/drivers/hv/hv_debugfs.c
@@ -0,0 +1,178 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Authors:
+ *   Branden Bonaby 
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+#include "hyperv_vmbus.h"
+
+struct dentry *hv_debug_root;
+
+static int hv_debugfs_delay_get(void *data, u64 *val)
+{
+   *val = *(u32