Drivers: hv: vmbus: Fix sysfs functions that display monitor id and page data
Subsystems (2)
cover Drivers: hv: vmbus: Fix sysfs functions that display monitor id and page data
Some of the monitor id and monitor page data sysfs files display incorrect data. This patchset provides the following changes:
1) Change the monitor_pages index in server_monitor_pending_show() to '0', which is the correct index for the server.
2) If monitor pages are not allocated to a channel, display nothing in the channel's monitor id and monitor page data sysfs files. The data that is currently shown in sysfs is incorrect.
Kimberly Brown (2):
Drivers: hv: vmbus: Change server monitor_pages index to 0
Drivers: hv: vmbus: Display nothing in sysfs if monitor_allocated not
set
Documentation/ABI/stable/sysfs-bus-vmbus | 9 ++++-- drivers/hv/vmbus_drv.c | 39 +++++++++++++++++++++++- 2 files changed, 44 insertions(+), 4 deletions(-)
Signature · 1 line
2.17.1
PATCH 1/2 Drivers: hv: vmbus: Change server monitor_pages index to 0
Change the monitor_pages index in server_monitor_pending_show() to '0'. '0' is the correct monitor_pages index for the server. A comment for the monitor_pages field in the vmbus_connection struct definition indicates that the 1st page is for parent->child notifications. In addition, the server_monitor_latency_show() and server_monitor_conn_id_show() functions use monitor_pages index '0'.
--- drivers/hv/vmbus_drv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hv/vmbus_drv.c +1 -1
@@ -234,7 +234,7 @@ static ssize_t server_monitor_pending_show(struct device *dev,return -ENODEV ;return sprintf (buf,"%d\n" ,channel_pending (hv_dev->channel, - vmbus_connection.monitor_pages[1 ])); + vmbus_connection.monitor_pages[0 ])); }static DEVICE_ATTR_RO (server_monitor_pending);
Signature · 1 line
2.17.1
PATCH 2/2 Drivers: hv: vmbus: Display nothing in sysfs if monitor_allocated not set
In reply to Kimberly BrownIf monitor pages are not allocated to a channel, the channel does not have a valid monitor id or valid monitor page data. In these cases, some of the "_show" functions display incorrect data. The "_show" functions that display monitor page data access and display data that is beyond the bounds of the hv_monitor_page array fields, which is obviously incorrect. The "_show" functions that display the monitor id display an invalid monitor id.
The "channel->offermsg.monitor_allocated" value can be used to determine whether monitor pages have been allocated to a channel. In the affected "_show" functions, verify that "channel->offermsg.monitor_allocated" is set before accessing the monitor id or the monitor_page data. If "channel->offermsg.monitor_allocated" is not set, display nothing.
--- Documentation/ABI/stable/sysfs-bus-vmbus | 9 ++++-- drivers/hv/vmbus_drv.c | 37 ++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 3 deletions(-)
Documentation/ABI/stable/sysfs-bus-vmbus +6 -3
@@ -81,7 +81,8 @@ What: /sys/bus/vmbus/devices/<UUID>/channels/<N>/latency Date: September. 2017 KernelVersion: 4.14 Contact: Stephen Hemminger <[email protected]> -Description: Channel signaling latency +Description: Channel signaling latency. If monitor pages are not allocated + to the channel, nothing is displayed. Users: Debugging tools What: /sys/bus/vmbus/devices/<UUID>/channels/<N>/out_mask
@@ -95,7 +96,8 @@ What: /sys/bus/vmbus/devices/<UUID>/channels/<N>/pending Date: September. 2017 KernelVersion: 4.14 Contact: Stephen Hemminger <[email protected]> -Description: Channel interrupt pending state +Description: Channel interrupt pending state. If monitor pages are not + allocated to the channel, nothing is displayed. Users: Debugging tools What: /sys/bus/vmbus/devices/<UUID>/channels/<N>/read_avail
@@ -137,7 +139,8 @@ What: /sys/bus/vmbus/devices/<UUID>/channels/<N>/monitor_id Date: January. 2018 KernelVersion: 4.16 Contact: Stephen Hemminger <[email protected]> -Description: Monitor bit associated with channel +Description: Monitor bit associated with channel. If monitor pages are not + allocated to the channel, nothing is displayed. Users: Debugging tools and userspace drivers What: /sys/bus/vmbus/devices/<UUID>/channels/<N>/ring
drivers/hv/vmbus_drv.c +37 -0
@@ -171,6 +171,10 @@ static ssize_t monitor_id_show(struct device *dev,if (!hv_dev->channel)return -ENODEV ; + +if (!hv_dev->channel->offermsg.monitor_allocated) +return sprintf (buf,"\n" ); +return sprintf (buf,"%d\n" , hv_dev->channel->offermsg.monitorid); }static DEVICE_ATTR_RO (monitor_id);
@@ -232,6 +236,10 @@ static ssize_t server_monitor_pending_show(struct device *dev,if (!hv_dev->channel)return -ENODEV ; + +if (!hv_dev->channel->offermsg.monitor_allocated) +return sprintf (buf,"\n" ); +return sprintf (buf,"%d\n" ,channel_pending (hv_dev->channel, vmbus_connection.monitor_pages[0 ]));
@@ -246,6 +254,10 @@ static ssize_t client_monitor_pending_show(struct device *dev,if (!hv_dev->channel)return -ENODEV ; + +if (!hv_dev->channel->offermsg.monitor_allocated) +return sprintf (buf,"\n" ); +return sprintf (buf,"%d\n" ,channel_pending (hv_dev->channel, vmbus_connection.monitor_pages[1 ]));
@@ -260,6 +272,10 @@ static ssize_t server_monitor_latency_show(struct device *dev,if (!hv_dev->channel)return -ENODEV ; + +if (!hv_dev->channel->offermsg.monitor_allocated) +return sprintf (buf,"\n" ); +return sprintf (buf,"%d\n" ,channel_latency (hv_dev->channel, vmbus_connection.monitor_pages[0 ]));
@@ -274,6 +290,10 @@ static ssize_t client_monitor_latency_show(struct device *dev,if (!hv_dev->channel)return -ENODEV ; + +if (!hv_dev->channel->offermsg.monitor_allocated) +return sprintf (buf,"\n" ); +return sprintf (buf,"%d\n" ,channel_latency (hv_dev->channel, vmbus_connection.monitor_pages[1 ]));
@@ -288,6 +308,10 @@ static ssize_t server_monitor_conn_id_show(struct device *dev,if (!hv_dev->channel)return -ENODEV ; + +if (!hv_dev->channel->offermsg.monitor_allocated) +return sprintf (buf,"\n" ); +return sprintf (buf,"%d\n" ,channel_conn_id (hv_dev->channel, vmbus_connection.monitor_pages[0 ]));
@@ -302,6 +326,10 @@ static ssize_t client_monitor_conn_id_show(struct device *dev,if (!hv_dev->channel)return -ENODEV ; + +if (!hv_dev->channel->offermsg.monitor_allocated) +return sprintf (buf,"\n" ); +return sprintf (buf,"%d\n" ,channel_conn_id (hv_dev->channel, vmbus_connection.monitor_pages[1 ]));
@@ -1469,6 +1497,9 @@ static VMBUS_CHAN_ATTR(cpu, S_IRUGO, show_target_cpu, NULL);static ssize_t channel_pending_show (const struct vmbus_channel *channel,char *buf) { +if (!channel->offermsg.monitor_allocated) +return sprintf (buf,"\n" ); +return sprintf (buf,"%d\n" ,channel_pending (channel, vmbus_connection.monitor_pages[1 ]));
@@ -1478,6 +1509,9 @@ static VMBUS_CHAN_ATTR(pending, S_IRUGO, channel_pending_show, NULL);static ssize_t channel_latency_show (const struct vmbus_channel *channel,char *buf) { +if (!channel->offermsg.monitor_allocated) +return sprintf (buf,"\n" ); +return sprintf (buf,"%d\n" ,channel_latency (channel, vmbus_connection.monitor_pages[1 ]));
@@ -1499,6 +1533,9 @@ static VMBUS_CHAN_ATTR(events, S_IRUGO, channel_events_show, NULL);static ssize_t subchannel_monitor_id_show (const struct vmbus_channel *channel,char *buf) { +if (!channel->offermsg.monitor_allocated) +return sprintf (buf,"\n" ); +return sprintf (buf,"%u\n" , channel->offermsg.monitorid); } static VMBUS_CHAN_ATTR(monitor_id, S_IRUGO, subchannel_monitor_id_show, NULL);
Signature · 1 line
2.17.1
Re: [PATCH 1/2] Drivers: hv: vmbus: Change server monitor_pages index to 0
In reply to Kimberly BrownQuoted 17 lines · On Fri, 8 Feb 2019 04:58:52 -0500 Kimberly Brown <[email protected]> wrote:
Change the
monitor_pagesindex inserver_monitor_pending_show()to '0'. '0' is the correctmonitor_pagesindex for the server. A comment for themonitor_pagesfield in thevmbus_connectionstruct definition indicates that the 1st page is forparent->childnotifications. In addition, theserver_monitor_latency_show()andserver_monitor_conn_id_show()functions usemonitor_pagesindex '0'.Signed-off-by Kimberly Brown <[email protected]>--- drivers/hv/vmbus_drv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/hv/vmbus_drv.c +0
-0
drivers/hv/vmbus_drv.c static ssize_t server_monitor_pending_show(struct device *dev, · line 239
Quoted 7 lines
drivers/hv/vmbus_drv.c +1
-1@@ -234,7 +234,7 @@ static ssize_t server_monitor_pending_show(struct device *dev,return -ENODEV ;return sprintf (buf,"%d\n" ,channel_pending (hv_dev->channel, - vmbus_connection.monitor_pages[1 ])); + vmbus_connection.monitor_pages[0 ])); }static DEVICE_ATTR_RO (server_monitor_pending);
Looks good.
I wonder if ever gets used though since it returned incorrect data...
Re: [PATCH 2/2] Drivers: hv: vmbus: Display nothing in sysfs if monitor_allocated not set
In reply to Kimberly BrownOn Fri, 8 Feb 2019 05:01:12 -0500
Kimberly Brown <[email protected]> wrote:
You are right, the current behavior is broken.
It would be good to add a description of under what conditions monitor is not used. Is this some part of a project emulating Hyper-V?
drivers/hv/vmbus_drv.c static ssize_t monitor_id_show(struct device *dev, · line 176
Quoted 3 lines
drivers/hv/vmbus_drv.c +3
-0+ +if (!hv_dev->channel->offermsg.monitor_allocated) +return sprintf (buf,"\n" );
If monitor is not used, why not return an error instead of empty data. Any program (or user) would have to handle that already.
Re: [PATCH 2/2] Drivers: hv: vmbus: Display nothing in sysfs if monitor_allocated not set
Quoted 8 lines · Stephen Hemminger
On Fri, 8 Feb 2019 05:01:12 -0500
Kimberly Brown <[email protected]> wrote:You are right, the current behavior is broken.
It would be good to add a description of under what conditions monitor is not used. Is this some part of a project emulating Hyper-V?
I'm not sure which conditions determine whether the monitor mechanism is used. I've searched the Hypervisor TLFS, and I couldn't find any information. If you have any suggestions for where I can find this information, please let me know.
No, I'm not working on a project emulating Hyper-V.
Quoted 7 lines
drivers/hv/vmbus_drv.c static ssize_t monitor_id_show(struct device *dev, · line 176
Quoted 4 lines
drivers/hv/vmbus_drv.c +3
-0+ +if (!hv_dev->channel->offermsg.monitor_allocated) +return sprintf (buf,"\n" );If monitor is not used, why not return an error instead of empty data. Any program (or user) would have to handle that already.
I think that returning an error instead is fine. I'll make this change in the next version of the patch.
Re: [PATCH 2/2] Drivers: hv: vmbus: Display nothing in sysfs if monitor_allocated not set
Quoted 10 lines · On Mon, 11 Feb 2019 02:01:18 -0500 Kimberly Brown <[email protected]> wrote:
Quoted 8 lines · Stephen Hemminger
On Fri, 8 Feb 2019 05:01:12 -0500
Kimberly Brown <[email protected]> wrote:You are right, the current behavior is broken.
It would be good to add a description of under what conditions monitor is not used. Is this some part of a project emulating Hyper-V?
Quoted 4 lines
I'm not sure which conditions determine whether the monitor mechanism is used. I've searched the Hypervisor TLFS, and I couldn't find any information. If you have any suggestions for where I can find this information, please let me know.
The monitor page stuff pre-dates my involvement with Hyper-V. KY might know. But based on comments it looks like it was added to avoid hypercalls for each message. It probably showed up in Windows Server 2012 timeframe.
To test you might want to dig up Windows Server 2008.
Quoted 1 line
No, I'm not working on a project emulating Hyper-V.
OK, I had heard that KVM project was doing something with QEMU.
Quoted 10 lines
Quoted 7 lines
drivers/hv/vmbus_drv.c static ssize_t monitor_id_show(struct device *dev, · line 176
Quoted 4 lines
drivers/hv/vmbus_drv.c +3
-0+ +if (!hv_dev->channel->offermsg.monitor_allocated) +return sprintf (buf,"\n" );If monitor is not used, why not return an error instead of empty data. Any program (or user) would have to handle that already.
I think that returning an error instead is fine. I'll make this change in the next version of the patch.
Re: [PATCH 2/2] Drivers: hv: vmbus: Display nothing in sysfs if monitor_allocated not set
Quoted 18 lines · Stephen Hemminger
Quoted 10 lines · On Mon, 11 Feb 2019 02:01:18 -0500 Kimberly Brown <[email protected]> wrote:
Quoted 8 lines · Stephen Hemminger
On Fri, 8 Feb 2019 05:01:12 -0500
Kimberly Brown <[email protected]> wrote:You are right, the current behavior is broken.
It would be good to add a description of under what conditions monitor is not used. Is this some part of a project emulating Hyper-V?Quoted 4 lines
I'm not sure which conditions determine whether the monitor mechanism is used. I've searched the Hypervisor TLFS, and I couldn't find any information. If you have any suggestions for where I can find this information, please let me know.
Quoted 6 lines
The monitor page stuff pre-dates my involvement with Hyper-V. KY might know. But based on comments it looks like it was added to avoid hypercalls for each message. It probably showed up in Windows Server 2012 timeframe.
To test you might want to dig up Windows Server 2008.
It looks like the monitor mechanism has always been used. It's present in the earliest commit that I can find: 3e7ee4902fe6 ("add the Hyper-V virtual bus") from 2009.
I propose that the following sentences be added to the sysfs documentation for the affected attributes:
"The monitor page mechanism is used for performance critical channels (storage, network, etc.). Channels that do not use the monitor page mechanism will return EINVAL."
I think that this provides sufficient information for a user to understand why opening an affected file can return EINVAL. What do you think?
Re: [PATCH 2/2] Drivers: hv: vmbus: Display nothing in sysfs if monitor_allocated not set
Quoted 33 lines · On Thu, 14 Feb 2019 01:11:03 -0500 Kimberly Brown <[email protected]> wrote:
Quoted 18 lines · Stephen Hemminger
Quoted 10 lines · On Mon, 11 Feb 2019 02:01:18 -0500 Kimberly Brown <[email protected]> wrote:
Quoted 8 lines · Stephen Hemminger
On Fri, 8 Feb 2019 05:01:12 -0500
Kimberly Brown <[email protected]> wrote:You are right, the current behavior is broken.
It would be good to add a description of under what conditions monitor is not used. Is this some part of a project emulating Hyper-V?Quoted 4 lines
I'm not sure which conditions determine whether the monitor mechanism is used. I've searched the Hypervisor TLFS, and I couldn't find any information. If you have any suggestions for where I can find this information, please let me know.
Quoted 6 lines
The monitor page stuff pre-dates my involvement with Hyper-V. KY might know. But based on comments it looks like it was added to avoid hypercalls for each message. It probably showed up in Windows Server 2012 timeframe.
To test you might want to dig up Windows Server 2008.
It looks like the monitor mechanism has always been used. It's present in the earliest commit that I can find:
3e7ee4902fe6("add the Hyper-V virtual bus") from 2009.I propose that the following sentences be added to the sysfs documentation for the affected attributes:
Quoted 6 lines
"The monitor page mechanism is used for performance critical channels (storage, network, etc.). Channels that do not use the monitor page mechanism will return EINVAL."
I think that this provides sufficient information for a user to understand why opening an affected file can return EINVAL. What do you think?
Thanks for following up. I agree with you EINVAL works as a solution. My understanding is that their are two ways a channel can work. The first one is for the guest to send a hyper call to the host to indicate when data is available. The other is for the guest to indicate by setting a bit in shared memory with host.
The shared memory approach reduces host/guest overhead and allows for more opportunities for batching in the ring. The host checks the shared memory on a polling interval defined in the latency field.
The hypercall method does not use the monitor page. It has lower latency (no polling).
v2 cover Drivers: hv: vmbus: Fix sysfs functions that display monitor id and page data
In reply to Kimberly BrownSome of the monitor id and monitor page data sysfs files display incorrect data. This patchset provides the following changes:
1) Change the monitor_pages index in server_monitor_pending_show() to '0', which is the correct index for the server.
2) If monitor pages are not allocated to a channel, return -EINVAL when the channel's monitor id and monitor page data sysfs files are opened. The data that is currently shown in sysfs is incorrect.
Changes in v2:
Patch 1: "Change server monitor_pages index to 0"
- Added the "Acked-by" line received for v1.
Patch 2: "Return -EINVAL if monitor_allocated not set"
- Changed the return value for cases where monitor_allocated is not set to "-EINVAL" as suggested by S. Hemminger.
- Updated the commit message to provide more details about the monitor page mechanism as suggested by S. Hemminger.
- Updated the sysfs documentation to describe the new return value.
Kimberly Brown (2):
Drivers: hv: vmbus: Change server monitor_pages index to 0
Drivers: hv: vmbus: Return -EINVAL if monitor_allocated not set
Documentation/ABI/stable/sysfs-bus-vmbus | 15 +++++++-- drivers/hv/vmbus_drv.c | 39 +++++++++++++++++++++++- 2 files changed, 50 insertions(+), 4 deletions(-)
Signature · 1 line
2.17.1
PATCH v2 1/2 Drivers: hv: vmbus: Change server monitor_pages index to 0
Change the monitor_pages index in server_monitor_pending_show() to '0'. '0' is the correct monitor_pages index for the server. A comment for the monitor_pages field in the vmbus_connection struct definition indicates that the 1st page is for parent->child notifications. In addition, the server_monitor_latency_show() and server_monitor_conn_id_show() functions use monitor_pages index '0'.
--- drivers/hv/vmbus_drv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hv/vmbus_drv.c +1 -1
@@ -234,7 +234,7 @@ static ssize_t server_monitor_pending_show(struct device *dev,return -ENODEV ;return sprintf (buf,"%d\n" ,channel_pending (hv_dev->channel, - vmbus_connection.monitor_pages[1 ])); + vmbus_connection.monitor_pages[0 ])); }static DEVICE_ATTR_RO (server_monitor_pending);
Signature · 1 line
2.17.1
PATCH v2 2/2 Drivers: hv: vmbus: Return -EINVAL if monitor_allocated not set
In reply to a message not in the archiveThere are two methods for signaling the host: the monitor page mechanism and hypercalls. The monitor page mechanism is used by performance critical channels (storage, networking, etc.) because it provides improved throughput. However, latency is increased. Monitor pages are allocated to these channels.
Monitor pages are not allocated to channels that do not use the monitor page mechanism. Therefore, these channels do not have a valid monitor id or valid monitor page data. In these cases, some of the "_show" functions return incorrect data. They return an invalid monitor id and data that is beyond the bounds of the hv_monitor_page array fields.
The "channel->offermsg.monitor_allocated" value can be used to determine whether monitor pages have been allocated to a channel. In the affected "_show" functions, verify that "channel->offermsg.monitor_allocated" is set before accessing the monitor id or the monitor page data. If "channel->offermsg.monitor_allocated" is not set, return -EINVAL.
--- Documentation/ABI/stable/sysfs-bus-vmbus | 15 ++++++++-- drivers/hv/vmbus_drv.c | 37 ++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 3 deletions(-)
Documentation/ABI/stable/sysfs-bus-vmbus +12 -3
@@ -81,7 +81,10 @@ What: /sys/bus/vmbus/devices/<UUID>/channels/<N>/latency Date: September. 2017 KernelVersion: 4.14 Contact: Stephen Hemminger <[email protected]> -Description: Channel signaling latency +Description: Channel signaling latency. The monitor page mechanism is used + for performance critical channels (storage, network, etc.). + Channels that do not use the monitor page mechanism will return + EINVAL. Users: Debugging tools What: /sys/bus/vmbus/devices/<UUID>/channels/<N>/out_mask
@@ -95,7 +98,10 @@ What: /sys/bus/vmbus/devices/<UUID>/channels/<N>/pending Date: September. 2017 KernelVersion: 4.14 Contact: Stephen Hemminger <[email protected]> -Description: Channel interrupt pending state +Description: Channel interrupt pending state. The monitor page mechanism is + used for performance critical channels (storage, network, + etc.). Channels that do not use the monitor page mechanism will + return EINVAL. Users: Debugging tools What: /sys/bus/vmbus/devices/<UUID>/channels/<N>/read_avail
@@ -137,7 +143,10 @@ What: /sys/bus/vmbus/devices/<UUID>/channels/<N>/monitor_id Date: January. 2018 KernelVersion: 4.16 Contact: Stephen Hemminger <[email protected]> -Description: Monitor bit associated with channel +Description: Monitor bit associated with channel. The monitor page mechanism + is used for performance critical channels (storage, network, + etc.). Channels that do not use the monitor page mechanism will + return EINVAL. Users: Debugging tools and userspace drivers What: /sys/bus/vmbus/devices/<UUID>/channels/<N>/ring
drivers/hv/vmbus_drv.c +37 -0
@@ -171,6 +171,10 @@ static ssize_t monitor_id_show(struct device *dev,if (!hv_dev->channel)return -ENODEV ; + +if (!hv_dev->channel->offermsg.monitor_allocated) +return -EINVAL ; +return sprintf (buf,"%d\n" , hv_dev->channel->offermsg.monitorid); }static DEVICE_ATTR_RO (monitor_id);
@@ -232,6 +236,10 @@ static ssize_t server_monitor_pending_show(struct device *dev,if (!hv_dev->channel)return -ENODEV ; + +if (!hv_dev->channel->offermsg.monitor_allocated) +return -EINVAL ; +return sprintf (buf,"%d\n" ,channel_pending (hv_dev->channel, vmbus_connection.monitor_pages[0 ]));
@@ -246,6 +254,10 @@ static ssize_t client_monitor_pending_show(struct device *dev,if (!hv_dev->channel)return -ENODEV ; + +if (!hv_dev->channel->offermsg.monitor_allocated) +return -EINVAL ; +return sprintf (buf,"%d\n" ,channel_pending (hv_dev->channel, vmbus_connection.monitor_pages[1 ]));
@@ -260,6 +272,10 @@ static ssize_t server_monitor_latency_show(struct device *dev,if (!hv_dev->channel)return -ENODEV ; + +if (!hv_dev->channel->offermsg.monitor_allocated) +return -EINVAL ; +return sprintf (buf,"%d\n" ,channel_latency (hv_dev->channel, vmbus_connection.monitor_pages[0 ]));
@@ -274,6 +290,10 @@ static ssize_t client_monitor_latency_show(struct device *dev,if (!hv_dev->channel)return -ENODEV ; + +if (!hv_dev->channel->offermsg.monitor_allocated) +return -EINVAL ; +return sprintf (buf,"%d\n" ,channel_latency (hv_dev->channel, vmbus_connection.monitor_pages[1 ]));
@@ -288,6 +308,10 @@ static ssize_t server_monitor_conn_id_show(struct device *dev,if (!hv_dev->channel)return -ENODEV ; + +if (!hv_dev->channel->offermsg.monitor_allocated) +return -EINVAL ; +return sprintf (buf,"%d\n" ,channel_conn_id (hv_dev->channel, vmbus_connection.monitor_pages[0 ]));
@@ -302,6 +326,10 @@ static ssize_t client_monitor_conn_id_show(struct device *dev,if (!hv_dev->channel)return -ENODEV ; + +if (!hv_dev->channel->offermsg.monitor_allocated) +return -EINVAL ; +return sprintf (buf,"%d\n" ,channel_conn_id (hv_dev->channel, vmbus_connection.monitor_pages[1 ]));
@@ -1469,6 +1497,9 @@ static VMBUS_CHAN_ATTR(cpu, S_IRUGO, show_target_cpu, NULL);static ssize_t channel_pending_show (const struct vmbus_channel *channel,char *buf) { +if (!channel->offermsg.monitor_allocated) +return -EINVAL ; +return sprintf (buf,"%d\n" ,channel_pending (channel, vmbus_connection.monitor_pages[1 ]));
@@ -1478,6 +1509,9 @@ static VMBUS_CHAN_ATTR(pending, S_IRUGO, channel_pending_show, NULL);static ssize_t channel_latency_show (const struct vmbus_channel *channel,char *buf) { +if (!channel->offermsg.monitor_allocated) +return -EINVAL ; +return sprintf (buf,"%d\n" ,channel_latency (channel, vmbus_connection.monitor_pages[1 ]));
@@ -1499,6 +1533,9 @@ static VMBUS_CHAN_ATTR(events, S_IRUGO, channel_events_show, NULL);static ssize_t subchannel_monitor_id_show (const struct vmbus_channel *channel,char *buf) { +if (!channel->offermsg.monitor_allocated) +return -EINVAL ; +return sprintf (buf,"%u\n" , channel->offermsg.monitorid); } static VMBUS_CHAN_ATTR(monitor_id, S_IRUGO, subchannel_monitor_id_show, NULL);
Signature · 1 line
2.17.1
RE: [PATCH v2 1/2] Drivers: hv: vmbus: Change server monitor_pages index to 0
In reply to Kimberly BrownFrom: Kimberly Brown <[email protected]> Sent: Monday, February 18, 2019 9:38 PM
Quoted 8 lines
Change the
monitor_pagesindex inserver_monitor_pending_show()to '0'. '0' is the correctmonitor_pagesindex for the server. A comment for themonitor_pagesfield in thevmbus_connectionstruct definition indicates that the 1st page is forparent->childnotifications. In addition, theserver_monitor_latency_show()andserver_monitor_conn_id_show()functions usemonitor_pagesindex '0'.
Quoted 6 lines
Signed-off-by Kimberly Brown <[email protected]>--- drivers/hv/vmbus_drv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
RE: [PATCH v2 2/2] Drivers: hv: vmbus: Return -EINVAL if monitor_allocated not set
In reply to Kimberly BrownFrom: Kimberly Brown <[email protected]> Sent: Monday, February 18, 2019 9:38 PM
Quoted 13 lines
There are two methods for signaling the host: the monitor page mechanism and hypercalls. The monitor page mechanism is used by performance critical channels (storage, networking, etc.) because it provides improved throughput. However, latency is increased. Monitor pages are allocated to these channels.
Monitor pages are not allocated to channels that do not use the monitor page mechanism. Therefore, these channels do not have a valid monitor id or valid monitor page data. In these cases, some of the "
_show" functions return incorrect data. They return an invalid monitor id and data that is beyond the bounds of thehv_monitor_pagearray fields.
Quoted 8 lines
The "
channel->offermsg.monitor_allocated" value can be used to determine whether monitor pages have been allocated to a channel. In the affected "_show" functions, verify that "channel->offermsg.monitor_allocated" is set before accessing the monitor id or the monitor page data. If "channel->offermsg.monitor_allocated" is not set, return-EINVAL.Signed-off-by Kimberly Brown <[email protected]>
PATCH v3 1/1 Drivers: hv: vmbus: Expose monitor data when channel uses monitor pages
In reply to Kimberly BrownThere are two methods for signaling the host: the monitor page mechanism and hypercalls. The monitor page mechanism is used by performance critical channels (storage, networking, etc.) because it provides improved throughput. However, latency is increased. Monitor pages are allocated to these channels.
Monitor pages are not allocated to channels that do not use the monitor page mechanism. Therefore, these channels do not have a valid monitor id or valid monitor page data. In these cases, some of the "_show" functions return incorrect data. They return an invalid monitor id and data that is beyond the bounds of the hv_monitor_page array fields.
The "channel->offermsg.monitor_allocated" value can be used to determine whether monitor pages have been allocated to a channel.
Move the device-level monitor page attributes to a separate attribute_group struct. If the channel uses the monitor page mechanism, set up the sysfs files for these attributes in vmbus_device_register().
Move the channel-level monitor page attributes to a separate attribute_group struct. If the channel uses the monitor page mechanism, set up the sysfs files for these attributes in vmbus_add_channel_kobj().
---
Changes in v3:
The monitor "_show" functions no longer return an error when a channel does not use the monitor page mechanism. Instead, the monitor page sysfs files are created only when a channel uses the monitor page mechanism. This change was suggested by G. Kroah-Hartman.
Note: this patch was originally patch 2/2 in a patchset. Patch 1/2 has already been added to char-misc-testing, so I'm not resending it.
Changes in v2:
- Changed the return value for cases where monitor_allocated is not set to "-EINVAL".
- Updated the commit message to provide more details about the monitor page mechanism.
- Updated the sysfs documentation to describe the new return value.
Documentation/ABI/stable/sysfs-bus-vmbus | 12 ++++-- drivers/hv/vmbus_drv.c | 52 +++++++++++++++++++----- 2 files changed, 51 insertions(+), 13 deletions(-)
Documentation/ABI/stable/sysfs-bus-vmbus +9 -3
@@ -81,7 +81,9 @@ What: /sys/bus/vmbus/devices/<UUID>/channels/<N>/latency Date: September. 2017 KernelVersion: 4.14 Contact: Stephen Hemminger <[email protected]> -Description: Channel signaling latency +Description: Channel signaling latency. This file is available only for + performance critical channels (storage, network, etc.) that use + the monitor page mechanism. Users: Debugging tools What: /sys/bus/vmbus/devices/<UUID>/channels/<N>/out_mask
@@ -95,7 +97,9 @@ What: /sys/bus/vmbus/devices/<UUID>/channels/<N>/pending Date: September. 2017 KernelVersion: 4.14 Contact: Stephen Hemminger <[email protected]> -Description: Channel interrupt pending state +Description: Channel interrupt pending state. This file is available only for + performance critical channels (storage, network, etc.) that use + the monitor page mechanism. Users: Debugging tools What: /sys/bus/vmbus/devices/<UUID>/channels/<N>/read_avail
@@ -137,7 +141,9 @@ What: /sys/bus/vmbus/devices/<UUID>/channels/<N>/monitor_id Date: January. 2018 KernelVersion: 4.16 Contact: Stephen Hemminger <[email protected]> -Description: Monitor bit associated with channel +Description: Monitor bit associated with channel. This file is available only + for performance critical channels (storage, network, etc.) that + use the monitor page mechanism. Users: Debugging tools and userspace drivers What: /sys/bus/vmbus/devices/<UUID>/channels/<N>/ring
drivers/hv/vmbus_drv.c +42 -10
98 lines not on this page · raw message
Signature · 1 line
2.17.1
Re: [PATCH v3] Drivers: hv: vmbus: Expose monitor data when channel uses monitor pages
Quoted 115 lines · Kimberly Brown
There are two methods for signaling the host: the monitor page mechanism and hypercalls. The monitor page mechanism is used by performance critical channels (storage, networking, etc.) because it provides improved throughput. However, latency is increased. Monitor pages are allocated to these channels.
Monitor pages are not allocated to channels that do not use the monitor page mechanism. Therefore, these channels do not have a valid monitor id or valid monitor page data. In these cases, some of the "
_show" functions return incorrect data. They return an invalid monitor id and data that is beyond the bounds of thehv_monitor_pagearray fields.The "
channel->offermsg.monitor_allocated" value can be used to determine whether monitor pages have been allocated to a channel.Move the device-level monitor page attributes to a separate
attribute_groupstruct. If the channel uses the monitor page mechanism, set up the sysfs files for these attributes invmbus_device_register().Move the channel-level monitor page attributes to a separate
attribute_groupstruct. If the channel uses the monitor page mechanism, set up the sysfs files for these attributes invmbus_add_channel_kobj().Signed-off-by Kimberly Brown <[email protected]>---
Changes in v3:
The monitor "_show" functions no longer return an error when a channel does not use the monitor page mechanism. Instead, the monitor page sysfs files are created only when a channel uses the monitor page mechanism. This change was suggested by G. Kroah-Hartman.Note: this patch was originally patch 2/2 in a patchset. Patch 1/2 has already been added to char-misc-testing, so I'm not resending it.
Changes in v2:
- Changed the return value for cases wheremonitor_allocatedis not set to "-EINVAL".
- Updated the commit message to provide more details about the monitor page mechanism.
- Updated the sysfs documentation to describe the new return value.Documentation/ABI/stable/sysfs-bus-vmbus | 12 ++++-- drivers/hv/vmbus_drv.c | 52 +++++++++++++++++++----- 2 files changed, 51 insertions(+), 13 deletions(-)Documentation/ABI/stable/sysfs-bus-vmbus +9
-3@@ -81,7 +81,9 @@ What: /sys/bus/vmbus/devices/<UUID>/channels/<N>/latency Date: September. 2017 KernelVersion: 4.14 Contact: Stephen Hemminger <[email protected]> -Description: Channel signaling latency +Description: Channel signaling latency. This file is available only for + performance critical channels (storage, network, etc.) that use + the monitor page mechanism. Users: Debugging tools What: /sys/bus/vmbus/devices/<UUID>/channels/<N>/out_mask@@ -95,7 +97,9 @@ What: /sys/bus/vmbus/devices/<UUID>/channels/<N>/pending Date: September. 2017 KernelVersion: 4.14 Contact: Stephen Hemminger <[email protected]> -Description: Channel interrupt pending state +Description: Channel interrupt pending state. This file is available only for + performance critical channels (storage, network, etc.) that use + the monitor page mechanism. Users: Debugging tools What: /sys/bus/vmbus/devices/<UUID>/channels/<N>/read_avail@@ -137,7 +141,9 @@ What: /sys/bus/vmbus/devices/<UUID>/channels/<N>/monitor_id Date: January. 2018 KernelVersion: 4.16 Contact: Stephen Hemminger <[email protected]> -Description: Monitor bit associated with channel +Description: Monitor bit associated with channel. This file is available only + for performance critical channels (storage, network, etc.) that + use the monitor page mechanism. Users: Debugging tools and userspace drivers What: /sys/bus/vmbus/devices/<UUID>/channels/<N>/ringdrivers/hv/vmbus_drv.c +5
-7@@ -601,19 +601,12 @@ static DEVICE_ATTR_RW(driver_override);static struct attribute *vmbus_dev_attrs[] = { &dev_attr_id.attr, &dev_attr_state.attr, - &dev_attr_monitor_id.attr, &dev_attr_class_id.attr, &dev_attr_device_id.attr, &dev_attr_modalias.attr, #ifdef CONFIG_NUMA &dev_attr_numa_node.attr, #endif - &dev_attr_server_monitor_pending.attr, - &dev_attr_client_monitor_pending.attr, - &dev_attr_server_monitor_latency.attr, - &dev_attr_client_monitor_latency.attr, - &dev_attr_server_monitor_conn_id.attr, - &dev_attr_client_monitor_conn_id.attr, &dev_attr_out_intr_mask.attr, &dev_attr_out_read_index.attr, &dev_attr_out_write_index.attr,@@ -632,6 +625,22 @@ static struct attribute *vmbus_dev_attrs[] = { };ATTRIBUTE_GROUPS (vmbus_dev); +/* +* Set up per device monitor page attributes. These attributes are used only by +* channels that use the monitor page mechanism. +*/ +static struct attribute *vmbus_dev_monitor_attrs[] = {
drivers/hv/vmbus_drv.c static struct attribute *vmbus_dev_attrs[] = { · line 642
Quoted 10 lines
drivers/hv/vmbus_drv.c +10
-0+ &dev_attr_monitor_id.attr, + &dev_attr_server_monitor_pending.attr, + &dev_attr_client_monitor_pending.attr, + &dev_attr_server_monitor_latency.attr, + &dev_attr_client_monitor_latency.attr, + &dev_attr_server_monitor_conn_id.attr, + &dev_attr_client_monitor_conn_id.attr, + NULL +}; +ATTRIBUTE_GROUPS (vmbus_dev_monitor);
No need to create a special group for this and then manually add it if you need it. Just the is_visible() callback in the attribute instead, as that is what it is there for.
Thanks,
greg k-h
PATCH v4 1/1 Drivers: hv: vmbus: Expose monitor data only when monitor pages are used
In reply to Kimberly BrownThere are two methods for signaling the host: the monitor page mechanism and hypercalls. The monitor page mechanism is used by performance critical channels (storage, networking, etc.) because it provides improved throughput. However, latency is increased. Monitor pages are allocated to these channels.
Monitor pages are not allocated to channels that do not use the monitor page mechanism. Therefore, these channels do not have a valid monitor id or valid monitor page data. In these cases, some of the "_show" functions return incorrect data. They return an invalid monitor id and data that is beyond the bounds of the hv_monitor_page array fields.
The "channel->offermsg.monitor_allocated" value can be used to determine whether monitor pages have been allocated to a channel.
Add "is_visible()" callback functions for the device-level and channel-level attribute groups. These functions will hide the monitor sysfs files when the monitor mechanism is not used.
Remove ".default_attributes" from "vmbus_chan_attrs" and create a channel-level attribute group, "vmbus_chan_group". These changes allow the new "is_visible()" callback function to be applied to the channel-level attributes. Call "sysfs_create_group()" to create the channel sysyfs files.
---
Changes in v4:
- Added “is_visible()” callback functions for the device-level and channel-level attribute groups.
- Removed the separate monitor attribute groups proposed in v3. They’re no longer needed because the “is_visible()” callbacks are used to determine the attribute visibility.
- Removed "default_attributes" from "vmbus_chan_attrs" and created a channel-level attribute group.
- Removed the "kobject_put(kobj)" call proposed in v3. The calling functions take care of calling "kobject_put(channel->kobj)" if an error is returned by "vmbus_add_channel_kobj()".
- Updated the commit message and subject for clarity and to reflect the new changes in v4.
Changes in v3:
- The monitor "_show" functions no longer return an error when a channel does not use the monitor page mechanism. Instead, the monitor page sysfs files are created only when a channel uses the monitor page mechanism. This change was suggested by G. Kroah-Hartman.
Note: this patch was originally patch 2/2 in a patchset. Patch 1/2 has already been added to char-misc-testing, so I'm not resending it.
Changes in v2:
- Changed the return value for cases where monitor_allocated is not set to "-EINVAL".
- Updated the commit message to provide more details about the monitor page mechanism.
- Updated the sysfs documentation to describe the new return value.
Documentation/ABI/stable/sysfs-bus-vmbus | 12 +++-- drivers/hv/vmbus_drv.c | 63 +++++++++++++++++++++++- 2 files changed, 70 insertions(+), 5 deletions(-)
Documentation/ABI/stable/sysfs-bus-vmbus +9 -3
@@ -81,7 +81,9 @@ What: /sys/bus/vmbus/devices/<UUID>/channels/<N>/latency Date: September. 2017 KernelVersion: 4.14 Contact: Stephen Hemminger <[email protected]> -Description: Channel signaling latency +Description: Channel signaling latency. This file is available only for + performance critical channels (storage, network, etc.) that use + the monitor page mechanism. Users: Debugging tools What: /sys/bus/vmbus/devices/<UUID>/channels/<N>/out_mask
@@ -95,7 +97,9 @@ What: /sys/bus/vmbus/devices/<UUID>/channels/<N>/pending Date: September. 2017 KernelVersion: 4.14 Contact: Stephen Hemminger <[email protected]> -Description: Channel interrupt pending state +Description: Channel interrupt pending state. This file is available only for + performance critical channels (storage, network, etc.) that use + the monitor page mechanism. Users: Debugging tools What: /sys/bus/vmbus/devices/<UUID>/channels/<N>/read_avail
@@ -137,7 +141,9 @@ What: /sys/bus/vmbus/devices/<UUID>/channels/<N>/monitor_id Date: January. 2018 KernelVersion: 4.16 Contact: Stephen Hemminger <[email protected]> -Description: Monitor bit associated with channel +Description: Monitor bit associated with channel. This file is available only + for performance critical channels (storage, network, etc.) that + use the monitor page mechanism. Users: Debugging tools and userspace drivers What: /sys/bus/vmbus/devices/<UUID>/channels/<N>/ring
drivers/hv/vmbus_drv.c +61 -2
84 lines not on this page · raw message
Signature · 1 line
2.17.1
RE: [PATCH v4] Drivers: hv: vmbus: Expose monitor data only when monitor pages are used
From: Kimberly Brown <[email protected]> Sent: Friday, March 1, 2019 11:18 AM
Quoted 20 lines
drivers/hv/vmbus_drv.c +19
-0+/* +* Channel-level attribute_group callback function. Returns the permission for +* each attribute, and returns 0 if an attribute is not visible. +*/ +static umode_t vmbus_chan_attr_is_visible (struct kobject *kobj, +struct attribute *attr,int idx) +{ +const struct vmbus_channel *channel = + container_of(kobj, struct vmbus_channel, kobj); + +/* Hide the monitor attributes if the monitor mechanism is not used. */ +if (!channel->offermsg.monitor_allocated && + (attr == &chan_attr_pending.attr || + attr == &chan_attr_latency.attr || + attr == &chan_attr_monitor_id.attr)) +return 0 ; + +return attr->mode; +}
drivers/hv/vmbus_drv.c static struct attribute *vmbus_chan_attrs[] = { · line 1556
Quoted 10 lines
drivers/hv/vmbus_drv.c +6
-1+ +static struct attribute_group vmbus_chan_group = { + .attrs = vmbus_chan_attrs, + .is_visible = vmbus_chan_attr_is_visible +}; +static struct kobj_type vmbus_chan_ktype = { .sysfs_ops = &vmbus_chan_sysfs_ops, .release = vmbus_chan_release, - .default_attrs = vmbus_chan_attrs,
Just to double-check my understanding, removing the default_attrs here means that in vmbus_add_channel_kobj(), the call to kobject_init_and_add() will only create the sub-directory that is the channel number. The sub-directory will be empty. Then the new call to sysfs_create_group() that you added below will populate the subdirectory, as filtered by vmbus_chan_attr_is_visible().
drivers/hv/vmbus_drv.c int vmbus_add_channel_kobj(struct hv_device *dev, struct · line 1631
Quoted 12 lines
};
/*
drivers/hv/vmbus_drv.c +4
-0@@ -1571,6 +1624,12 @@ int vmbus_add_channel_kobj(struct hv_device *dev, struct vmbus_channel *channel)if (ret)return ret; + ret =sysfs_create_group (kobj, &vmbus_chan_group); +if (ret) { +pr_err ("Unable to set up channel sysfs files\n" ); +return ret;
In this error case, the previously created sub-directory that is the channel number needs to be deleted/cleaned up.
Review int vmbus_add_channel_kobj(struct hv_device *dev, struct · line 1633
Quoted 2 lines
(quoted diff) +2
-0+ } +
Michael
Re: [PATCH v4] Drivers: hv: vmbus: Expose monitor data only when monitor pages are used
In reply to Kimberly BrownQuoted 19 lines · Kimberly Brown
drivers/hv/vmbus_drv.c +19
-0+/* +* Channel-level attribute_group callback function. Returns the permission for +* each attribute, and returns 0 if an attribute is not visible. +*/ +static umode_t vmbus_chan_attr_is_visible (struct kobject *kobj, +struct attribute *attr,int idx) +{ +const struct vmbus_channel *channel = + container_of(kobj, struct vmbus_channel, kobj); + +/* Hide the monitor attributes if the monitor mechanism is not used. */ +if (!channel->offermsg.monitor_allocated && + (attr == &chan_attr_pending.attr || + attr == &chan_attr_latency.attr || + attr == &chan_attr_monitor_id.attr)) +return 0 ; + +return attr->mode; +}
drivers/hv/vmbus_drv.c static struct attribute *vmbus_chan_attrs[] = { · line 1556
Quoted 10 lines
drivers/hv/vmbus_drv.c +6
-1+ +static struct attribute_group vmbus_chan_group = { + .attrs = vmbus_chan_attrs, + .is_visible = vmbus_chan_attr_is_visible +}; +static struct kobj_type vmbus_chan_ktype = { .sysfs_ops = &vmbus_chan_sysfs_ops, .release = vmbus_chan_release, - .default_attrs = vmbus_chan_attrs,
Why did you remove this line?
drivers/hv/vmbus_drv.c int vmbus_add_channel_kobj(struct hv_device *dev, struct vmbus_channel *channel) · line 1627
Quoted 8 lines
};
/*
drivers/hv/vmbus_drv.c +1
-0@@ -1571,6 +1624,12 @@ int vmbus_add_channel_kobj(struct hv_device *dev, struct vmbus_channel *channel)if (ret)return ret; + ret =sysfs_create_group (kobj, &vmbus_chan_group);
Why are you adding these "by hand"? What was wrong with using the default attribute group pointer? You also are not removing the attributes :(
greg k-h
Re: [PATCH v4] Drivers: hv: vmbus: Expose monitor data only when monitor pages are used
Quoted 24 lines · Greg KH
Quoted 23 lines · Kimberly Brown
drivers/hv/vmbus_drv.c +23
-0+/* +* Channel-level attribute_group callback function. Returns the permission for +* each attribute, and returns 0 if an attribute is not visible. +*/ +static umode_t vmbus_chan_attr_is_visible (struct kobject *kobj, +struct attribute *attr,int idx) +{ +const struct vmbus_channel *channel = + container_of(kobj, struct vmbus_channel, kobj); + +/* Hide the monitor attributes if the monitor mechanism is not used. */ +if (!channel->offermsg.monitor_allocated && + (attr == &chan_attr_pending.attr || + attr == &chan_attr_latency.attr || + attr == &chan_attr_monitor_id.attr)) +return 0 ; + +return attr->mode; +} + +static struct attribute_group vmbus_chan_group = { + .attrs = vmbus_chan_attrs, + .is_visible = vmbus_chan_attr_is_visible
Quoted 8 lines
drivers/hv/vmbus_drv.c static struct attribute *vmbus_chan_attrs[] = { · line 1556
Quoted 6 lines
drivers/hv/vmbus_drv.c +2
-1+}; +static struct kobj_type vmbus_chan_ktype = { .sysfs_ops = &vmbus_chan_sysfs_ops, .release = vmbus_chan_release, - .default_attrs = vmbus_chan_attrs,Why did you remove this line?
I removed the default attributes because vmbus_chan_attrs contains non-default attributes. You suggested that I use one attribute_group and an is_visible() callback for the device-level attributes (see
https://lore.kernel.org/lkml/[email protected]/). I assumed (possibly incorrectly) that I should do the same for these channel-level attributes.
Quoted 7 lines
Quoted 7 lines
};
/*
drivers/hv/vmbus_drv.c +0
-0@@ -1571,6 +1624,12 @@ int vmbus_add_channel_kobj(struct hv_device *dev, struct vmbus_channel *channel)if (ret)return ret;
Quoted 5 lines
drivers/hv/vmbus_drv.c int vmbus_add_channel_kobj(struct hv_device *dev, struct vmbus_channel *channel) · line 1627
Quoted 1 line
drivers/hv/vmbus_drv.c +1
-0+ ret =sysfs_create_group (kobj, &vmbus_chan_group);Why are you adding these "by hand"? What was wrong with using the default attribute group pointer? You also are not removing the attributes :(
Are you referring to default_attrs in kobj_type? It's not an attribute_group pointer, it's a pointer to an attribute pointer array. The problem with using default_attrs is that all of the attributes are visible.
I'm fairly certain that the monitor attributes are being removed. sysfs_create_group() uses the attribute_group's is_visible() callback to control the attribute visibility. And, when I look at the sysfs files, I can see that the monitor sysyfs files are removed.
In v3, I proposed moving the monitor attributes to a special attribute_group and adding that group manually when needed. Do you prefer that approach for the channel-level monitor attributes?
Thanks,
Kim
Quoted 2 lines
greg k-h
Re: [PATCH v4] Drivers: hv: vmbus: Expose monitor data only when monitor pages are used
In reply to Michael KelleyQuoted 30 lines · Michael Kelley
From: Kimberly Brown <[email protected]> Sent: Friday, March 1, 2019 11:18 AM
Quoted 29 lines
drivers/hv/vmbus_drv.c +25
-0+/* +* Channel-level attribute_group callback function. Returns the permission for +* each attribute, and returns 0 if an attribute is not visible. +*/ +static umode_t vmbus_chan_attr_is_visible (struct kobject *kobj, +struct attribute *attr,int idx) +{ +const struct vmbus_channel *channel = + container_of(kobj, struct vmbus_channel, kobj); + +/* Hide the monitor attributes if the monitor mechanism is not used. */ +if (!channel->offermsg.monitor_allocated && + (attr == &chan_attr_pending.attr || + attr == &chan_attr_latency.attr || + attr == &chan_attr_monitor_id.attr)) +return 0 ; + +return attr->mode; +} + +static struct attribute_group vmbus_chan_group = { + .attrs = vmbus_chan_attrs, + .is_visible = vmbus_chan_attr_is_visible +}; +static struct kobj_type vmbus_chan_ktype = { .sysfs_ops = &vmbus_chan_sysfs_ops, .release = vmbus_chan_release,
Quoted 8 lines
drivers/hv/vmbus_drv.c static struct attribute *vmbus_chan_attrs[] = { · line 1556
Quoted 1 line
drivers/hv/vmbus_drv.c +0
-1- .default_attrs = vmbus_chan_attrs,Just to double-check my understanding, removing the
default_attrshere means that invmbus_add_channel_kobj(), the call tokobject_init_and_add()will only create the sub-directory that is the channel number. The sub-directory will be empty. Then the new call tosysfs_create_group()that you added below will populate the subdirectory, as filtered byvmbus_chan_attr_is_visible().
Yes, that's my understanding as well.
Quoted 9 lines
Quoted 9 lines
};
/*
drivers/hv/vmbus_drv.c +0
-0@@ -1571,6 +1624,12 @@ int vmbus_add_channel_kobj(struct hv_device *dev, struct vmbus_channel *channel)if (ret)return ret;
Quoted 7 lines
drivers/hv/vmbus_drv.c int vmbus_add_channel_kobj(struct hv_device *dev, struct vmbus_channel *channel) · line 1630
Quoted 4 lines
drivers/hv/vmbus_drv.c +4
-0+ ret =sysfs_create_group (kobj, &vmbus_chan_group); +if (ret) { +pr_err ("Unable to set up channel sysfs files\n" ); +return ret;In this error case, the previously created sub-directory that is the channel number needs to be deleted/cleaned up.
I was going to let the kobject and sysfs systems take care of that. If vmbus_add_channel_kobj() returns an error to the calling functions, they call kobject_put(), which eventually removes the directory.
There are two functions that call vmbus_add_channel_kobj():vmbus_add_channel_work() and vmbus_device_register(). If vmbus_add_channel_kobj() returns an error to vmbus_add_channel_work(), the function calls are:
free_channel() => kobject_put() (channel kobj ref. count should now be
0) => kobject_release() => kobject_cleanup() => kobject_del() => sysfs_remove_dir()
If vmbus_add_channel_kobject() returns an error to vmbus_device_register(), the device's sub-directory is removed:
device_unregister() => put_device() => kobject_put() (device kobj ref. count should now be 0) => kobject_release() => ...
So, I don't think its necessary to cleanup the subdirectory created by kobject_init_and_add() here.
Thanks,
Kim
Quoted 5 lines
Review int vmbus_add_channel_kobj(struct hv_device *dev, struct · line 1633
Quoted 3 lines
(quoted diff) +2
-0+ } +Michael
Re: [PATCH v4] Drivers: hv: vmbus: Expose monitor data only when monitor pages are used
In reply to Kimberly BrownQuoted 34 lines · Kimberly Brown
Quoted 24 lines · Greg KH
Quoted 23 lines · Kimberly Brown
drivers/hv/vmbus_drv.c +23
-0+/* +* Channel-level attribute_group callback function. Returns the permission for +* each attribute, and returns 0 if an attribute is not visible. +*/ +static umode_t vmbus_chan_attr_is_visible (struct kobject *kobj, +struct attribute *attr,int idx) +{ +const struct vmbus_channel *channel = + container_of(kobj, struct vmbus_channel, kobj); + +/* Hide the monitor attributes if the monitor mechanism is not used. */ +if (!channel->offermsg.monitor_allocated && + (attr == &chan_attr_pending.attr || + attr == &chan_attr_latency.attr || + attr == &chan_attr_monitor_id.attr)) +return 0 ; + +return attr->mode; +} + +static struct attribute_group vmbus_chan_group = { + .attrs = vmbus_chan_attrs, + .is_visible = vmbus_chan_attr_is_visibleQuoted 8 lines
drivers/hv/vmbus_drv.c static struct attribute *vmbus_chan_attrs[] = { · line 1556
Quoted 6 lines
drivers/hv/vmbus_drv.c +2
-1+}; +static struct kobj_type vmbus_chan_ktype = { .sysfs_ops = &vmbus_chan_sysfs_ops, .release = vmbus_chan_release, - .default_attrs = vmbus_chan_attrs,Why did you remove this line?
Quoted 6 lines
I removed the default attributes because
vmbus_chan_attrscontains non-default attributes. You suggested that I use oneattribute_groupand anis_visible()callback for the device-level attributes (see
https://lore.kernel.org/lkml/[email protected]/). I assumed (possibly incorrectly) that I should do the same for these channel-level attributes.
That is fine to have a callback, but why did you have to remove the default attribute pointer? The two should have nothing to do with each other.
Quoted 13 lines
Quoted 7 lines
Quoted 7 lines
};
/*
drivers/hv/vmbus_drv.c +0
-0@@ -1571,6 +1624,12 @@ int vmbus_add_channel_kobj(struct hv_device *dev, struct vmbus_channel *channel)if (ret)return ret;Quoted 5 lines
drivers/hv/vmbus_drv.c int vmbus_add_channel_kobj(struct hv_device *dev, struct vmbus_channel *channel) · line 1627
Quoted 1 line
drivers/hv/vmbus_drv.c +1
-0+ ret =sysfs_create_group (kobj, &vmbus_chan_group);Why are you adding these "by hand"? What was wrong with using the default attribute group pointer? You also are not removing the attributes :(
Quoted 4 lines
Are you referring to
default_attrsinkobj_type? It's not anattribute_grouppointer, it's a pointer to an attribute pointer array. The problem with usingdefault_attrsis that all of the attributes are visible.
It shouldn't, the is_visable() callback will be called on each attribute when the group is created by the core. Did that not work properly when you tested this?
Quoted 4 lines
I'm fairly certain that the monitor attributes are being removed.
sysfs_create_group()uses the attribute_group'sis_visible()callback to control the attribute visibility. And, when I look at the sysfs files, I can see that the monitor sysyfs files are removed.
I mean you are not removing the group when the device goes away, not that the individual files are not present. If you leave the pointer to default_attributes there, the core will properly remove the sysfs attributes when the device is removed from the system. Otherwise you just "get lucky" if the attributes are removed or not.
Quoted 3 lines
In v3, I proposed moving the monitor attributes to a special
attribute_groupand adding that group manually when needed. Do you prefer that approach for the channel-level monitor attributes?
No need for a special group here, just use the is_visable() callback like you currently are, all should be fine. I think you are adding more code than you need to in order to get this to all work properly :)
thanks,
greg k-h
PATCH v5 1/1 Drivers: hv: vmbus: Expose monitor data only when monitor pages are used
In reply to Kimberly BrownThere are two methods for signaling the host: the monitor page mechanism and hypercalls. The monitor page mechanism is used by performance critical channels (storage, networking, etc.) because it provides improved throughput. However, latency is increased. Monitor pages are allocated to these channels.
Monitor pages are not allocated to channels that do not use the monitor page mechanism. Therefore, these channels do not have a valid monitor id or valid monitor page data. In these cases, some of the "_show" functions return incorrect data. They return an invalid monitor id and data that is beyond the bounds of the hv_monitor_page array fields.
The "channel->offermsg.monitor_allocated" value can be used to determine whether monitor pages have been allocated to a channel.
Add "is_visible()" callback functions for the device-level and channel-level attribute groups. These functions will hide the monitor sysfs files when the monitor mechanism is not used.
Remove ".default_attributes" from "vmbus_chan_attrs" and create a channel-level attribute group, "vmbus_chan_group". These changes allow the new "is_visible()" callback function to be applied to the channel-level attributes. Call "sysfs_create_group()" to create the channel sysyfs files.
Add the “bool sysfs_group_ready” field to the vmbus_channel struct. This field is used to ensure that the attributes in the “vmbus_chan_group” attribute group have been created. Add the “vmbus_remove_channel_attr_group()” function, which calls "sysfs_remove_group()" on “vmbus_chan_group” if the attributes were created.
---
Changes in v5:
- Added the “bool sysfs_group_ready” field to vmbus_channel.
- Added the “vmbus_remove_channel_attr_group()” function which calls "sysfs_remove_group()".
- Added a comment to "vmbus_add_channel_kobj()" to describe how the empty directory is removed if "sysfs_create_group()" returns an error.
- Updated the commit message.
NOTE: “.default_attrs” must be removed from vmbus_chan_ktype in order to use the is_visible() function because "default_attrs" is an array of attributes, not an attribute_group.
Changes in v4:
- Added “is_visible()” callback functions for the device-level and channel-level attribute groups.
- Removed the separate monitor attribute groups proposed in v3. They’re no longer needed because the “is_visible()” callbacks are used to determine the attribute visibility.
- Removed "default_attributes" from "vmbus_chan_attrs" and created a channel-level attribute group.
- Removed the "kobject_put(kobj)" call proposed in v3. The calling functions take care of calling "kobject_put(channel->kobj)" if an error is returned by "vmbus_add_channel_kobj()".
- Updated the commit message and subject for clarity and to reflect the new changes in v4.
Changes in v3:
- The monitor "_show" functions no longer return an error when a channel does not use the monitor page mechanism. Instead, the monitor page sysfs files are created only when a channel uses the monitor page mechanism. This change was suggested by G. Kroah-Hartman.
Note: this patch was originally patch 2/2 in a patchset. Patch 1/2 has already been added to char-misc-testing, so I'm not resending it.
Changes in v2:
- Changed the return value for cases where monitor_allocated is not set to "-EINVAL".
- Updated the commit message to provide more details about the monitor page mechanism.
- Updated the sysfs documentation to describe the new return value.
Documentation/ABI/stable/sysfs-bus-vmbus | 12 +++- drivers/hv/channel_mgmt.c | 3 + drivers/hv/hyperv_vmbus.h | 2 + drivers/hv/vmbus_drv.c | 80 +++++++++++++++++++++++- include/linux/hyperv.h | 6 ++ 5 files changed, 98 insertions(+), 5 deletions(-)
Documentation/ABI/stable/sysfs-bus-vmbus +9 -3
@@ -81,7 +81,9 @@ What: /sys/bus/vmbus/devices/<UUID>/channels/<N>/latency Date: September. 2017 KernelVersion: 4.14 Contact: Stephen Hemminger <[email protected]> -Description: Channel signaling latency +Description: Channel signaling latency. This file is available only for + performance critical channels (storage, network, etc.) that use + the monitor page mechanism. Users: Debugging tools What: /sys/bus/vmbus/devices/<UUID>/channels/<N>/out_mask
@@ -95,7 +97,9 @@ What: /sys/bus/vmbus/devices/<UUID>/channels/<N>/pending Date: September. 2017 KernelVersion: 4.14 Contact: Stephen Hemminger <[email protected]> -Description: Channel interrupt pending state +Description: Channel interrupt pending state. This file is available only for + performance critical channels (storage, network, etc.) that use + the monitor page mechanism. Users: Debugging tools What: /sys/bus/vmbus/devices/<UUID>/channels/<N>/read_avail
@@ -137,7 +141,9 @@ What: /sys/bus/vmbus/devices/<UUID>/channels/<N>/monitor_id Date: January. 2018 KernelVersion: 4.16 Contact: Stephen Hemminger <[email protected]> -Description: Monitor bit associated with channel +Description: Monitor bit associated with channel. This file is available only + for performance critical channels (storage, network, etc.) that + use the monitor page mechanism. Users: Debugging tools and userspace drivers What: /sys/bus/vmbus/devices/<UUID>/channels/<N>/ring
drivers/hv/channel_mgmt.c +3 -0
@@ -346,6 +346,9 @@ static void free_channel(struct vmbus_channel *channel) {tasklet_kill (&channel->callback_event); +/* Remove the channel sysfs attribute group */ +vmbus_remove_channel_attr_group (channel); +kobject_put (&channel->kobj); }
drivers/hv/hyperv_vmbus.h +2 -0
@@ -321,6 +321,8 @@ void vmbus_device_unregister(struct hv_device *device_obj);int vmbus_add_channel_kobj (struct hv_device *device_obj,struct vmbus_channel *channel); +void vmbus_remove_channel_attr_group (struct vmbus_channel *channel); +struct vmbus_channel *relid2channel (u32 relid);void vmbus_free_channels (void );
drivers/hv/vmbus_drv.c +78 -2
106 lines not on this page · raw message
include/linux/hyperv.h +6 -0
@@ -934,6 +934,12 @@ struct vmbus_channel {* full outbound ring buffer. */ u64 out_full_first; + +/* +* Indicates whether the channel's attribute group sysfs files have +* been successfully created. +*/ +bool sysfs_group_ready; };static inline bool is_hvsock_channel (const struct vmbus_channel *c)
Signature · 1 line
2.17.1
Re: [PATCH v5] Drivers: hv: vmbus: Expose monitor data only when monitor pages are used
drivers/hv/vmbus_drv.c static struct attribute *vmbus_chan_attrs[] = { · line 1556
Quoted 4 lines · Kimberly Brown
static struct
kobj_typevmbus_chan_ktype= {drivers/hv/vmbus_drv.c +0
-1.sysfs_ops = &vmbus_chan_sysfs_ops, .release = vmbus_chan_release, - .default_attrs = vmbus_chan_attrs,
As discussed on IRC, a kobj_type needs to get an attribute group one of these days, not just a attribute list :)
So thanks for persisting with this, sorry for the earlier review comments, you were totally right about this, nice work.
Minor review comments below:
drivers/hv/vmbus_drv.c int vmbus_add_channel_kobj(struct hv_device *dev, struct vmbus_channel *channel) · line 1628
Quoted 9 lines
};
/*
drivers/hv/vmbus_drv.c +2
-0@@ -1571,11 +1624,34 @@ int vmbus_add_channel_kobj(struct hv_device *dev, struct vmbus_channel *channel)if (ret)return ret; + ret =sysfs_create_group (kobj, &vmbus_chan_group); + channel->sysfs_group_ready = !ret;
Why do you need this flag?
drivers/hv/vmbus_drv.c int vmbus_add_channel_kobj(struct hv_device *dev, struct vmbus_channel *channel) · line 1635
Quoted 7 lines
drivers/hv/vmbus_drv.c +7
-0+ +if (ret) { +/* +* If an error is returned to the calling functions, those +* functions will call kobject_put() on the channel kobject, +* which will cleanup the empty channel directory created by +* kobject_init_and_add().
Why is this comment needed?
drivers/hv/vmbus_drv.c int vmbus_add_channel_kobj(struct hv_device *dev, struct vmbus_channel *channel) · line 1637
Quoted 2 lines
drivers/hv/vmbus_drv.c +2
-0+*/ +pr_err ("Unable to set up channel sysfs files\n" );
dev_err() to show who had the problem with the files?
Quoted 5 lines
drivers/hv/vmbus_drv.c +3
-0+return ret; + } +kobject_uevent (kobj,KOBJ_ADD );
drivers/hv/vmbus_drv.c int vmbus_add_channel_kobj(struct hv_device *dev, struct vmbus_channel *channel) · line 1652
Quoted 10 lines
drivers/hv/vmbus_drv.c +7
-0return 0 ; } +/* +* vmbus_remove_channel_attr_group - remove the channel's attribute group +*/ +void vmbus_remove_channel_attr_group (struct vmbus_channel *channel) +{ +if (channel->sysfs_group_ready) +sysfs_remove_group (&channel->kobj, &vmbus_chan_group);
You should be able to just always remove these, no need for a flag to say you have created them or not, right?
thanks,
greg k-h
Re: [PATCH v5] Drivers: hv: vmbus: Expose monitor data only when monitor pages are used
Quoted 21 lines · Greg KH
drivers/hv/vmbus_drv.c static struct attribute *vmbus_chan_attrs[] = { · line 1556
Quoted 4 lines · Kimberly Brown
static struct
kobj_typevmbus_chan_ktype= {drivers/hv/vmbus_drv.c +0
-1.sysfs_ops = &vmbus_chan_sysfs_ops, .release = vmbus_chan_release, - .default_attrs = vmbus_chan_attrs,As discussed on IRC, a
kobj_typeneeds to get an attribute group one of these days, not just a attribute list :)So thanks for persisting with this, sorry for the earlier review comments, you were totally right about this, nice work.
Minor review comments below:
Quoted 7 lines
};
/*
drivers/hv/vmbus_drv.c +0
-0@@ -1571,11 +1624,34 @@ int vmbus_add_channel_kobj(struct hv_device *dev, struct vmbus_channel *channel)if (ret)return ret;
Quoted 5 lines
drivers/hv/vmbus_drv.c int vmbus_add_channel_kobj(struct hv_device *dev, struct vmbus_channel *channel) · line 1628
Quoted 2 lines
drivers/hv/vmbus_drv.c +2
-0+ ret =sysfs_create_group (kobj, &vmbus_chan_group); + channel->sysfs_group_ready = !ret;Why do you need this flag?
I added this flag to prevent sysfs_remove_group() from being called if sysfs_create_group() or the earlier call to kobject_init_and_add() failed. However, it looks like that would just lead to WARN() being called, which seems appropriate. I'll remove this flag.
Quoted 10 lines
drivers/hv/vmbus_drv.c int vmbus_add_channel_kobj(struct hv_device *dev, struct vmbus_channel *channel) · line 1635
Quoted 7 lines
drivers/hv/vmbus_drv.c +7
-0+ +if (ret) { +/* +* If an error is returned to the calling functions, those +* functions will call kobject_put() on the channel kobject, +* which will cleanup the empty channel directory created by +* kobject_init_and_add(). Why is this comment needed?
Another reviewer asked why the empty directory created by kobject_init_and_add() isn't removed here when sysfs_create_group() fails. We decided that a comment would help clear up any future confusion.
Quoted 5 lines
drivers/hv/vmbus_drv.c int vmbus_add_channel_kobj(struct hv_device *dev, struct vmbus_channel *channel) · line 1637
Quoted 2 lines
drivers/hv/vmbus_drv.c +2
-0+*/ +pr_err ("Unable to set up channel sysfs files\n" );
dev_err()to show who had the problem with the files?
Yes, good point. I'll change this.
Quoted 22 lines
Quoted 5 lines
drivers/hv/vmbus_drv.c +3
-0+return ret; + } +kobject_uevent (kobj,KOBJ_ADD );drivers/hv/vmbus_drv.c int vmbus_add_channel_kobj(struct hv_device *dev, struct vmbus_channel *channel) · line 1652
Quoted 10 lines
drivers/hv/vmbus_drv.c +7
-0return 0 ; } +/* +* vmbus_remove_channel_attr_group - remove the channel's attribute group +*/ +void vmbus_remove_channel_attr_group (struct vmbus_channel *channel) +{ +if (channel->sysfs_group_ready) +sysfs_remove_group (&channel->kobj, &vmbus_chan_group);You should be able to just always remove these, no need for a flag to say you have created them or not, right?
thanks,
greg k-h
PATCH v6 1/1 Drivers: hv: vmbus: Expose monitor data only when monitor pages are used
In reply to Kimberly BrownThere are two methods for signaling the host: the monitor page mechanism and hypercalls. The monitor page mechanism is used by performance critical channels (storage, networking, etc.) because it provides improved throughput. However, latency is increased. Monitor pages are allocated to these channels.
Monitor pages are not allocated to channels that do not use the monitor page mechanism. Therefore, these channels do not have a valid monitor id or valid monitor page data. In these cases, some of the "_show" functions return incorrect data. They return an invalid monitor id and data that is beyond the bounds of the hv_monitor_page array fields.
The "channel->offermsg.monitor_allocated" value can be used to determine whether monitor pages have been allocated to a channel.
Add "is_visible()" callback functions for the device-level and channel-level attribute groups. These functions will hide the monitor sysfs files when the monitor mechanism is not used.
Remove ".default_attributes" from "vmbus_chan_attrs" and create a channel-level attribute group. These changes allow the new "is_visible()" callback function to be applied to the channel-level attributes.
Call "sysfs_create_group()" in "vmbus_add_channel_kobj()" to create the channel's sysfs files. Add a new function, “vmbus_remove_channel_attr_group()”, and call it in "free_channel()" to remove the channel's sysfs files when the channel is closed.
---
Changes in v6:
- Removed the “sysfs_group_ready” flag proposed in v5. The flag was used to verify that the attribute group was created, which is unnecessary; sysfs_remove_group() can be called even when sysfs_create_group() fails.
- Replaced pr_err() with dev_err() as suggested by G. Kroah-Hartman.
- Shortened the error path comment in vmbus_add_channel_kobj().
- Updated the commit message.
Changes in v5:
- Added the “bool sysfs_group_ready” field to vmbus_channel.
- Added the “vmbus_remove_channel_attr_group()” function which calls "sysfs_remove_group()".
- Added a comment to "vmbus_add_channel_kobj()" to describe how the empty directory is removed if "sysfs_create_group()" returns an error.
- Updated the commit message.
NOTE: “.default_attrs” must be removed from vmbus_chan_ktype in order to use the is_visible() function because "default_attrs" is an array of attributes, not an attribute_group.
Changes in v4:
- Added “is_visible()” callback functions for the device-level and channel-level attribute groups.
- Removed the separate monitor attribute groups proposed in v3. They’re no longer needed because the “is_visible()” callbacks are used to determine the attribute visibility.
- Removed "default_attributes" from "vmbus_chan_attrs" and created a channel-level attribute group.
- Removed the "kobject_put(kobj)" call proposed in v3. The calling functions take care of calling "kobject_put(channel->kobj)" if an error is returned by "vmbus_add_channel_kobj()".
- Updated the commit message and subject for clarity and to reflect the new changes in v4.
Changes in v3:
- The monitor "_show" functions no longer return an error when a channel does not use the monitor page mechanism. Instead, the monitor page sysfs files are created only when a channel uses the monitor page mechanism. This change was suggested by G. Kroah-Hartman.
Note: this patch was originally patch 2/2 in a patchset. Patch 1/2 has already been added to char-misc-testing, so I'm not resending it.
Changes in v2:
- Changed the return value for cases where monitor_allocated is not set to "-EINVAL".
- Updated the commit message to provide more details about the monitor page mechanism.
- Updated the sysfs documentation to describe the new return value.
Documentation/ABI/stable/sysfs-bus-vmbus | 12 +++-
drivers/hv/channel_mgmt.c | 1 + drivers/hv/hyperv_vmbus.h | 2 + drivers/hv/vmbus_drv.c | 77 +++++++++++++++++++++++- 4 files changed, 87 insertions(+), 5 deletions(-)
Documentation/ABI/stable/sysfs-bus-vmbus +9 -3
@@ -81,7 +81,9 @@ What: /sys/bus/vmbus/devices/<UUID>/channels/<N>/latency Date: September. 2017 KernelVersion: 4.14 Contact: Stephen Hemminger <[email protected]> -Description: Channel signaling latency +Description: Channel signaling latency. This file is available only for + performance critical channels (storage, network, etc.) that use + the monitor page mechanism. Users: Debugging tools What: /sys/bus/vmbus/devices/<UUID>/channels/<N>/out_mask
@@ -95,7 +97,9 @@ What: /sys/bus/vmbus/devices/<UUID>/channels/<N>/pending Date: September. 2017 KernelVersion: 4.14 Contact: Stephen Hemminger <[email protected]> -Description: Channel interrupt pending state +Description: Channel interrupt pending state. This file is available only for + performance critical channels (storage, network, etc.) that use + the monitor page mechanism. Users: Debugging tools What: /sys/bus/vmbus/devices/<UUID>/channels/<N>/read_avail
@@ -137,7 +141,9 @@ What: /sys/bus/vmbus/devices/<UUID>/channels/<N>/monitor_id Date: January. 2018 KernelVersion: 4.16 Contact: Stephen Hemminger <[email protected]> -Description: Monitor bit associated with channel +Description: Monitor bit associated with channel. This file is available only + for performance critical channels (storage, network, etc.) that + use the monitor page mechanism. Users: Debugging tools and userspace drivers What: /sys/bus/vmbus/devices/<UUID>/channels/<N>/ring
drivers/hv/channel_mgmt.c +1 -0
@@ -347,6 +347,7 @@ static struct vmbus_channel *alloc_channel(void)static void free_channel (struct vmbus_channel *channel) {tasklet_kill (&channel->callback_event); +vmbus_remove_channel_attr_group (channel);kobject_put (&channel->kobj); }
drivers/hv/hyperv_vmbus.h +2 -0
@@ -322,6 +322,8 @@ void vmbus_device_unregister(struct hv_device *device_obj);int vmbus_add_channel_kobj (struct hv_device *device_obj,struct vmbus_channel *channel); +void vmbus_remove_channel_attr_group (struct vmbus_channel *channel); +struct vmbus_channel *relid2channel (u32 relid);void vmbus_free_channels (void );
drivers/hv/vmbus_drv.c +75 -2
109 lines not on this page · raw message
Signature · 1 line
2.17.1
Re: [PATCH v6] Drivers: hv: vmbus: Expose monitor data only when monitor pages are used
Quoted 24 lines · Kimberly Brown
There are two methods for signaling the host: the monitor page mechanism and hypercalls. The monitor page mechanism is used by performance critical channels (storage, networking, etc.) because it provides improved throughput. However, latency is increased. Monitor pages are allocated to these channels.
Monitor pages are not allocated to channels that do not use the monitor page mechanism. Therefore, these channels do not have a valid monitor id or valid monitor page data. In these cases, some of the "
_show" functions return incorrect data. They return an invalid monitor id and data that is beyond the bounds of thehv_monitor_pagearray fields.The "
channel->offermsg.monitor_allocated" value can be used to determine whether monitor pages have been allocated to a channel.Add "
is_visible()" callback functions for the device-level and channel-level attribute groups. These functions will hide the monitor sysfs files when the monitor mechanism is not used.Remove ".default_attributes" from "
vmbus_chan_attrs" and create a channel-level attribute group. These changes allow the new "is_visible()" callback function to be applied to the channel-level attributes.
Quoted 6 lines
Call "
sysfs_create_group()" in "vmbus_add_channel_kobj()" to create the channel's sysfs files. Add a new function, “vmbus_remove_channel_attr_group()”, and call it in "free_channel()" to remove the channel's sysfs files when the channel is closed.Signed-off-by Kimberly Brown <[email protected]>
Nice work, thanks for all of the changes you have made to this over time.
RE: [PATCH v6] Drivers: hv: vmbus: Expose monitor data only when monitor pages are used
In reply to Kimberly BrownFrom: Kimberly Brown <[email protected]> Sent: Monday, March 18, 2019 9:04 PM
Quoted 25 lines
There are two methods for signaling the host: the monitor page mechanism and hypercalls. The monitor page mechanism is used by performance critical channels (storage, networking, etc.) because it provides improved throughput. However, latency is increased. Monitor pages are allocated to these channels.
Monitor pages are not allocated to channels that do not use the monitor page mechanism. Therefore, these channels do not have a valid monitor id or valid monitor page data. In these cases, some of the "
_show" functions return incorrect data. They return an invalid monitor id and data that is beyond the bounds of thehv_monitor_pagearray fields.The "
channel->offermsg.monitor_allocated" value can be used to determine whether monitor pages have been allocated to a channel.Add "
is_visible()" callback functions for the device-level and channel-level attribute groups. These functions will hide the monitor sysfs files when the monitor mechanism is not used.Remove ".default_attributes" from "
vmbus_chan_attrs" and create a channel-level attribute group. These changes allow the new "is_visible()" callback function to be applied to the channel-level attributes.
Quoted 6 lines
Call "
sysfs_create_group()" in "vmbus_add_channel_kobj()" to create the channel's sysfs files. Add a new function, “vmbus_remove_channel_attr_group()”, and call it in "free_channel()" to remove the channel's sysfs files when the channel is closed.Signed-off-by Kimberly Brown <[email protected]>
Sasha Levin
AppliedRe: [PATCH v6] Drivers: hv: vmbus: Expose monitor data only when monitor pages are used
In reply to Kimberly BrownQuoted 24 lines · Kimberly Brown
There are two methods for signaling the host: the monitor page mechanism and hypercalls. The monitor page mechanism is used by performance critical channels (storage, networking, etc.) because it provides improved throughput. However, latency is increased. Monitor pages are allocated to these channels.
Monitor pages are not allocated to channels that do not use the monitor page mechanism. Therefore, these channels do not have a valid monitor id or valid monitor page data. In these cases, some of the "
_show" functions return incorrect data. They return an invalid monitor id and data that is beyond the bounds of thehv_monitor_pagearray fields.The "
channel->offermsg.monitor_allocated" value can be used to determine whether monitor pages have been allocated to a channel.Add "
is_visible()" callback functions for the device-level and channel-level attribute groups. These functions will hide the monitor sysfs files when the monitor mechanism is not used.Remove ".default_attributes" from "
vmbus_chan_attrs" and create a channel-level attribute group. These changes allow the new "is_visible()" callback function to be applied to the channel-level attributes.
Quoted 6 lines
Call "
sysfs_create_group()" in "vmbus_add_channel_kobj()" to create the channel's sysfs files. Add a new function, “vmbus_remove_channel_attr_group()”, and call it in "free_channel()" to remove the channel's sysfs files when the channel is closed.Signed-off-by Kimberly Brown <[email protected]>
I've queued it up for hyperv-fixes, thanks Kimberly.
Should this go in stable as well?
--
Thanks,
Sasha
RE: [PATCH v6] Drivers: hv: vmbus: Expose monitor data only when monitor pages are used
From: Sasha Levin <[email protected]> Sent: Wednesday, March 20, 2019 8:57 PM
Quoted 5 lines
I've queued it up for hyperv-fixes, thanks Kimberly.
Should this go in stable as well?
My take: these changes lean more toward being a "clean up" rather than fixing a problem that has significant impact. The data in the sysfs entries is bogus, but isn't actually hurting anything. The current code does index off the end of an array in some cases, but the accesses are reads and there's plenty of padding so that actually making an invalid memory
reference won't happen. In the interest of reducing churn in the
stable branches, I would lean toward *not* backporting this to stable.
Michael