Skip to contentSkip to conversation

net: phy: improve stats handling in mdio_bus.c

PATCH Applied Heiner Kallweit 3 participants 12 messages Feb 27 – Mar 5

Subsystems (3)
lore
Share & tools
lore

Heiner Kallweit

author maintainer
#0 lore raw

cover net: phy: improve stats handling in mdio_bus.c

Improve stats handling in mdio_bus.c.

Heiner Kallweit (8):
net: mdio: extend struct mdio_bus_stat_attr instead of using
dev_ext_attribute
net: mdio: use macro __ATTR to simplify the code
net: phy: consider that mdio_bus_device_stat_field_show doesn't use
member address
net: phy: avoid extra casting in mdio_bus_get_stat
net: mdio: constify attributes and attribute arrays
net: mdio: use macro __ATTRIBUTE_GROUPS
net: phy: inline helper mdio_bus_get_global_stat
net: phy: improve mdiobus_stats_acct

 drivers/net/phy/mdio_bus.c | 124 ++++++++++++++-----------------------
 1 file changed, 46 insertions(+), 78 deletions(-)
Signature · 1 line
2.53.0
author maintainer
#1 lore raw

PATCH 1/8 net: mdio: extend struct mdio_bus_stat_attr instead of using dev_ext_attribute

Currently the var member of struct dev_ext_attribute is used in a very ugly way. Extend struct mdio_bus_stat_attr instead, what allows to simplify the code and also slightly reduces memory footprint.

Note: Member addr is renamed to avoid a conflict in macro
MDIO_BUS_STATS_ADDR_ATTR_DECL.

---
 drivers/net/phy/mdio_bus.c | 45 +++++++++++++++++---------------------
 1 file changed, 20 insertions(+), 25 deletions(-)
drivers/net/phy/mdio_bus.c +20 -25
index afdf1ad6c0e..4fe9859369b 100644
@@ -124,10 +124,16 @@ static void mdiobus_release(struct device *d)
 }
 
 struct mdio_bus_stat_attr {
-	int addr;
+	struct device_attribute attr;
+	int address;
 	unsigned int field_offset;
 };
 
+static struct mdio_bus_stat_attr *to_sattr(struct device_attribute *attr)
+{
+	return container_of(attr, struct mdio_bus_stat_attr, attr);
+}
+
 static u64 mdio_bus_get_stat(struct mdio_bus_stats *s, unsigned int offset)
 {
 	const char *p = (const char *)s + offset;
@@ -157,18 +163,14 @@ static ssize_t mdio_bus_stat_field_show(struct device *dev,
 					struct device_attribute *attr,
 					char *buf)
 {
+	struct mdio_bus_stat_attr *sattr = to_sattr(attr);
 	struct mii_bus *bus = to_mii_bus(dev);
-	struct mdio_bus_stat_attr *sattr;
-	struct dev_ext_attribute *eattr;
 	u64 val;
 
-	eattr = container_of(attr, struct dev_ext_attribute, attr);
-	sattr = eattr->var;
-
-	if (sattr->addr < 0)
+	if (sattr->address < 0)
 		val = mdio_bus_get_global_stat(bus, sattr->field_offset);
 	else
-		val = mdio_bus_get_stat(&bus->stats[sattr->addr],
+		val = mdio_bus_get_stat(&bus->stats[sattr->address],
 					sattr->field_offset);
 
 	return sysfs_emit(buf, "%llu\n", val);
@@ -178,37 +180,31 @@ static ssize_t mdio_bus_device_stat_field_show(struct device *dev,
 					       struct device_attribute *attr,
 					       char *buf)
 {
+	struct mdio_bus_stat_attr *sattr = to_sattr(attr);
 	struct mdio_device *mdiodev = to_mdio_device(dev);
 	struct mii_bus *bus = mdiodev->bus;
-	struct mdio_bus_stat_attr *sattr;
-	struct dev_ext_attribute *eattr;
 	int addr = mdiodev->addr;
 	u64 val;
 
-	eattr = container_of(attr, struct dev_ext_attribute, attr);
-	sattr = eattr->var;
-
 	val = mdio_bus_get_stat(&bus->stats[addr], sattr->field_offset);
 
 	return sysfs_emit(buf, "%llu\n", val);
 }
 
 #define MDIO_BUS_STATS_ATTR_DECL(field, file)				\
-static struct dev_ext_attribute dev_attr_mdio_bus_##field = {		\
+static struct mdio_bus_stat_attr dev_attr_mdio_bus_##field = {		\
 	.attr = { .attr = { .name = file, .mode = 0444 },		\
 		     .show = mdio_bus_stat_field_show,			\
 	},								\
-	.var = &((struct mdio_bus_stat_attr) {				\
-		-1, offsetof(struct mdio_bus_stats, field)		\
-	}),								\
+	.address = -1,							\
+	.field_offset = offsetof(struct mdio_bus_stats, field),		\
 };									\
-static struct dev_ext_attribute dev_attr_mdio_bus_device_##field = {	\
+static struct mdio_bus_stat_attr dev_attr_mdio_bus_device_##field = {	\
 	.attr = { .attr = { .name = file, .mode = 0444 },		\
 		     .show = mdio_bus_device_stat_field_show,		\
 	},								\
-	.var = &((struct mdio_bus_stat_attr) {				\
-		-1, offsetof(struct mdio_bus_stats, field)		\
-	}),								\
+	.address = -1,							\
+	.field_offset = offsetof(struct mdio_bus_stats, field),		\
 };
 
 #define MDIO_BUS_STATS_ATTR(field)					\
@@ -220,13 +216,12 @@ MDIO_BUS_STATS_ATTR(writes);
 MDIO_BUS_STATS_ATTR(reads);
 
 #define MDIO_BUS_STATS_ADDR_ATTR_DECL(field, addr, file)		\
-static struct dev_ext_attribute dev_attr_mdio_bus_addr_##field##_##addr = { \
+static struct mdio_bus_stat_attr dev_attr_mdio_bus_addr_##field##_##addr = { \
 	.attr = { .attr = { .name = file, .mode = 0444 },		\
 		     .show = mdio_bus_stat_field_show,			\
 	},								\
-	.var = &((struct mdio_bus_stat_attr) {				\
-		addr, offsetof(struct mdio_bus_stats, field)		\
-	}),								\
+	.address = addr,						\
+	.field_offset = offsetof(struct mdio_bus_stats, field),		\
 }
 
 #define MDIO_BUS_STATS_ADDR_ATTR(field, addr)				\
Signature · 1 line
2.53.0
author maintainer
#2 lore raw

PATCH 2/8 net: mdio: use macro __ATTR to simplify the code

In reply to Heiner Kallweit

Use macro __ATTR to simplify the code. Note that __ATTR can't be used in MDIO_BUS_STATS_ADDR_ATTR_DECL because the included stringification would conflict with how argument file is passed.

---
 drivers/net/phy/mdio_bus.c | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)
drivers/net/phy/mdio_bus.c +4 -11
index 4fe9859369b..0c0cf7a7296 100644
@@ -191,24 +191,17 @@ static ssize_t mdio_bus_device_stat_field_show(struct device *dev,
 	return sysfs_emit(buf, "%llu\n", val);
 }
 
-#define MDIO_BUS_STATS_ATTR_DECL(field, file)				\
+#define MDIO_BUS_STATS_ATTR(field)					\
 static struct mdio_bus_stat_attr dev_attr_mdio_bus_##field = {		\
-	.attr = { .attr = { .name = file, .mode = 0444 },		\
-		     .show = mdio_bus_stat_field_show,			\
-	},								\
+	.attr = __ATTR(field, 0444, mdio_bus_stat_field_show, NULL),	\
 	.address = -1,							\
 	.field_offset = offsetof(struct mdio_bus_stats, field),		\
 };									\
 static struct mdio_bus_stat_attr dev_attr_mdio_bus_device_##field = {	\
-	.attr = { .attr = { .name = file, .mode = 0444 },		\
-		     .show = mdio_bus_device_stat_field_show,		\
-	},								\
+	.attr = __ATTR(field, 0444, mdio_bus_device_stat_field_show, NULL), \
 	.address = -1,							\
 	.field_offset = offsetof(struct mdio_bus_stats, field),		\
-};
-
-#define MDIO_BUS_STATS_ATTR(field)					\
-	MDIO_BUS_STATS_ATTR_DECL(field, __stringify(field))
+}
 
 MDIO_BUS_STATS_ATTR(transfers);
 MDIO_BUS_STATS_ATTR(errors);
Signature · 1 line
2.53.0
author maintainer
#3 lore raw

PATCH 3/8 net: phy: consider that mdio_bus_device_stat_field_show doesn't use member address

In reply to Heiner Kallweit

mdio_bus_device_stat_field_show() doesn't use the address member, so we don't have to initialize it.

---
 drivers/net/phy/mdio_bus.c | 1 -
 1 file changed, 1 deletion(-)
drivers/net/phy/mdio_bus.c +0 -1
index 0c0cf7a7296..f189e9fbcbd 100644
@@ -199,7 +199,6 @@ static struct mdio_bus_stat_attr dev_attr_mdio_bus_##field = {		\
 };									\
 static struct mdio_bus_stat_attr dev_attr_mdio_bus_device_##field = {	\
 	.attr = __ATTR(field, 0444, mdio_bus_device_stat_field_show, NULL), \
-	.address = -1,							\
 	.field_offset = offsetof(struct mdio_bus_stats, field),		\
 }
 
Signature · 1 line
2.53.0
author maintainer
#4 lore raw

PATCH 4/8 net: phy: avoid extra casting in mdio_bus_get_stat

In reply to Heiner Kallweit

Using void * instead of char * allows to remove one cast.

---
 drivers/net/phy/mdio_bus.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/phy/mdio_bus.c +2 -2
index f189e9fbcbd..fb2bcc69c8d 100644
@@ -136,13 +136,13 @@ static struct mdio_bus_stat_attr *to_sattr(struct device_attribute *attr)
 
 static u64 mdio_bus_get_stat(struct mdio_bus_stats *s, unsigned int offset)
 {
-	const char *p = (const char *)s + offset;
+	const u64_stats_t *stats = (const void *)s + offset;
 	unsigned int start;
 	u64 val = 0;
 
 	do {
 		start = u64_stats_fetch_begin(&s->syncp);
-		val = u64_stats_read((const u64_stats_t *)p);
+		val = u64_stats_read(stats);
 	} while (u64_stats_fetch_retry(&s->syncp, start));
 
 	return val;
Signature · 1 line
2.53.0
author maintainer
#5 lore raw

PATCH 5/8 net: mdio: constify attributes and attribute arrays

In reply to Heiner Kallweit

Constify attributes and attribute arrays, using new member attrs_const of struct attribute_group.

---
 drivers/net/phy/mdio_bus.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)
drivers/net/phy/mdio_bus.c +10 -9
index fb2bcc69c8d..750b9165086 100644
@@ -192,12 +192,12 @@ static ssize_t mdio_bus_device_stat_field_show(struct device *dev,
 }
 
 #define MDIO_BUS_STATS_ATTR(field)					\
-static struct mdio_bus_stat_attr dev_attr_mdio_bus_##field = {		\
+static const struct mdio_bus_stat_attr dev_attr_mdio_bus_##field = {	\
 	.attr = __ATTR(field, 0444, mdio_bus_stat_field_show, NULL),	\
 	.address = -1,							\
 	.field_offset = offsetof(struct mdio_bus_stats, field),		\
 };									\
-static struct mdio_bus_stat_attr dev_attr_mdio_bus_device_##field = {	\
+static const struct mdio_bus_stat_attr dev_attr_mdio_bus_device_##field = { \
 	.attr = __ATTR(field, 0444, mdio_bus_device_stat_field_show, NULL), \
 	.field_offset = offsetof(struct mdio_bus_stats, field),		\
 }
@@ -208,7 +208,8 @@ MDIO_BUS_STATS_ATTR(writes);
 MDIO_BUS_STATS_ATTR(reads);
 
 #define MDIO_BUS_STATS_ADDR_ATTR_DECL(field, addr, file)		\
-static struct mdio_bus_stat_attr dev_attr_mdio_bus_addr_##field##_##addr = { \
+static const struct mdio_bus_stat_attr					\
+dev_attr_mdio_bus_addr_##field##_##addr = {				\
 	.attr = { .attr = { .name = file, .mode = 0444 },		\
 		     .show = mdio_bus_stat_field_show,			\
 	},								\
@@ -265,7 +266,7 @@ MDIO_BUS_STATS_ADDR_ATTR_GROUP_DECL(31);
 	&dev_attr_mdio_bus_addr_writes_##addr.attr.attr,		\
 	&dev_attr_mdio_bus_addr_reads_##addr.attr.attr			\
 
-static struct attribute *mdio_bus_statistics_attrs[] = {
+static const struct attribute *const mdio_bus_statistics_attrs[] = {
 	&dev_attr_mdio_bus_transfers.attr.attr,
 	&dev_attr_mdio_bus_errors.attr.attr,
 	&dev_attr_mdio_bus_writes.attr.attr,
@@ -306,8 +307,8 @@ static struct attribute *mdio_bus_statistics_attrs[] = {
 };
 
 static const struct attribute_group mdio_bus_statistics_group = {
-	.name	= "statistics",
-	.attrs	= mdio_bus_statistics_attrs,
+	.name		= "statistics",
+	.attrs_const	= mdio_bus_statistics_attrs,
 };
 
 static const struct attribute_group *mdio_bus_groups[] = {
@@ -973,7 +974,7 @@ static int mdio_uevent(const struct device *dev, struct kobj_uevent_env *env)
 	return 0;
 }
 
-static struct attribute *mdio_bus_device_statistics_attrs[] = {
+static const struct attribute *const mdio_bus_device_statistics_attrs[] = {
 	&dev_attr_mdio_bus_device_transfers.attr.attr,
 	&dev_attr_mdio_bus_device_errors.attr.attr,
 	&dev_attr_mdio_bus_device_writes.attr.attr,
@@ -982,8 +983,8 @@ static struct attribute *mdio_bus_device_statistics_attrs[] = {
 };
 
 static const struct attribute_group mdio_bus_device_statistics_group = {
-	.name	= "statistics",
-	.attrs	= mdio_bus_device_statistics_attrs,
+	.name		= "statistics",
+	.attrs_const	= mdio_bus_device_statistics_attrs,
 };
 
 static const struct attribute_group *mdio_bus_dev_groups[] = {
Signature · 1 line
2.53.0
author maintainer
#6 lore raw

PATCH 6/8 net: mdio: use macro __ATTRIBUTE_GROUPS

In reply to Heiner Kallweit

Use macro __ATTRIBUTE_GROUPS() to simplify the code.

---
 drivers/net/phy/mdio_bus.c | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)
drivers/net/phy/mdio_bus.c +4 -12
index 750b9165086..0e2820ab8cb 100644
@@ -310,16 +310,12 @@ static const struct attribute_group mdio_bus_statistics_group = {
 	.name		= "statistics",
 	.attrs_const	= mdio_bus_statistics_attrs,
 };
-
-static const struct attribute_group *mdio_bus_groups[] = {
-	&mdio_bus_statistics_group,
-	NULL,
-};
+__ATTRIBUTE_GROUPS(mdio_bus_statistics);
 
 const struct class mdio_bus_class = {
 	.name		= "mdio_bus",
 	.dev_release	= mdiobus_release,
-	.dev_groups	= mdio_bus_groups,
+	.dev_groups	= mdio_bus_statistics_groups,
 };
 EXPORT_SYMBOL_GPL(mdio_bus_class);
 
@@ -986,15 +982,11 @@ static const struct attribute_group mdio_bus_device_statistics_group = {
 	.name		= "statistics",
 	.attrs_const	= mdio_bus_device_statistics_attrs,
 };
-
-static const struct attribute_group *mdio_bus_dev_groups[] = {
-	&mdio_bus_device_statistics_group,
-	NULL,
-};
+__ATTRIBUTE_GROUPS(mdio_bus_device_statistics);
 
 const struct bus_type mdio_bus_type = {
 	.name		= "mdio_bus",
-	.dev_groups	= mdio_bus_dev_groups,
+	.dev_groups	= mdio_bus_device_statistics_groups,
 	.match		= mdio_bus_match,
 	.uevent		= mdio_uevent,
 };
Signature · 1 line
2.53.0
author maintainer
#7 lore raw

PATCH 7/8 net: phy: inline helper mdio_bus_get_global_stat

In reply to Heiner Kallweit

mdio_bus_get_global_stat() has only one user. Inline it to simplify the code.

---
 drivers/net/phy/mdio_bus.c | 23 ++++++++---------------
 1 file changed, 8 insertions(+), 15 deletions(-)
drivers/net/phy/mdio_bus.c +8 -15
index 0e2820ab8cb..48c0447e6a8 100644
@@ -148,30 +148,23 @@ static u64 mdio_bus_get_stat(struct mdio_bus_stats *s, unsigned int offset)
 	return val;
 }
 
-static u64 mdio_bus_get_global_stat(struct mii_bus *bus, unsigned int offset)
-{
-	unsigned int i;
-	u64 val = 0;
-
-	for (i = 0; i < PHY_MAX_ADDR; i++)
-		val += mdio_bus_get_stat(&bus->stats[i], offset);
-
-	return val;
-}
-
 static ssize_t mdio_bus_stat_field_show(struct device *dev,
 					struct device_attribute *attr,
 					char *buf)
 {
 	struct mdio_bus_stat_attr *sattr = to_sattr(attr);
 	struct mii_bus *bus = to_mii_bus(dev);
-	u64 val;
+	u64 val = 0;
 
-	if (sattr->address < 0)
-		val = mdio_bus_get_global_stat(bus, sattr->field_offset);
-	else
+	if (sattr->address < 0) {
+		/* get global stats */
+		for (int i = 0; i < PHY_MAX_ADDR; i++)
+			val += mdio_bus_get_stat(&bus->stats[i],
+						 sattr->field_offset);
+	} else {
 		val = mdio_bus_get_stat(&bus->stats[sattr->address],
 					sattr->field_offset);
+	}
 
 	return sysfs_emit(buf, "%llu\n", val);
 }
Signature · 1 line
2.53.0
author maintainer
#8 lore raw

PATCH 8/8 net: phy: improve mdiobus_stats_acct

In reply to Heiner Kallweit

- Remove duplicated preempt disable. Disabling preemption has been added to functions like u64_stats_update_begin() in the meantime.
- Simplify branch structure

---
 drivers/net/phy/mdio_bus.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)
drivers/net/phy/mdio_bus.c +3 -8
index 48c0447e6a8..b32a369cd25 100644
@@ -358,22 +358,17 @@ EXPORT_SYMBOL(of_mdio_find_bus);
 
 static void mdiobus_stats_acct(struct mdio_bus_stats *stats, bool op, int ret)
 {
-	preempt_disable();
 	u64_stats_update_begin(&stats->syncp);
 
 	u64_stats_inc(&stats->transfers);
-	if (ret < 0) {
+	if (ret < 0)
 		u64_stats_inc(&stats->errors);
-		goto out;
-	}
-
-	if (op)
+	else if (op)
 		u64_stats_inc(&stats->reads);
 	else
 		u64_stats_inc(&stats->writes);
-out:
+
 	u64_stats_update_end(&stats->syncp);
-	preempt_enable();
 }
 
 /**
Signature · 1 line
2.53.0
#9 lore raw

Re: [PATCH net-next 8/8] net: phy: improve mdiobus_stats_acct

Quoted 5 lines · Heiner Kallweit

- Remove duplicated preempt disable. Disabling preemption has been added to functions like u64_stats_update_begin() in the meantime.
- Simplify branch structure

This patch has been merged to yesterday's linux-next as commit 1afccc5a201e ("net: phy: improve mdiobus_stats_acct"). In my tests I found that it introduces the following warning on 32bit machines with USB ethernet adapters, so the preempt disable was there for a good reason:

------------[ cut here ]------------
WARNING: ./include/linux/u64_stats_sync.h:171 at 
mdiobus_stats_acct+0x288/0x2b4, CPU#0: kworker/0:3/50
Loading compiled-in X.509 certificates
Modules linked in:
CPU: 0 UID: 0 PID: 50 Comm: kworker/0:3 Not tainted 
7.0.0-rc2-next-20260304 #12283 PREEMPT
Hardware name: Samsung Exynos (Flattened Device Tree)
Workqueue: usb_hub_wq hub_event
Call trace:
  unwind_backtrace from show_stack+0x10/0x14
  show_stack from dump_stack_lvl+0x68/0x88
  dump_stack_lvl from __warn+0x94/0x210
  __warn from warn_slowpath_fmt+0x1b0/0x1bc
  warn_slowpath_fmt from mdiobus_stats_acct+0x288/0x2b4
  mdiobus_stats_acct from __mdiobus_read+0x84/0xf0
  __mdiobus_read from mdiobus_read+0x30/0x44
  mdiobus_read from get_phy_device+0xac/0x140
  get_phy_device from mdiobus_scan+0x24/0x104
  mdiobus_scan from __mdiobus_register+0x21c/0x478
  __mdiobus_register from smsc95xx_bind+0x3f4/0x5f0
  smsc95xx_bind from usbnet_probe+0x330/0x928
  usbnet_probe from usb_probe_interface+0xec/0x318
  usb_probe_interface from really_probe+0xe0/0x424
  really_probe from __driver_probe_device+0x9c/0x1f4
  __driver_probe_device from driver_probe_device+0x30/0xc0
  driver_probe_device from __device_attach_driver+0xa8/0x140
  __device_attach_driver from bus_for_each_drv+0x84/0xdc
  bus_for_each_drv from __device_attach+0xb0/0x214
  __device_attach from device_initial_probe+0x3c/0x48
  device_initial_probe from bus_probe_device+0x24/0x80
  bus_probe_device from device_add+0x5c0/0x810
  device_add from usb_set_configuration+0x4e4/0x974
  usb_set_configuration from usb_generic_driver_probe+0x3c/0x78
  usb_generic_driver_probe from usb_probe_device+0x4c/0x14c
  usb_probe_device from really_probe+0xe0/0x424
  really_probe from __driver_probe_device+0x9c/0x1f4
  __driver_probe_device from driver_probe_device+0x30/0xc0
  driver_probe_device from __device_attach_driver+0xa8/0x140
  __device_attach_driver from bus_for_each_drv+0x84/0xdc
  bus_for_each_drv from __device_attach+0xb0/0x214
  __device_attach from device_initial_probe+0x3c/0x48
  device_initial_probe from bus_probe_device+0x24/0x80
  bus_probe_device from device_add+0x5c0/0x810
  device_add from usb_new_device+0x23c/0x4f8
  usb_new_device from hub_event+0x11dc/0x1ca4
  hub_event from process_one_work+0x24c/0x7b8
  process_one_work from worker_thread+0x1b8/0x3bc
  worker_thread from kthread+0x128/0x168
  kthread from ret_from_fork+0x14/0x28
Exception stack(0xf0a15fb0 to 0xf0a15ff8)
...
irq event stamp: 5711
hardirqs last  enabled at (5911): [<c01c6c54>] 
console_flush_one_record+0x424/0x570
hardirqs last disabled at (5943): [<c013ce4c>] handle_softirqs+0x53c/0x5c0
softirqs last  enabled at (5944): [<c013cc3c>] handle_softirqs+0x32c/0x5c0
softirqs last disabled at (6157): [<c013d07c>] __irq_exit_rcu+0x144/0x1f0
---[ end trace 0000000000000000 ]---
Quoted 24 lines
---
  drivers/net/phy/mdio_bus.c | 11 +++--------
  1 file changed, 3 insertions(+), 8 deletions(-)
drivers/net/phy/mdio_bus.c +2 -6
index 48c0447e6a8..b32a369cd25 100644
@@ -358,22 +358,17 @@ EXPORT_SYMBOL(of_mdio_find_bus);
 
  static void mdiobus_stats_acct(struct mdio_bus_stats *stats, bool op, int ret)
  {
-	preempt_disable();
  	u64_stats_update_begin(&stats->syncp);
 
  	u64_stats_inc(&stats->transfers);
-	if (ret < 0) {
+	if (ret < 0)
  		u64_stats_inc(&stats->errors);
-		goto out;
-	}
-
-	if (op)
+	else if (op)

drivers/net/phy/mdio_bus.c EXPORT_SYMBOL(of_mdio_find_bus); · line 374

Quoted 10 lines
drivers/net/phy/mdio_bus.c +1 -2
  		u64_stats_inc(&stats->reads);
  	else
  		u64_stats_inc(&stats->writes);
-out:
+
  	u64_stats_update_end(&stats->syncp);
-	preempt_enable();
  }
 
  /**

Best regards

Signature · 2 lines
Marek Szyprowski, PhD
Samsung R&D Institute Poland
author maintainer
#10 lore raw

Re: [PATCH net-next 8/8] net: phy: improve mdiobus_stats_acct

Quoted 5 lines · Marek Szyprowski
Quoted 4 lines · Heiner Kallweit

- Remove duplicated preempt disable. Disabling preemption has been added to functions like u64_stats_update_begin() in the meantime.
- Simplify branch structure

Quoted 7 lines
Quoted 1 line

This patch has been merged to yesterday's linux-next as commit 1afccc5a201e ("net: phy: improve mdiobus_stats_acct"). In my tests I found that it introduces the following warning on 32bit machines with USB ethernet adapters, so the preempt disable was there for a good reason:

Thanks for the report. Indeed, on non-PREEMPT_RT systems it's still needed. I'll send a revert.

#11 lore raw
In reply to Heiner Kallweit
This series was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:

Hello:

This series was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:

Quoted 14 lines · On Fri, 27 Feb 2026 23:04:20 +0100 you wrote:

Improve stats handling in mdio_bus.c.

Heiner Kallweit (8):
net: mdio: extend struct mdio_bus_stat_attr instead of using
dev_ext_attribute
net: mdio: use macro __ATTR to simplify the code
net: phy: consider that mdio_bus_device_stat_field_show doesn't use
member address
net: phy: avoid extra casting in mdio_bus_get_stat
net: mdio: constify attributes and attribute arrays
net: mdio: use macro __ATTRIBUTE_GROUPS
net: phy: inline helper mdio_bus_get_global_stat
net: phy: improve mdiobus_stats_acct

Quoted 1 line

[...]

Here is the summary with links:
- [net-next,1/8] net: mdio: extend struct mdio_bus_stat_attr instead of using dev_ext_attribute

    https://git.kernel.org/netdev/net-next/c/5c494f404a3f
  - [net-next,2/8] net: mdio: use macro __ATTR to simplify the code
    https://git.kernel.org/netdev/net-next/c/807d8addc3ec
  - [net-next,3/8] net: phy: consider that mdio_bus_device_stat_field_show doesn't use member address
    https://git.kernel.org/netdev/net-next/c/8068acaff125
  - [net-next,4/8] net: phy: avoid extra casting in mdio_bus_get_stat
    https://git.kernel.org/netdev/net-next/c/c599649d05a0
  - [net-next,5/8] net: mdio: constify attributes and attribute arrays
    https://git.kernel.org/netdev/net-next/c/a4c08b701559
  - [net-next,6/8] net: mdio: use macro __ATTRIBUTE_GROUPS
    https://git.kernel.org/netdev/net-next/c/8e0bdf30be75
  - [net-next,7/8] net: phy: inline helper mdio_bus_get_global_stat
    https://git.kernel.org/netdev/net-next/c/7f97ca5f9858
  - [net-next,8/8] net: phy: improve mdiobus_stats_acct
    https://git.kernel.org/netdev/net-next/c/1afccc5a201e

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html