From: Branden Bonaby <brandonbonaby94@gmail.com>
To: kys@microsoft.com, haiyangz@microsoft.com,
sthemmin@microsoft.com, sashal@kernel.org
Cc: Branden Bonaby <brandonbonaby94@gmail.com>,
linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 2/3] drivers: hv: vmbus: add fuzz test attributes to sysfs
Date: Thu, 1 Aug 2019 16:00:42 -0400 [thread overview]
Message-ID: <20f96dba927eaa42fceeebfc7a6a37f3b1a9ee65.1564527684.git.brandonbonaby94@gmail.com> (raw)
In-Reply-To: <cover.1564527684.git.brandonbonaby94@gmail.com>
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 <brandonbonaby94@gmail.com>
---
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 <mikelley@microsoft.com>
Description: Total number of write operations that encountered an outbound
ring buffer full condition
Users: Debugging tools
+
+What: /sys/bus/vmbus/devices/<UUID>/fuzz_test_state
+Date: July 2019
+KernelVersion: 5.2
+Contact: Branden Bonaby <brandonbonaby94@gmail.com>
+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/<UUID>/fuzz_test_buffer_delay
+Date: July 2019
+KernelVersion: 5.2
+Contact: Branden Bonaby <brandonbonaby94@gmail.com>
+Description: Fuzz testing buffer delay value between 0 - 1000
+Users: Debugging tools
+
+What: /sys/bus/vmbus/devices/<UUID>/fuzz_test_message_delay
+Date: July 2019
+KernelVersion: 5.2
+Contact: Branden Bonaby <brandonbonaby94@gmail.com>
+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 <linux/clockchips.h>
#include <linux/cpu.h>
#include <linux/sched/task_stack.h>
-
+#include <linux/kernel.h>
#include <asm/mshyperv.h>
#include <linux/notifier.h>
#include <linux/ptrace.h>
@@ -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, &state);
+
+ 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, &val);
+
+ 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, &val);
+
+ 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 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_message_delay);
+}
+static DEVICE_ATTR_RW(fuzz_test_message_delay);
/* Set up per device attributes in /sys/bus/vmbus/devices/<bus device> */
static struct attribute *vmbus_dev_attrs[] = {
&dev_attr_id.attr,
@@ -615,6 +707,9 @@ static struct attribute *vmbus_dev_attrs[] = {
&dev_attr_vendor.attr,
&dev_attr_device.attr,
&dev_attr_driver_override.attr,
+ &dev_attr_fuzz_test_state.attr,
+ &dev_attr_fuzz_test_buffer_delay.attr,
+ &dev_attr_fuzz_test_message_delay.attr,
NULL,
};
--
2.17.1
next prev parent reply other threads:[~2019-08-01 20:00 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-01 20:00 [PATCH 0/3] hv: vmbus: add fuzz testing to hv devices Branden Bonaby
2019-08-01 20:00 ` [PATCH 1/3] drivers: hv: vmbus: Introduce latency testing Branden Bonaby
2019-08-02 7:32 ` Vitaly Kuznetsov
2019-08-02 19:02 ` Branden Bonaby
2019-08-01 20:00 ` Branden Bonaby [this message]
2019-08-02 7:34 ` [PATCH 2/3] drivers: hv: vmbus: add fuzz test attributes to sysfs Vitaly Kuznetsov
2019-08-02 19:02 ` Branden Bonaby
2019-08-01 20:00 ` [PATCH 3/3] tools: hv: add vmbus testing tool Branden Bonaby
2019-08-02 7:30 ` [PATCH 0/3] hv: vmbus: add fuzz testing to hv devices Vitaly Kuznetsov
2019-08-02 19:02 ` Branden Bonaby
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20f96dba927eaa42fceeebfc7a6a37f3b1a9ee65.1564527684.git.brandonbonaby94@gmail.com \
--to=brandonbonaby94@gmail.com \
--cc=haiyangz@microsoft.com \
--cc=kys@microsoft.com \
--cc=linux-hyperv@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sashal@kernel.org \
--cc=sthemmin@microsoft.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).