Skip to contentSkip to conversation

driver core: avoid repeatedly printing the same 'Fixed dependency' log

PATCH In review Xu Yang 2 participants 3 messages May 9 – May 25

Subsystems (2)
lore
Share & tools
lore

Xu Yang

author
#0 lore raw

PATCH 1/1 driver core: avoid repeatedly printing the same 'Fixed dependency' log

The "Fixed dependency cycle(s) with ..." log is printed for each cycle finding process. In particular, the same cycle may be parsed many times during the proxy link setup. For example, if /soc/bus@4c000000/usb@4c100000 is a devicetree structure and node usb@4c100000 is in a cycle, then for each device registration (soc, 4c000000.bus and 4c100000.usb), fw_devlink_create_devlink() will find the same cycle and print a log. The repeat logs are redundant and may cause confusion for the user. Move the pr_debug() to __fwnode_link_cycle() and avoid printing the log if it has already been printed.

---
 drivers/base/core.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/base/core.c +6 -2
index d49420e066de..af0371d4ed83 100644
@@ -127,7 +127,13 @@ static void __fwnode_link_cycle(struct fwnode_link *link)
 {
 	pr_debug("%pfwf: cycle: depends on %pfwf\n",
 		 link->consumer, link->supplier);
+
+	if (link->flags & FWLINK_FLAG_CYCLE)
+		return;
+
 	link->flags |= FWLINK_FLAG_CYCLE;
+	pr_info("%pfwf: Fixed dependency cycle(s) with %pfwf\n",
+		link->consumer, link->supplier);
 }
 
 /**
@@ -2140,8 +2146,6 @@ static int fw_devlink_create_devlink(struct device *con,
 	if (__fw_devlink_relax_cycles(link->consumer, sup_handle)) {
 		__fwnode_link_cycle(link);
 		pr_debug("----- cycle: end -----\n");
-		pr_info("%pfwf: Fixed dependency cycle(s) with %pfwf\n",
-			link->consumer, sup_handle);
 	}
 	device_links_write_unlock();
 
Signature · 1 line
2.34.1
#1 lore raw
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] Moving `pr_info()` into `__fwnode_link_cycle()` causes log spam and highly misleading dependency…

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Moving pr_info() into __fwnode_link_cycle() causes log spam and highly misleading dependency cycle logs during initial cycle detection. --

commit b7864d7a5daadca2b750e1e3f78ba9cec6f247d5
Author: Xu Yang <[email protected]>

driver core: avoid repeatedly printing the same 'Fixed dependency' log

This commit attempts to deduplicate "Fixed dependency cycle" logs by moving the print statement into __fwnode_link_cycle() and gating it behind the FWLINK_FLAG_CYCLE flag check.

Quoted 5 lines
drivers/base/core.c +0 -0
@@ -127,7 +127,13 @@ static void __fwnode_link_cycle(struct fwnode_link *link)
 {

drivers/base/core.c static void __fwnode_link_cycle(struct fwnode_link *link) · line 137

Quoted 10 lines
drivers/base/core.c +6 -0
 	pr_debug("%pfwf: cycle: depends on %pfwf\n",
 		 link->consumer, link->supplier);
+
+	if (link->flags & FWLINK_FLAG_CYCLE)
+		return;
+
 	link->flags |= FWLINK_FLAG_CYCLE;
+	pr_info("%pfwf: Fixed dependency cycle(s) with %pfwf\n",
+		link->consumer, link->supplier);
 }

When moving this pr_info() into __fwnode_link_cycle(), does this cause the log to be printed for every intermediate edge in the cycle?

__fw_devlink_relax_cycles() unwinds the recursion and calls __fwnode_link_cycle() for each link involved in the cycle:

__fw_devlink_relax_cycles() {
	...
	list_for_each_entry(link, &sup_handle->suppliers, c_hook) {
		if (link->flags & FWLINK_FLAG_IGNORE)
			continue;

		if (__fw_devlink_relax_cycles(con_handle, link->supplier)) {
			__fwnode_link_cycle(link);
			ret = true;
		}
	}
	...
}

Because of this recursive unwinding, won't this change print the "Fixed dependency cycle(s)" message for every node involved in a newly detected cycle, rather than just the specific link that closed it?

Could this lead to more confusing log spam by flagging older, valid dependencies as the source of the cycle?

[ ... ]

Quoted 7 lines
drivers/base/core.c +0 -2
@@ -2140,8 +2146,6 @@ static int fw_devlink_create_devlink(struct device *con,
 	if (__fw_devlink_relax_cycles(link->consumer, sup_handle)) {
 		__fwnode_link_cycle(link);
 		pr_debug("----- cycle: end -----\n");
-		pr_info("%pfwf: Fixed dependency cycle(s) with %pfwf\n",
-			link->consumer, sup_handle);
 	}
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
author
#2 lore raw
In reply to Xu Yang

Hi Saravana,

Quoted 9 lines · Xu Yang

The "Fixed dependency cycle(s) with ..." log is printed for each cycle finding process. In particular, the same cycle may be parsed many times during the proxy link setup. For example, if /soc/bus@4c000000/usb@4c100000 is a devicetree structure and node usb@4c100000 is in a cycle, then for each device registration (soc, 4c000000.bus and 4c100000.usb), fw_devlink_create_devlink() will find the same cycle and print a log. The repeat logs are redundant and may cause confusion for the user. Move the pr_debug() to __fwnode_link_cycle() and avoid printing the log if it has already been printed.

Could the logging be improved here?

Thanks,
Xu Yang

Quoted 36 lines
---
 drivers/base/core.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/base/core.c +6 -2
index d49420e066de..af0371d4ed83 100644
@@ -127,7 +127,13 @@ static void __fwnode_link_cycle(struct fwnode_link *link)
 {
 	pr_debug("%pfwf: cycle: depends on %pfwf\n",
 		 link->consumer, link->supplier);
+
+	if (link->flags & FWLINK_FLAG_CYCLE)
+		return;
+
 	link->flags |= FWLINK_FLAG_CYCLE;
+	pr_info("%pfwf: Fixed dependency cycle(s) with %pfwf\n",
+		link->consumer, link->supplier);
 }
 
 /**
@@ -2140,8 +2146,6 @@ static int fw_devlink_create_devlink(struct device *con,
 	if (__fw_devlink_relax_cycles(link->consumer, sup_handle)) {
 		__fwnode_link_cycle(link);
 		pr_debug("----- cycle: end -----\n");
-		pr_info("%pfwf: Fixed dependency cycle(s) with %pfwf\n",
-			link->consumer, sup_handle);
 	}
 	device_links_write_unlock();
 
Signature · 1 line
2.34.1