Re: [PATCH 2/3] drivers: hv: vmbus: add fuzz test attributes to sysfs

2019-08-02 Thread Branden Bonaby
On Fri, Aug 02, 2019 at 09:34:40AM +0200, Vitaly Kuznetsov wrote:
> Branden Bonaby  writes:
> 
> > Expose the test parameters as part of the sysfs channel attributes.
> > We will control the testing state via these attributes.
> >
> > Signed-off-by: Branden Bonaby 
> > ---
> >  Documentation/ABI/stable/sysfs-bus-vmbus | 22 ++
> >  drivers/hv/vmbus_drv.c   | 97 +++-
> >  2 files changed, 118 insertions(+), 1 deletion(-)
> >
> > diff --git a/Documentation/ABI/stable/sysfs-bus-vmbus 
> > b/Documentation/ABI/stable/sysfs-bus-vmbus
> > index 8e8d167eca31..239fcb6fdc75 100644
> > --- a/Documentation/ABI/stable/sysfs-bus-vmbus
> > +++ b/Documentation/ABI/stable/sysfs-bus-vmbus
> > @@ -185,3 +185,25 @@ Contact:Michael Kelley 
> >  Description:Total number of write operations that encountered an 
> > outbound
> > ring buffer full condition
> >  Users:  Debugging tools
> > +
> > +What:   /sys/bus/vmbus/devices//fuzz_test_state
> 
> I would prefer this to go under /sys/kernel/debug/ as this is clearly a
> debug/test feature.
> -- 
> Vitaly

Alright, it is testing so I see what you mean and why the code in 
this patch should go in debugfs. Will fix that and resend.

Branden Bonaby 


Re: [PATCH 2/3] drivers: hv: vmbus: add fuzz test attributes to sysfs

2019-08-02 Thread Vitaly Kuznetsov
Branden Bonaby  writes:

> Expose the test parameters as part of the sysfs channel attributes.
> We will control the testing state via these attributes.
>
> Signed-off-by: Branden Bonaby 
> ---
>  Documentation/ABI/stable/sysfs-bus-vmbus | 22 ++
>  drivers/hv/vmbus_drv.c   | 97 +++-
>  2 files changed, 118 insertions(+), 1 deletion(-)
>
> diff --git a/Documentation/ABI/stable/sysfs-bus-vmbus 
> b/Documentation/ABI/stable/sysfs-bus-vmbus
> index 8e8d167eca31..239fcb6fdc75 100644
> --- a/Documentation/ABI/stable/sysfs-bus-vmbus
> +++ b/Documentation/ABI/stable/sysfs-bus-vmbus
> @@ -185,3 +185,25 @@ Contact:Michael Kelley 
>  Description:Total number of write operations that encountered an outbound
>   ring buffer full condition
>  Users:  Debugging tools
> +
> +What:   /sys/bus/vmbus/devices//fuzz_test_state

I would prefer this to go under /sys/kernel/debug/ as this is clearly a
debug/test feature.


> +Date:   July 2019
> +KernelVersion:  5.2
> +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/bus/vmbus/devices//fuzz_test_buffer_delay
> +Date:   July 2019
> +KernelVersion:  5.2
> +Contact:Branden Bonaby 
> +Description:Fuzz testing buffer delay value between 0 - 1000
> +Users:  Debugging tools
> +
> +What:   /sys/bus/vmbus/devices//fuzz_test_message_delay
> +Date:   July 2019
> +KernelVersion:  5.2
> +Contact:Branden Bonaby 
> +Description:Fuzz testing message delay value between 0 - 1000
> +Users:  Debugging tools
> diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
> index 92b1874b3eb3..0c71fd66ef81 100644
> --- a/drivers/hv/vmbus_drv.c
> +++ b/drivers/hv/vmbus_drv.c
> @@ -22,7 +22,7 @@
>  #include 
>  #include 
>  #include 
> -
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -584,6 +584,98 @@ static ssize_t driver_override_show(struct device *dev,
>  }
>  static DEVICE_ATTR_RW(driver_override);
>  
> +static ssize_t fuzz_test_state_store(struct device *dev,
> +  struct device_attribute *attr,
> +  const char *buf, size_t count)
> +{
> + struct hv_device *hv_dev = device_to_hv_device(dev);
> + struct vmbus_channel *channel = hv_dev->channel;
> + int state;
> + int delay = kstrtoint(buf, 0, );
> +
> + if (delay)
> + return count;
> + if (state)
> + channel->fuzz_testing_state = 1;
> + else
> + channel->fuzz_testing_state = 0;
> + return count;
> +}
> +
> +static ssize_t fuzz_test_state_show(struct device *dev,
> + struct device_attribute *dev_attr,
> + char *buf)
> +{
> + struct hv_device *hv_dev = device_to_hv_device(dev);
> + struct vmbus_channel *channel = hv_dev->channel;
> +
> + return sprintf(buf, "%u\n", channel->fuzz_testing_state);
> +}
> +static DEVICE_ATTR_RW(fuzz_test_state);
> +
> +static ssize_t fuzz_test_buffer_delay_store(struct device *dev,
> + struct device_attribute *attr,
> + const char *buf, size_t count)
> +{
> + struct hv_device *hv_dev = device_to_hv_device(dev);
> + struct vmbus_channel *channel = hv_dev->channel;
> + int val;
> + int delay = kstrtoint(buf, 0, );
> +
> + if (delay)
> + return count;
> + if (val >= 1 && val <= 1000)
> + channel->fuzz_testing_buffer_delay = val;
> + /*Best to not use else statement here since we want
> +  *the buffer delay to remain the same if val > 1000
> +  */
> + else if (val <= 0)
> + channel->fuzz_testing_buffer_delay = 0;
> + return count;
> +}
> +
> +static ssize_t fuzz_test_buffer_delay_show(struct device *dev,
> +struct device_attribute *dev_attr,
> +char *buf)
> +{
> + struct hv_device *hv_dev = device_to_hv_device(dev);
> + struct vmbus_channel *channel = hv_dev->channel;
> +
> + return sprintf(buf, "%u\n", channel->fuzz_testing_buffer_delay);
> +}
> +static DEVICE_ATTR_RW(fuzz_test_buffer_delay);
> +
> +static ssize_t fuzz_test_message_delay_store(struct device *dev,
> +  struct device_attribute *attr,
> +  const char *buf, size_t count)
> +{
> + struct hv_device *hv_dev = device_to_hv_device(dev);
> + struct vmbus_channel *channel = hv_dev->channel;
> + int val;
> + int delay = kstrtoint(buf, 0, );
> +
> + if (delay)
> + return count;
> + if (val >= 1 && val <= 1000)
> + channel->fuzz_testing_message_delay = val;
> + /*Best to 

[PATCH 2/3] drivers: hv: vmbus: add fuzz test attributes to sysfs

2019-08-01 Thread Branden Bonaby
Expose the test parameters as part of the sysfs channel attributes.
We will control the testing state via these attributes.

Signed-off-by: Branden Bonaby 
---
 Documentation/ABI/stable/sysfs-bus-vmbus | 22 ++
 drivers/hv/vmbus_drv.c   | 97 +++-
 2 files changed, 118 insertions(+), 1 deletion(-)

diff --git a/Documentation/ABI/stable/sysfs-bus-vmbus 
b/Documentation/ABI/stable/sysfs-bus-vmbus
index 8e8d167eca31..239fcb6fdc75 100644
--- a/Documentation/ABI/stable/sysfs-bus-vmbus
+++ b/Documentation/ABI/stable/sysfs-bus-vmbus
@@ -185,3 +185,25 @@ Contact:Michael Kelley 
 Description:Total number of write operations that encountered an outbound
ring buffer full condition
 Users:  Debugging tools
+
+What:   /sys/bus/vmbus/devices//fuzz_test_state
+Date:   July 2019
+KernelVersion:  5.2
+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/bus/vmbus/devices//fuzz_test_buffer_delay
+Date:   July 2019
+KernelVersion:  5.2
+Contact:Branden Bonaby 
+Description:Fuzz testing buffer delay value between 0 - 1000
+Users:  Debugging tools
+
+What:   /sys/bus/vmbus/devices//fuzz_test_message_delay
+Date:   July 2019
+KernelVersion:  5.2
+Contact:Branden Bonaby 
+Description:Fuzz testing message delay value between 0 - 1000
+Users:  Debugging tools
diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
index 92b1874b3eb3..0c71fd66ef81 100644
--- a/drivers/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
@@ -22,7 +22,7 @@
 #include 
 #include 
 #include 
-
+#include 
 #include 
 #include 
 #include 
@@ -584,6 +584,98 @@ static ssize_t driver_override_show(struct device *dev,
 }
 static DEVICE_ATTR_RW(driver_override);
 
+static ssize_t fuzz_test_state_store(struct device *dev,
+struct device_attribute *attr,
+const char *buf, size_t count)
+{
+   struct hv_device *hv_dev = device_to_hv_device(dev);
+   struct vmbus_channel *channel = hv_dev->channel;
+   int state;
+   int delay = kstrtoint(buf, 0, );
+
+   if (delay)
+   return count;
+   if (state)
+   channel->fuzz_testing_state = 1;
+   else
+   channel->fuzz_testing_state = 0;
+   return count;
+}
+
+static ssize_t fuzz_test_state_show(struct device *dev,
+   struct device_attribute *dev_attr,
+   char *buf)
+{
+   struct hv_device *hv_dev = device_to_hv_device(dev);
+   struct vmbus_channel *channel = hv_dev->channel;
+
+   return sprintf(buf, "%u\n", channel->fuzz_testing_state);
+}
+static DEVICE_ATTR_RW(fuzz_test_state);
+
+static ssize_t fuzz_test_buffer_delay_store(struct device *dev,
+   struct device_attribute *attr,
+   const char *buf, size_t count)
+{
+   struct hv_device *hv_dev = device_to_hv_device(dev);
+   struct vmbus_channel *channel = hv_dev->channel;
+   int val;
+   int delay = kstrtoint(buf, 0, );
+
+   if (delay)
+   return count;
+   if (val >= 1 && val <= 1000)
+   channel->fuzz_testing_buffer_delay = val;
+   /*Best to not use else statement here since we want
+*the buffer delay to remain the same if val > 1000
+*/
+   else if (val <= 0)
+   channel->fuzz_testing_buffer_delay = 0;
+   return count;
+}
+
+static ssize_t fuzz_test_buffer_delay_show(struct device *dev,
+  struct device_attribute *dev_attr,
+  char *buf)
+{
+   struct hv_device *hv_dev = device_to_hv_device(dev);
+   struct vmbus_channel *channel = hv_dev->channel;
+
+   return sprintf(buf, "%u\n", channel->fuzz_testing_buffer_delay);
+}
+static DEVICE_ATTR_RW(fuzz_test_buffer_delay);
+
+static ssize_t fuzz_test_message_delay_store(struct device *dev,
+struct device_attribute *attr,
+const char *buf, size_t count)
+{
+   struct hv_device *hv_dev = device_to_hv_device(dev);
+   struct vmbus_channel *channel = hv_dev->channel;
+   int val;
+   int delay = kstrtoint(buf, 0, );
+
+   if (delay)
+   return count;
+   if (val >= 1 && val <= 1000)
+   channel->fuzz_testing_message_delay = val;
+   /*Best to not use else statement here since we want
+*the message delay to remain the same if val > 1000
+*/
+   else if (val <= 0)
+   channel->fuzz_testing_message_delay = 0;
+   return count;
+}
+
+static ssize_t fuzz_test_message_delay_show(struct