Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp680573ybi; Fri, 2 Aug 2019 02:30:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqzAraLOvWue+jnIF4zvc4gCr4fsLgc3Ir76g7k4z9busF2lA8u+E99XtmHNx89lglSOWUpk X-Received: by 2002:a17:90a:23a4:: with SMTP id g33mr3521751pje.115.1564738255150; Fri, 02 Aug 2019 02:30:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564738255; cv=none; d=google.com; s=arc-20160816; b=wvoYjzLwNOmQcDqhLF/hrxPgSi30ezxNacY5dBeca1LuconQoAkAjJm7kHw9ZUJbQT 3+09mf6Nv69piYQGCv7aAa1dbHtVHzDKg2jzPAXOCVk/fg4ed5AS5Ny8ckeTlxa4dotW nhqNxiJFSAG1XtVqo6sV5H6J2gY5XqoF68TFKIFAr/Hlob1XGw5/jFD1fevBc4oj9q27 X6WZYTDdNmzWlL64XSBMYnrmkLnzG12rMD3TRmKn5jO+8f1uOItjj6+aEiLlB5CowwPo P65jcgR8sltGXC3daxZtYXUokQtWBcocNvf7Hq+wrkIkJA7VHJYczXXRyWrLAq7DGp94 hQ1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from; bh=3z/XjlqQ+U0upcsy+zCqEqLj7uveq+FerIfINm1EQYg=; b=iEo9brLB7eNDLFVppjgjwnXqLDg8M82pqF2TEzckSSF8ijso2oWgjvsm/B0xHf5Rno yEw0cPT4qE10cgcQAVm1ODCJF9BDIQSxswY/zIi9EVYfmTVhBrU4hW99SKKoeSe64Dzl Of4Mu5BXkzVUzUF7+Jt3C7hcllMfogI1EEfoOrjkW3teNDGN4ly2zF0ZQpQ0HOYMTPQH Map20JRx/JKTQhCb7VIMwRSHNFsXlpV5NQo4i7b7x2OuLKO99ld5KIPY83s04m6oL9Zb 7XF/wshkTmt65XopWgRfhzcmKa15ZgVEUT/k2s0hZ+OmFQxaaGgltAm940Kn8UkXB0+W QqBg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u71si39304460pgd.279.2019.08.02.02.30.38; Fri, 02 Aug 2019 02:30:55 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389792AbfHBHep (ORCPT + 99 others); Fri, 2 Aug 2019 03:34:45 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:38483 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389759AbfHBHep (ORCPT ); Fri, 2 Aug 2019 03:34:45 -0400 Received: by mail-wr1-f66.google.com with SMTP id g17so76092195wrr.5 for ; Fri, 02 Aug 2019 00:34:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version; bh=3z/XjlqQ+U0upcsy+zCqEqLj7uveq+FerIfINm1EQYg=; b=bzXL+D2eHD6aasQhELQOVuNHESg6xHsk/IMz3cUl1x9WsBNH6LP2zisZ3ixk/Z7jLx OrMs0QlKuZTguZpm+oUNXabgtXaGpR5dKDAB/yli5dq9TnJ1WBq73sm7FaOr6yFPnYJx Bk2EyEwTa86lubSkPS5D1oDdtwpUbLpeC3Wm+GheCxZIHqlpwxBxfA/HBDX91E/aHH4B RTd3PqDYhF4bjPWP3bT1L1xrpG7p6GHikW9oTIhicSakHpjCF8fAjFdfrcCBm4qQdKkw HqX5jtcQhfdCcwBMwfhf713jmUaES3LWT6HY92OTVr6ynivacppL20+4edbHFV/I3PA+ iK3g== X-Gm-Message-State: APjAAAVv+rxhk/6TI5PS/2uqS/67xacs4C/AyPNhjkr/irECOYRDaO1Y L59tmudONl8niWdBvTXHIoSSTA== X-Received: by 2002:a5d:4ec1:: with SMTP id s1mr135829022wrv.19.1564731282930; Fri, 02 Aug 2019 00:34:42 -0700 (PDT) Received: from vitty.brq.redhat.com (ip-89-176-127-93.net.upcbroadband.cz. [89.176.127.93]) by smtp.gmail.com with ESMTPSA id b2sm97905340wrp.72.2019.08.02.00.34.41 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 02 Aug 2019 00:34:42 -0700 (PDT) From: Vitaly Kuznetsov To: Branden Bonaby Cc: linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org, kys@microsoft.com, haiyangz@microsoft.com, sthemmin@microsoft.com, sashal@kernel.org Subject: Re: [PATCH 2/3] drivers: hv: vmbus: add fuzz test attributes to sysfs In-Reply-To: <20f96dba927eaa42fceeebfc7a6a37f3b1a9ee65.1564527684.git.brandonbonaby94@gmail.com> References: <20f96dba927eaa42fceeebfc7a6a37f3b1a9ee65.1564527684.git.brandonbonaby94@gmail.com> Date: Fri, 02 Aug 2019 09:34:40 +0200 Message-ID: <87a7csggvj.fsf@vitty.brq.redhat.com> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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, &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/ */ > 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, > }; -- Vitaly