Linux-HyperV List
 help / color / mirror / Atom feed
* [PATCH v2 0/4] drivers: hv: mark some sysfs attribute as const
@ 2026-04-03  8:29 Thomas Weißschuh
  2026-04-03  8:29 ` [PATCH v2 1/4] drivers: hv: mark chan_attr_ring_buffer " Thomas Weißschuh
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Thomas Weißschuh @ 2026-04-03  8:29 UTC (permalink / raw)
  To: K. Y. Srinivasan, Haiyang Zhang, Wei Liu, Dexuan Cui, Long Li
  Cc: Michael Kelley, linux-hyperv, linux-kernel, Thomas Weißschuh

The sysfs attribute structures are never modified.
Mark them as const where possible.

This excludes the device attributes for now, as these will have their
own migration.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
Changes in v2:
- Mark missed four channels attributes as const (Michael Kelley)
- Link to v1: https://patch.msgid.link/20260402-sysfs-const-hv-v1-0-a467d6f7726e@weissschuh.net

---
Thomas Weißschuh (4):
      drivers: hv: mark chan_attr_ring_buffer as const
      drivers: hv: use ATTRIBUTE_GROUPS helper
      drivers: hv: mark bus attributes as const
      drivers: hv: mark channel attributes as const

 drivers/hv/vmbus_drv.c | 51 ++++++++++++++++++++++++--------------------------
 1 file changed, 24 insertions(+), 27 deletions(-)
---
base-commit: 6de23f81a5e08be8fbf5e8d7e9febc72a5b5f27f
change-id: 20260331-sysfs-const-hv-cad05718c68a

Best regards,
--  
Thomas Weißschuh <linux@weissschuh.net>


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v2 1/4] drivers: hv: mark chan_attr_ring_buffer as const
  2026-04-03  8:29 [PATCH v2 0/4] drivers: hv: mark some sysfs attribute as const Thomas Weißschuh
@ 2026-04-03  8:29 ` Thomas Weißschuh
  2026-04-03  8:29 ` [PATCH v2 2/4] drivers: hv: use ATTRIBUTE_GROUPS helper Thomas Weißschuh
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 8+ messages in thread
From: Thomas Weißschuh @ 2026-04-03  8:29 UTC (permalink / raw)
  To: K. Y. Srinivasan, Haiyang Zhang, Wei Liu, Dexuan Cui, Long Li
  Cc: Michael Kelley, linux-hyperv, linux-kernel, Thomas Weißschuh

The structure is never modified, mark it as const.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Reviewed-by: Michael Kelley <mhklinux@outlook.com>
Tested-by: Michael Kelley <mhklinux@outlook.com>
---
 drivers/hv/vmbus_drv.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
index bc4fc1951ae1..5f9b7cc9080c 100644
--- a/drivers/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
@@ -1959,7 +1959,7 @@ static int hv_mmap_ring_buffer_wrapper(struct file *filp, struct kobject *kobj,
 	return channel->mmap_ring_buffer(channel, vma);
 }
 
-static struct bin_attribute chan_attr_ring_buffer = {
+static const struct bin_attribute chan_attr_ring_buffer = {
 	.attr = {
 		.name = "ring",
 		.mode = 0600,
@@ -1985,7 +1985,7 @@ static struct attribute *vmbus_chan_attrs[] = {
 	NULL
 };
 
-static const struct bin_attribute *vmbus_chan_bin_attrs[] = {
+static const struct bin_attribute *const vmbus_chan_bin_attrs[] = {
 	&chan_attr_ring_buffer,
 	NULL
 };

-- 
2.53.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v2 2/4] drivers: hv: use ATTRIBUTE_GROUPS helper
  2026-04-03  8:29 [PATCH v2 0/4] drivers: hv: mark some sysfs attribute as const Thomas Weißschuh
  2026-04-03  8:29 ` [PATCH v2 1/4] drivers: hv: mark chan_attr_ring_buffer " Thomas Weißschuh
@ 2026-04-03  8:29 ` Thomas Weißschuh
  2026-04-03  8:29 ` [PATCH v2 3/4] drivers: hv: mark bus attributes as const Thomas Weißschuh
  2026-04-03  8:29 ` [PATCH v2 4/4] drivers: hv: mark channel " Thomas Weißschuh
  3 siblings, 0 replies; 8+ messages in thread
From: Thomas Weißschuh @ 2026-04-03  8:29 UTC (permalink / raw)
  To: K. Y. Srinivasan, Haiyang Zhang, Wei Liu, Dexuan Cui, Long Li
  Cc: Michael Kelley, linux-hyperv, linux-kernel, Thomas Weißschuh

The current logic is equivalent to the helper.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Reviewed-by: Michael Kelley <mhklinux@outlook.com>
Tested-by: Michael Kelley <mhklinux@outlook.com>
---
 drivers/hv/vmbus_drv.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
index 5f9b7cc9080c..d41b39ab628d 100644
--- a/drivers/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
@@ -645,10 +645,7 @@ static struct attribute *vmbus_bus_attrs[] = {
 	&bus_attr_hibernation.attr,
 	NULL,
 };
-static const struct attribute_group vmbus_bus_group = {
-	.attrs = vmbus_bus_attrs,
-};
-__ATTRIBUTE_GROUPS(vmbus_bus);
+ATTRIBUTE_GROUPS(vmbus_bus);
 
 /*
  * vmbus_uevent - add uevent for our device

-- 
2.53.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v2 3/4] drivers: hv: mark bus attributes as const
  2026-04-03  8:29 [PATCH v2 0/4] drivers: hv: mark some sysfs attribute as const Thomas Weißschuh
  2026-04-03  8:29 ` [PATCH v2 1/4] drivers: hv: mark chan_attr_ring_buffer " Thomas Weißschuh
  2026-04-03  8:29 ` [PATCH v2 2/4] drivers: hv: use ATTRIBUTE_GROUPS helper Thomas Weißschuh
@ 2026-04-03  8:29 ` Thomas Weißschuh
  2026-04-03  8:29 ` [PATCH v2 4/4] drivers: hv: mark channel " Thomas Weißschuh
  3 siblings, 0 replies; 8+ messages in thread
From: Thomas Weißschuh @ 2026-04-03  8:29 UTC (permalink / raw)
  To: K. Y. Srinivasan, Haiyang Zhang, Wei Liu, Dexuan Cui, Long Li
  Cc: Michael Kelley, linux-hyperv, linux-kernel, Thomas Weißschuh

This attribute is never modified, mark it as const.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Reviewed-by: Michael Kelley <mhklinux@outlook.com>
Tested-by: Michael Kelley <mhklinux@outlook.com>
---
 drivers/hv/vmbus_drv.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
index d41b39ab628d..ecce6b72a2a2 100644
--- a/drivers/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
@@ -639,9 +639,9 @@ static ssize_t hibernation_show(const struct bus_type *bus, char *buf)
 	return sprintf(buf, "%d\n", !!hv_is_hibernation_supported());
 }
 
-static BUS_ATTR_RO(hibernation);
+static const BUS_ATTR_RO(hibernation);
 
-static struct attribute *vmbus_bus_attrs[] = {
+static const struct attribute *const vmbus_bus_attrs[] = {
 	&bus_attr_hibernation.attr,
 	NULL,
 };

-- 
2.53.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v2 4/4] drivers: hv: mark channel attributes as const
  2026-04-03  8:29 [PATCH v2 0/4] drivers: hv: mark some sysfs attribute as const Thomas Weißschuh
                   ` (2 preceding siblings ...)
  2026-04-03  8:29 ` [PATCH v2 3/4] drivers: hv: mark bus attributes as const Thomas Weißschuh
@ 2026-04-03  8:29 ` Thomas Weißschuh
  2026-04-03 15:56   ` Michael Kelley
  3 siblings, 1 reply; 8+ messages in thread
From: Thomas Weißschuh @ 2026-04-03  8:29 UTC (permalink / raw)
  To: K. Y. Srinivasan, Haiyang Zhang, Wei Liu, Dexuan Cui, Long Li
  Cc: Michael Kelley, linux-hyperv, linux-kernel, Thomas Weißschuh

These attributes are never modified, mark them as const.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Tested-by: Michael Kelley <mhklinux@outlook.com>
---
 drivers/hv/vmbus_drv.c | 38 +++++++++++++++++++-------------------
 1 file changed, 19 insertions(+), 19 deletions(-)

diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
index ecce6b72a2a2..b33b85764c19 100644
--- a/drivers/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
@@ -1695,7 +1695,7 @@ static ssize_t out_mask_show(struct vmbus_channel *channel, char *buf)
 	mutex_unlock(&rbi->ring_buffer_mutex);
 	return ret;
 }
-static VMBUS_CHAN_ATTR_RO(out_mask);
+static const VMBUS_CHAN_ATTR_RO(out_mask);
 
 static ssize_t in_mask_show(struct vmbus_channel *channel, char *buf)
 {
@@ -1712,7 +1712,7 @@ static ssize_t in_mask_show(struct vmbus_channel *channel, char *buf)
 	mutex_unlock(&rbi->ring_buffer_mutex);
 	return ret;
 }
-static VMBUS_CHAN_ATTR_RO(in_mask);
+static const VMBUS_CHAN_ATTR_RO(in_mask);
 
 static ssize_t read_avail_show(struct vmbus_channel *channel, char *buf)
 {
@@ -1729,7 +1729,7 @@ static ssize_t read_avail_show(struct vmbus_channel *channel, char *buf)
 	mutex_unlock(&rbi->ring_buffer_mutex);
 	return ret;
 }
-static VMBUS_CHAN_ATTR_RO(read_avail);
+static const VMBUS_CHAN_ATTR_RO(read_avail);
 
 static ssize_t write_avail_show(struct vmbus_channel *channel, char *buf)
 {
@@ -1746,7 +1746,7 @@ static ssize_t write_avail_show(struct vmbus_channel *channel, char *buf)
 	mutex_unlock(&rbi->ring_buffer_mutex);
 	return ret;
 }
-static VMBUS_CHAN_ATTR_RO(write_avail);
+static const VMBUS_CHAN_ATTR_RO(write_avail);
 
 static ssize_t target_cpu_show(struct vmbus_channel *channel, char *buf)
 {
@@ -1864,7 +1864,7 @@ static ssize_t target_cpu_store(struct vmbus_channel *channel,
 
 	return ret ?: count;
 }
-static VMBUS_CHAN_ATTR(cpu, 0644, target_cpu_show, target_cpu_store);
+static const VMBUS_CHAN_ATTR(cpu, 0644, target_cpu_show, target_cpu_store);
 
 static ssize_t channel_pending_show(struct vmbus_channel *channel,
 				    char *buf)
@@ -1873,7 +1873,7 @@ static ssize_t channel_pending_show(struct vmbus_channel *channel,
 		       channel_pending(channel,
 				       vmbus_connection.monitor_pages[1]));
 }
-static VMBUS_CHAN_ATTR(pending, 0444, channel_pending_show, NULL);
+static const VMBUS_CHAN_ATTR(pending, 0444, channel_pending_show, NULL);
 
 static ssize_t channel_latency_show(struct vmbus_channel *channel,
 				    char *buf)
@@ -1882,19 +1882,19 @@ static ssize_t channel_latency_show(struct vmbus_channel *channel,
 		       channel_latency(channel,
 				       vmbus_connection.monitor_pages[1]));
 }
-static VMBUS_CHAN_ATTR(latency, 0444, channel_latency_show, NULL);
+static const VMBUS_CHAN_ATTR(latency, 0444, channel_latency_show, NULL);
 
 static ssize_t channel_interrupts_show(struct vmbus_channel *channel, char *buf)
 {
 	return sprintf(buf, "%llu\n", channel->interrupts);
 }
-static VMBUS_CHAN_ATTR(interrupts, 0444, channel_interrupts_show, NULL);
+static const VMBUS_CHAN_ATTR(interrupts, 0444, channel_interrupts_show, NULL);
 
 static ssize_t channel_events_show(struct vmbus_channel *channel, char *buf)
 {
 	return sprintf(buf, "%llu\n", channel->sig_events);
 }
-static VMBUS_CHAN_ATTR(events, 0444, channel_events_show, NULL);
+static const VMBUS_CHAN_ATTR(events, 0444, channel_events_show, NULL);
 
 static ssize_t channel_intr_in_full_show(struct vmbus_channel *channel,
 					 char *buf)
@@ -1902,7 +1902,7 @@ static ssize_t channel_intr_in_full_show(struct vmbus_channel *channel,
 	return sprintf(buf, "%llu\n",
 		       (unsigned long long)channel->intr_in_full);
 }
-static VMBUS_CHAN_ATTR(intr_in_full, 0444, channel_intr_in_full_show, NULL);
+static const VMBUS_CHAN_ATTR(intr_in_full, 0444, channel_intr_in_full_show, NULL);
 
 static ssize_t channel_intr_out_empty_show(struct vmbus_channel *channel,
 					   char *buf)
@@ -1910,7 +1910,7 @@ static ssize_t channel_intr_out_empty_show(struct vmbus_channel *channel,
 	return sprintf(buf, "%llu\n",
 		       (unsigned long long)channel->intr_out_empty);
 }
-static VMBUS_CHAN_ATTR(intr_out_empty, 0444, channel_intr_out_empty_show, NULL);
+static const VMBUS_CHAN_ATTR(intr_out_empty, 0444, channel_intr_out_empty_show, NULL);
 
 static ssize_t channel_out_full_first_show(struct vmbus_channel *channel,
 					   char *buf)
@@ -1918,7 +1918,7 @@ static ssize_t channel_out_full_first_show(struct vmbus_channel *channel,
 	return sprintf(buf, "%llu\n",
 		       (unsigned long long)channel->out_full_first);
 }
-static VMBUS_CHAN_ATTR(out_full_first, 0444, channel_out_full_first_show, NULL);
+static const VMBUS_CHAN_ATTR(out_full_first, 0444, channel_out_full_first_show, NULL);
 
 static ssize_t channel_out_full_total_show(struct vmbus_channel *channel,
 					   char *buf)
@@ -1926,14 +1926,14 @@ static ssize_t channel_out_full_total_show(struct vmbus_channel *channel,
 	return sprintf(buf, "%llu\n",
 		       (unsigned long long)channel->out_full_total);
 }
-static VMBUS_CHAN_ATTR(out_full_total, 0444, channel_out_full_total_show, NULL);
+static const VMBUS_CHAN_ATTR(out_full_total, 0444, channel_out_full_total_show, NULL);
 
 static ssize_t subchannel_monitor_id_show(struct vmbus_channel *channel,
 					  char *buf)
 {
 	return sprintf(buf, "%u\n", channel->offermsg.monitorid);
 }
-static VMBUS_CHAN_ATTR(monitor_id, 0444, subchannel_monitor_id_show, NULL);
+static const VMBUS_CHAN_ATTR(monitor_id, 0444, subchannel_monitor_id_show, NULL);
 
 static ssize_t subchannel_id_show(struct vmbus_channel *channel,
 				  char *buf)
@@ -1941,7 +1941,7 @@ static ssize_t subchannel_id_show(struct vmbus_channel *channel,
 	return sprintf(buf, "%u\n",
 		       channel->offermsg.offer.sub_channel_index);
 }
-static VMBUS_CHAN_ATTR_RO(subchannel_id);
+static const VMBUS_CHAN_ATTR_RO(subchannel_id);
 
 static int hv_mmap_ring_buffer_wrapper(struct file *filp, struct kobject *kobj,
 				       const struct bin_attribute *attr,
@@ -1963,7 +1963,7 @@ static const struct bin_attribute chan_attr_ring_buffer = {
 	},
 	.mmap = hv_mmap_ring_buffer_wrapper,
 };
-static struct attribute *vmbus_chan_attrs[] = {
+static const struct attribute *const vmbus_chan_attrs[] = {
 	&chan_attr_out_mask.attr,
 	&chan_attr_in_mask.attr,
 	&chan_attr_read_avail.attr,
@@ -1992,7 +1992,7 @@ static const struct bin_attribute *const vmbus_chan_bin_attrs[] = {
  * 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 attribute *attr, int idx)
 {
 	const struct vmbus_channel *channel =
 		container_of(kobj, struct vmbus_channel, kobj);
@@ -2030,9 +2030,9 @@ static size_t vmbus_chan_bin_size(struct kobject *kobj,
 }
 
 static const struct attribute_group vmbus_chan_group = {
-	.attrs = vmbus_chan_attrs,
+	.attrs_const = vmbus_chan_attrs,
 	.bin_attrs = vmbus_chan_bin_attrs,
-	.is_visible = vmbus_chan_attr_is_visible,
+	.is_visible_const = vmbus_chan_attr_is_visible,
 	.is_bin_visible = vmbus_chan_bin_attr_is_visible,
 	.bin_size = vmbus_chan_bin_size,
 };

-- 
2.53.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* RE: [PATCH v2 4/4] drivers: hv: mark channel attributes as const
  2026-04-03  8:29 ` [PATCH v2 4/4] drivers: hv: mark channel " Thomas Weißschuh
@ 2026-04-03 15:56   ` Michael Kelley
  2026-04-03 16:15     ` Thomas Weißschuh
  0 siblings, 1 reply; 8+ messages in thread
From: Michael Kelley @ 2026-04-03 15:56 UTC (permalink / raw)
  To: Thomas Weißschuh, K. Y. Srinivasan, Haiyang Zhang, Wei Liu,
	Dexuan Cui, Long Li
  Cc: linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org

From: Thomas Weißschuh <linux@weissschuh.net> Sent: Friday, April 3, 2026 1:29 AM
> 
> These attributes are never modified, mark them as const.
> 
> Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
> Tested-by: Michael Kelley <mhklinux@outlook.com>

Reviewed-by: Michael Kelley <mhklinux@outlook.com>

But take a look at this analysis from Sashiko AI:
https://sashiko.dev/#/patchset/20260403-sysfs-const-hv-v2-0-8932ab8d41db%40weissschuh.net

This seems to be a valid concern with your earlier commit 7dd9fdb4939b9
"sysfs: attribute_group: enable const variants of is_visible()".

> ---
>  drivers/hv/vmbus_drv.c | 38 +++++++++++++++++++-------------------
>  1 file changed, 19 insertions(+), 19 deletions(-)
> 
> diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
> index ecce6b72a2a2..b33b85764c19 100644
> --- a/drivers/hv/vmbus_drv.c
> +++ b/drivers/hv/vmbus_drv.c
> @@ -1695,7 +1695,7 @@ static ssize_t out_mask_show(struct vmbus_channel
> *channel, char *buf)
>  	mutex_unlock(&rbi->ring_buffer_mutex);
>  	return ret;
>  }
> -static VMBUS_CHAN_ATTR_RO(out_mask);
> +static const VMBUS_CHAN_ATTR_RO(out_mask);
> 
>  static ssize_t in_mask_show(struct vmbus_channel *channel, char *buf)
>  {
> @@ -1712,7 +1712,7 @@ static ssize_t in_mask_show(struct vmbus_channel
> *channel, char *buf)
>  	mutex_unlock(&rbi->ring_buffer_mutex);
>  	return ret;
>  }
> -static VMBUS_CHAN_ATTR_RO(in_mask);
> +static const VMBUS_CHAN_ATTR_RO(in_mask);
> 
>  static ssize_t read_avail_show(struct vmbus_channel *channel, char *buf)
>  {
> @@ -1729,7 +1729,7 @@ static ssize_t read_avail_show(struct vmbus_channel
> *channel, char *buf)
>  	mutex_unlock(&rbi->ring_buffer_mutex);
>  	return ret;
>  }
> -static VMBUS_CHAN_ATTR_RO(read_avail);
> +static const VMBUS_CHAN_ATTR_RO(read_avail);
> 
>  static ssize_t write_avail_show(struct vmbus_channel *channel, char *buf)
>  {
> @@ -1746,7 +1746,7 @@ static ssize_t write_avail_show(struct vmbus_channel
> *channel, char *buf)
>  	mutex_unlock(&rbi->ring_buffer_mutex);
>  	return ret;
>  }
> -static VMBUS_CHAN_ATTR_RO(write_avail);
> +static const VMBUS_CHAN_ATTR_RO(write_avail);
> 
>  static ssize_t target_cpu_show(struct vmbus_channel *channel, char *buf)
>  {
> @@ -1864,7 +1864,7 @@ static ssize_t target_cpu_store(struct vmbus_channel
> *channel,
> 
>  	return ret ?: count;
>  }
> -static VMBUS_CHAN_ATTR(cpu, 0644, target_cpu_show, target_cpu_store);
> +static const VMBUS_CHAN_ATTR(cpu, 0644, target_cpu_show, target_cpu_store);
> 
>  static ssize_t channel_pending_show(struct vmbus_channel *channel,
>  				    char *buf)
> @@ -1873,7 +1873,7 @@ static ssize_t channel_pending_show(struct vmbus_channel
> *channel,
>  		       channel_pending(channel,
>  				       vmbus_connection.monitor_pages[1]));
>  }
> -static VMBUS_CHAN_ATTR(pending, 0444, channel_pending_show, NULL);
> +static const VMBUS_CHAN_ATTR(pending, 0444, channel_pending_show, NULL);
> 
>  static ssize_t channel_latency_show(struct vmbus_channel *channel,
>  				    char *buf)
> @@ -1882,19 +1882,19 @@ static ssize_t channel_latency_show(struct
> vmbus_channel *channel,
>  		       channel_latency(channel,
>  				       vmbus_connection.monitor_pages[1]));
>  }
> -static VMBUS_CHAN_ATTR(latency, 0444, channel_latency_show, NULL);
> +static const VMBUS_CHAN_ATTR(latency, 0444, channel_latency_show, NULL);
> 
>  static ssize_t channel_interrupts_show(struct vmbus_channel *channel, char *buf)
>  {
>  	return sprintf(buf, "%llu\n", channel->interrupts);
>  }
> -static VMBUS_CHAN_ATTR(interrupts, 0444, channel_interrupts_show, NULL);
> +static const VMBUS_CHAN_ATTR(interrupts, 0444, channel_interrupts_show, NULL);
> 
>  static ssize_t channel_events_show(struct vmbus_channel *channel, char *buf)
>  {
>  	return sprintf(buf, "%llu\n", channel->sig_events);
>  }
> -static VMBUS_CHAN_ATTR(events, 0444, channel_events_show, NULL);
> +static const VMBUS_CHAN_ATTR(events, 0444, channel_events_show, NULL);
> 
>  static ssize_t channel_intr_in_full_show(struct vmbus_channel *channel,
>  					 char *buf)
> @@ -1902,7 +1902,7 @@ static ssize_t channel_intr_in_full_show(struct
> vmbus_channel *channel,
>  	return sprintf(buf, "%llu\n",
>  		       (unsigned long long)channel->intr_in_full);
>  }
> -static VMBUS_CHAN_ATTR(intr_in_full, 0444, channel_intr_in_full_show, NULL);
> +static const VMBUS_CHAN_ATTR(intr_in_full, 0444, channel_intr_in_full_show, NULL);
> 
>  static ssize_t channel_intr_out_empty_show(struct vmbus_channel *channel,
>  					   char *buf)
> @@ -1910,7 +1910,7 @@ static ssize_t channel_intr_out_empty_show(struct
> vmbus_channel *channel,
>  	return sprintf(buf, "%llu\n",
>  		       (unsigned long long)channel->intr_out_empty);
>  }
> -static VMBUS_CHAN_ATTR(intr_out_empty, 0444, channel_intr_out_empty_show,
> NULL);
> +static const VMBUS_CHAN_ATTR(intr_out_empty, 0444,
> channel_intr_out_empty_show, NULL);
> 
>  static ssize_t channel_out_full_first_show(struct vmbus_channel *channel,
>  					   char *buf)
> @@ -1918,7 +1918,7 @@ static ssize_t channel_out_full_first_show(struct
> vmbus_channel *channel,
>  	return sprintf(buf, "%llu\n",
>  		       (unsigned long long)channel->out_full_first);
>  }
> -static VMBUS_CHAN_ATTR(out_full_first, 0444, channel_out_full_first_show, NULL);
> +static const VMBUS_CHAN_ATTR(out_full_first, 0444, channel_out_full_first_show,
> NULL);
> 
>  static ssize_t channel_out_full_total_show(struct vmbus_channel *channel,
>  					   char *buf)
> @@ -1926,14 +1926,14 @@ static ssize_t channel_out_full_total_show(struct
> vmbus_channel *channel,
>  	return sprintf(buf, "%llu\n",
>  		       (unsigned long long)channel->out_full_total);
>  }
> -static VMBUS_CHAN_ATTR(out_full_total, 0444, channel_out_full_total_show, NULL);
> +static const VMBUS_CHAN_ATTR(out_full_total, 0444, channel_out_full_total_show,
> NULL);
> 
>  static ssize_t subchannel_monitor_id_show(struct vmbus_channel *channel,
>  					  char *buf)
>  {
>  	return sprintf(buf, "%u\n", channel->offermsg.monitorid);
>  }
> -static VMBUS_CHAN_ATTR(monitor_id, 0444, subchannel_monitor_id_show, NULL);
> +static const VMBUS_CHAN_ATTR(monitor_id, 0444, subchannel_monitor_id_show,
> NULL);
> 
>  static ssize_t subchannel_id_show(struct vmbus_channel *channel,
>  				  char *buf)
> @@ -1941,7 +1941,7 @@ static ssize_t subchannel_id_show(struct vmbus_channel
> *channel,
>  	return sprintf(buf, "%u\n",
>  		       channel->offermsg.offer.sub_channel_index);
>  }
> -static VMBUS_CHAN_ATTR_RO(subchannel_id);
> +static const VMBUS_CHAN_ATTR_RO(subchannel_id);
> 
>  static int hv_mmap_ring_buffer_wrapper(struct file *filp, struct kobject *kobj,
>  				       const struct bin_attribute *attr,
> @@ -1963,7 +1963,7 @@ static const struct bin_attribute chan_attr_ring_buffer = {
>  	},
>  	.mmap = hv_mmap_ring_buffer_wrapper,
>  };
> -static struct attribute *vmbus_chan_attrs[] = {
> +static const struct attribute *const vmbus_chan_attrs[] = {
>  	&chan_attr_out_mask.attr,
>  	&chan_attr_in_mask.attr,
>  	&chan_attr_read_avail.attr,
> @@ -1992,7 +1992,7 @@ static const struct bin_attribute *const
> vmbus_chan_bin_attrs[] = {
>   * 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 attribute *attr, int idx)
>  {
>  	const struct vmbus_channel *channel =
>  		container_of(kobj, struct vmbus_channel, kobj);
> @@ -2030,9 +2030,9 @@ static size_t vmbus_chan_bin_size(struct kobject *kobj,
>  }
> 
>  static const struct attribute_group vmbus_chan_group = {
> -	.attrs = vmbus_chan_attrs,
> +	.attrs_const = vmbus_chan_attrs,
>  	.bin_attrs = vmbus_chan_bin_attrs,
> -	.is_visible = vmbus_chan_attr_is_visible,
> +	.is_visible_const = vmbus_chan_attr_is_visible,
>  	.is_bin_visible = vmbus_chan_bin_attr_is_visible,
>  	.bin_size = vmbus_chan_bin_size,
>  };
> 
> --
> 2.53.0
> 


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 4/4] drivers: hv: mark channel attributes as const
  2026-04-03 15:56   ` Michael Kelley
@ 2026-04-03 16:15     ` Thomas Weißschuh
  2026-04-03 17:46       ` Michael Kelley
  0 siblings, 1 reply; 8+ messages in thread
From: Thomas Weißschuh @ 2026-04-03 16:15 UTC (permalink / raw)
  To: Michael Kelley
  Cc: K. Y. Srinivasan, Haiyang Zhang, Wei Liu, Dexuan Cui, Long Li,
	linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org

On 2026-04-03 15:56:54+0000, Michael Kelley wrote:
> From: Thomas Weißschuh <linux@weissschuh.net> Sent: Friday, April 3, 2026 1:29 AM
> > 
> > These attributes are never modified, mark them as const.
> > 
> > Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
> > Tested-by: Michael Kelley <mhklinux@outlook.com>
> 
> Reviewed-by: Michael Kelley <mhklinux@outlook.com>

Thanks.

> But take a look at this analysis from Sashiko AI:
> https://sashiko.dev/#/patchset/20260403-sysfs-const-hv-v2-0-8932ab8d41db%40weissschuh.net
> 
> This seems to be a valid concern with your earlier commit 7dd9fdb4939b9
> "sysfs: attribute_group: enable const variants of is_visible()".

Indeed, I missed this user of ->is_visible.
I'll send a fix for that, but it shouldn't affect this series.


Thomas

^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: [PATCH v2 4/4] drivers: hv: mark channel attributes as const
  2026-04-03 16:15     ` Thomas Weißschuh
@ 2026-04-03 17:46       ` Michael Kelley
  0 siblings, 0 replies; 8+ messages in thread
From: Michael Kelley @ 2026-04-03 17:46 UTC (permalink / raw)
  To: Thomas Weißschuh, Michael Kelley
  Cc: K. Y. Srinivasan, Haiyang Zhang, Wei Liu, Dexuan Cui, Long Li,
	linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org

From: Thomas Weißschuh <linux@weissschuh.net> Sent: Friday, April 3, 2026 9:16 AM
> 
> On 2026-04-03 15:56:54+0000, Michael Kelley wrote:
> > From: Thomas Weißschuh <linux@weissschuh.net> Sent: Friday, April 3, 2026 1:29 AM
> > >
> > > These attributes are never modified, mark them as const.
> > >
> > > Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
> > > Tested-by: Michael Kelley <mhklinux@outlook.com>
> >
> > Reviewed-by: Michael Kelley <mhklinux@outlook.com>
> 
> Thanks.
> 
> > But take a look at this analysis from Sashiko AI:
> > https://sashiko.dev/#/patchset/20260403-sysfs-const-hv-v2-0-8932ab8d41db%40weissschuh.net
> >
> > This seems to be a valid concern with your earlier commit 7dd9fdb4939b9
> > "sysfs: attribute_group: enable const variants of is_visible()".
> 
> Indeed, I missed this user of ->is_visible.
> I'll send a fix for that, but it shouldn't affect this series.
> 

Agreed.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-04-03 17:46 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-03  8:29 [PATCH v2 0/4] drivers: hv: mark some sysfs attribute as const Thomas Weißschuh
2026-04-03  8:29 ` [PATCH v2 1/4] drivers: hv: mark chan_attr_ring_buffer " Thomas Weißschuh
2026-04-03  8:29 ` [PATCH v2 2/4] drivers: hv: use ATTRIBUTE_GROUPS helper Thomas Weißschuh
2026-04-03  8:29 ` [PATCH v2 3/4] drivers: hv: mark bus attributes as const Thomas Weißschuh
2026-04-03  8:29 ` [PATCH v2 4/4] drivers: hv: mark channel " Thomas Weißschuh
2026-04-03 15:56   ` Michael Kelley
2026-04-03 16:15     ` Thomas Weißschuh
2026-04-03 17:46       ` Michael Kelley

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox