thunderbolt: add tracefs support to tb_* logging helpers
Subsystems (2)
PATCH 1/2 thunderbolt: add tracefs support to tb_* logging helpers
Thunderbolt tracing is a lightweight alternative to traditional thunderbolt debug logging. While thunderbolt debug logging is quite convenient when reproducing a specific issue, it doesn't help when something goes wrong unexpectedly. There are a couple of reasons why one does not want to enable thunderbolt debug logging at all times:
1. We don't want to overwhelm kernel log with thunderbolt spam, others want to use it too
2. Console logging is slow
Thunderbolt tracing aims to solve both these problems. Use of the thunderbolt tracefs instance allows to enable thunderbolt logging in production without impacting performance or spamming the system logs.
To use thunderbolt tracing, set the thunderbolt.trace module parameter (via cmdline or sysfs) to true:
::
eg: echo true > /sys/module/thunderbolt/parameters/trace
Once active, all log messages will be written to the thunderbolt trace. Once at capacity, the trace will overwrite old messages with new ones. At any point, one can read the trace file to extract the previous thunderbolt messages:
::
eg: cat /sys/kernel/tracing/instances/thunderbolt/trace
The thunderbolt trace instance is subsystem wide, so if you have multiple devices active, they will be adding logs to the same trace.
--- drivers/thunderbolt/nhi.c | 81 +++++++++++++++++++++++++++++++++++++++ drivers/thunderbolt/tb.h | 60 ++++++++++++++++++++++++++--- 2 files changed, 136 insertions(+), 5 deletions(-)
drivers/thunderbolt/nhi.c +81 -0
@@ -20,6 +20,7 @@#include <linux/delay.h> #include <linux/property.h> #include <linux/string_helpers.h> +#include <linux/trace.h> #include "nhi.h" #include "nhi_regs.h"
@@ -50,6 +51,19 @@ static bool host_reset = true;module_param (host_reset, bool,0444 );MODULE_PARM_DESC (host_reset,"reset USBv2 host router (default: true)" ); +#ifdef CONFIG_TRACING +/* +* __tb_debug_trace - enable debug logs to the thunderbolt tracefs instance +*/ +bool __tb_debug_trace; +EXPORT_SYMBOL (__tb_debug_trace); + +MODULE_PARM_DESC (trace,"enable debug logs to the thunderbolt tracefs instance (default: false) (bool)" ); +module_param_named (trace, __tb_debug_trace, bool,0600 ); + +static struct trace_array *trace_arr; +#endif +static int ring_interrupt_index (const struct tb_ring *ring) {int bit = ring->hop;
@@ -1539,6 +1553,71 @@ static struct pci_driver nhi_driver = { .driver.pm = &nhi_pm_ops, }; +#ifdef CONFIG_TRACING + +/** +* tb_trace_init - initializes the thunderbolt trace array +* +* This function fetches (or creates) the thunderbolt trace array. +* This should be called once on thunderbolt subsystem creation +* and matched with tb_trace_cleanup(). +*/ +void tb_trace_init (void ) +{ +int ret; + + trace_arr =trace_array_get_by_name ("thunderbolt" ); +if (!trace_arr) +return ; + + ret =trace_array_init_printk (trace_arr); +if (ret) +tb_trace_cleanup (); +} + +/** +* tb_trace_printf - adds an entry to the thunderbolt tracefs instance +* @format: printf format of the message to add to the trace +* +* This function adds a new entry in the thunderbolt tracefs instance +*/ +void tb_trace_printf (const struct device *dev,const char *format, ...) +{ +struct va_format vaf; +va_list args; + +va_start (args, format); + vaf.fmt = format; + vaf.va = &args; + +if (dev) +trace_array_printk (trace_arr, _THIS_IP_,"%s %s: %pV" , +dev_driver_string (dev),dev_name (dev), + &vaf); +else +trace_array_printk (trace_arr, _THIS_IP_, +"(NULL device *): %pV" , &vaf); +va_end (args); +} + +/** +* tb_trace_cleanup - destroys the thunderbolt trace array +* +* This function destroys the thunderbolt trace array created +* with tb_trace_init. This should be called once on thunderbolt +* subsystem close and matched with tb_trace_init(). +*/ +void tb_trace_cleanup (void ) +{ +if (trace_arr) { +trace_array_put (trace_arr); +trace_array_destroy (trace_arr); + trace_arr =NULL ; + } +} + +#endif +static int __init nhi_init (void ) {int ret;
@@ -1549,11 +1628,13 @@ static int __init nhi_init(void) ret =pci_register_driver (&nhi_driver);if (ret)tb_domain_exit (); +tb_trace_init ();return ret; } static void __exit nhi_unload(void) { +tb_trace_cleanup ();pci_unregister_driver (&nhi_driver);tb_domain_exit (); }
drivers/thunderbolt/tb.h +55 -5
72 lines not on this page · raw message
Signature · 1 line
2.41.0.487.g6d72f3e995-goog
PATCH 2/2 thunderbolt: add tracefs support to dev_* logging helpers
Add wrappers for dev_* logging functions used in thunderbolt module in order to be able to dynamically enable/disable logging of messages to the thunderbolt tracefs instance.
--- drivers/thunderbolt/acpi.c | 10 +-- drivers/thunderbolt/ctl.c | 9 +-- drivers/thunderbolt/icm.c | 14 ++--- drivers/thunderbolt/nhi.c | 72 +++++++++++----------- drivers/thunderbolt/nvm.c | 2 +- drivers/thunderbolt/retimer.c | 12 ++-- drivers/thunderbolt/switch.c | 24 ++++---- drivers/thunderbolt/tb.c | 8 +-- drivers/thunderbolt/tb.h | 25 +++++--- drivers/thunderbolt/usb4_port.c | 2 +- drivers/thunderbolt/xdomain.c | 106 ++++++++++++++++---------------- 11 files changed, 147 insertions(+), 137 deletions(-)
drivers/thunderbolt/acpi.c +5 -5
@@ -82,11 +82,11 @@ static acpi_status tb_acpi_add_link(acpi_handle handle, u32 level, void *data,DL_FLAG_RPM_ACTIVE | DL_FLAG_PM_RUNTIME);if (link) { -dev_dbg (&nhi->pdev->dev,"created link from %s\n" , -dev_name (&pdev->dev)); +tb_dev_dbg (&nhi->pdev->dev,"created link from %s\n" , +dev_name (&pdev->dev)); }else { -dev_warn (&nhi->pdev->dev,"device link creation from %s failed\n" , -dev_name (&pdev->dev)); +tb_dev_warn (&nhi->pdev->dev,"device link creation from %s failed\n" , +dev_name (&pdev->dev)); }pm_runtime_put (&pdev->dev);
@@ -119,7 +119,7 @@ void tb_acpi_add_links(struct tb_nhi *nhi) status =acpi_walk_namespace (ACPI_TYPE_DEVICE ,ACPI_ROOT_OBJECT ,32 , tb_acpi_add_link,NULL , nhi,NULL );if (ACPI_FAILURE (status)) -dev_warn (&nhi->pdev->dev,"failed to enumerate tunneled ports\n" ); +tb_dev_warn (&nhi->pdev->dev,"failed to enumerate tunneled ports\n" ); }/**
drivers/thunderbolt/ctl.c +5 -4
@@ -14,6 +14,7 @@#include <linux/workqueue.h> #include "ctl.h" +#include "tb.h" #define TB_CTL_RX_PKG_COUNT 10
@@ -54,16 +55,16 @@ struct tb_ctl { dev_WARN(&(ctl)->nhi->pdev->dev, format, ## arg) #define tb_ctl_err(ctl, format, arg...) \ - dev_err(&(ctl)->nhi->pdev->dev, format, ## arg) + tb_dev_err(&(ctl)->nhi->pdev->dev, format, ## arg) #define tb_ctl_warn(ctl, format, arg...) \ - dev_warn(&(ctl)->nhi->pdev->dev, format, ## arg) + tb_dev_warn(&(ctl)->nhi->pdev->dev, format, ## arg) #define tb_ctl_info(ctl, format, arg...) \ - dev_info(&(ctl)->nhi->pdev->dev, format, ## arg) + tb_dev_info(&(ctl)->nhi->pdev->dev, format, ## arg) #define tb_ctl_dbg(ctl, format, arg...) \ - dev_dbg(&(ctl)->nhi->pdev->dev, format, ## arg) + tb_dev_dbg(&(ctl)->nhi->pdev->dev, format, ## arg) static DECLARE_WAIT_QUEUE_HEAD(tb_cfg_request_cancel_queue); /* Serializes access to request kref_get/put */
drivers/thunderbolt/icm.c +7 -7
@@ -1477,7 +1477,7 @@ static int icm_ar_get_mode(struct tb *tb) }while (--retries);if (!retries) { -dev_err (&nhi->pdev->dev,"ICM firmware not authenticated\n" ); +tb_dev_err (&nhi->pdev->dev,"ICM firmware not authenticated\n" );return -ENODEV ; }
@@ -1819,7 +1819,7 @@ static int icm_firmware_start(struct tb *tb, struct tb_nhi *nhi)if (icm_firmware_running (nhi))return 0 ; -dev_dbg (&nhi->pdev->dev,"starting ICM firmware\n" ); +tb_dev_dbg (&nhi->pdev->dev,"starting ICM firmware\n" ); ret =icm_firmware_reset (tb, nhi);if (ret)
@@ -1914,7 +1914,7 @@ static int icm_firmware_init(struct tb *tb) ret =icm_firmware_start (tb, nhi);if (ret) { -dev_err (&nhi->pdev->dev,"could not start ICM firmware\n" ); +tb_dev_err (&nhi->pdev->dev,"could not start ICM firmware\n" );return ret; }
@@ -1946,10 +1946,10 @@ static int icm_firmware_init(struct tb *tb)*/ ret =icm_reset_phy_port (tb,0 );if (ret) -dev_warn (&nhi->pdev->dev,"failed to reset links on port0\n" ); +tb_dev_warn (&nhi->pdev->dev,"failed to reset links on port0\n" ); ret =icm_reset_phy_port (tb,1 );if (ret) -dev_warn (&nhi->pdev->dev,"failed to reset links on port1\n" ); +tb_dev_warn (&nhi->pdev->dev,"failed to reset links on port1\n" );return 0 ; }
@@ -2128,7 +2128,7 @@ static int icm_runtime_resume_switch(struct tb_switch *sw)if (tb_route (sw)) {if (!wait_for_completion_timeout (&sw->rpm_complete,msecs_to_jiffies (500 ))) { -dev_dbg (&sw->dev,"runtime resuming timed out\n" ); +tb_dev_dbg (&sw->dev,"runtime resuming timed out\n" ); } }return 0 ;
@@ -2544,7 +2544,7 @@ struct tb *icm_probe(struct tb_nhi *nhi) }if (!icm->is_supported || !icm->is_supported (tb)) { -dev_dbg (&nhi->pdev->dev,"ICM not supported on this controller\n" ); +tb_dev_dbg (&nhi->pdev->dev,"ICM not supported on this controller\n" );tb_domain_put (tb);return NULL ; }
drivers/thunderbolt/nhi.c +36 -36
187 lines not on this page · raw message
drivers/thunderbolt/nvm.c +1 -1
@@ -318,7 +318,7 @@ struct tb_nvm *tb_nvm_alloc(struct device *dev) }if (!vops) { -dev_dbg (dev,"retimer NVM format of vendor %#x unknown\n" , +tb_dev_dbg (dev,"retimer NVM format of vendor %#x unknown\n" , rt->vendor);return ERR_PTR (-EOPNOTSUPP ); }
drivers/thunderbolt/retimer.c +6 -6
@@ -97,7 +97,7 @@ static int tb_retimer_nvm_add(struct tb_retimer *rt)return 0 ; err_nvm: -dev_dbg (&rt->dev,"NVM upgrade disabled\n" ); +tb_dev_dbg (&rt->dev,"NVM upgrade disabled\n" );if (!IS_ERR (nvm))tb_nvm_free (nvm);
@@ -410,20 +410,20 @@ static int tb_retimer_add(struct tb_port *port, u8 index, u32 auth_status) ret =device_register (&rt->dev);if (ret) { -dev_err (&rt->dev,"failed to register retimer: %d\n" , ret); +tb_dev_err (&rt->dev,"failed to register retimer: %d\n" , ret);put_device (&rt->dev);return ret; } ret =tb_retimer_nvm_add (rt);if (ret) { -dev_err (&rt->dev,"failed to add NVM devices: %d\n" , ret); +tb_dev_err (&rt->dev,"failed to add NVM devices: %d\n" , ret);device_unregister (&rt->dev);return ret; } -dev_info (&rt->dev,"new retimer found, vendor=%#x device=%#x\n" , - rt->vendor, rt->device); +tb_dev_info (&rt->dev,"new retimer found, vendor=%#x device=%#x\n" , + rt->vendor, rt->device);pm_runtime_no_callbacks (&rt->dev);pm_runtime_set_active (&rt->dev);
@@ -437,7 +437,7 @@ static int tb_retimer_add(struct tb_port *port, u8 index, u32 auth_status)static void tb_retimer_remove (struct tb_retimer *rt) { -dev_info (&rt->dev,"retimer disconnected\n" ); +tb_dev_info (&rt->dev,"retimer disconnected\n" );tb_nvm_free (rt->nvm);device_unregister (&rt->dev); }
drivers/thunderbolt/switch.c +12 -12
@@ -2912,7 +2912,7 @@ int tb_switch_add(struct tb_switch *sw)*/ ret =tb_switch_add_dma_port (sw);if (ret) { -dev_err (&sw->dev,"failed to add DMA port\n" ); +tb_dev_err (&sw->dev,"failed to add DMA port\n" );return ret; }
@@ -2922,12 +2922,12 @@ int tb_switch_add(struct tb_switch *sw)/* read drom */ ret =tb_drom_read (sw);if (ret) -dev_warn (&sw->dev,"reading DROM failed: %d\n" , ret); +tb_dev_warn (&sw->dev,"reading DROM failed: %d\n" , ret);tb_sw_dbg (sw,"uid: %#llx\n" , sw->uid); ret =tb_switch_set_uuid (sw);if (ret) { -dev_err (&sw->dev,"failed to set UUID\n" ); +tb_dev_err (&sw->dev,"failed to set UUID\n" );return ret; }
@@ -2938,7 +2938,7 @@ int tb_switch_add(struct tb_switch *sw) } ret =tb_init_port (&sw->ports[i]);if (ret) { -dev_err (&sw->dev,"failed to initialize port %d\n" , i); +tb_dev_err (&sw->dev,"failed to initialize port %d\n" , i);return ret; } }
@@ -2966,27 +2966,27 @@ int tb_switch_add(struct tb_switch *sw) ret =device_add (&sw->dev);if (ret) { -dev_err (&sw->dev,"failed to add device: %d\n" , ret); +tb_dev_err (&sw->dev,"failed to add device: %d\n" , ret);return ret; }if (tb_route (sw)) { -dev_info (&sw->dev,"new device found, vendor=%#x device=%#x\n" , - sw->vendor, sw->device); +tb_dev_info (&sw->dev,"new device found, vendor=%#x device=%#x\n" , + sw->vendor, sw->device);if (sw->vendor_name && sw->device_name) -dev_info (&sw->dev,"%s %s\n" , sw->vendor_name, - sw->device_name); +tb_dev_info (&sw->dev,"%s %s\n" , sw->vendor_name, + sw->device_name); } ret =usb4_switch_add_ports (sw);if (ret) { -dev_err (&sw->dev,"failed to add USB4 ports\n" ); +tb_dev_err (&sw->dev,"failed to add USB4 ports\n" ); goto err_del; } ret =tb_switch_nvm_add (sw);if (ret) { -dev_err (&sw->dev,"failed to add NVM devices\n" ); +tb_dev_err (&sw->dev,"failed to add NVM devices\n" ); goto err_ports; }
@@ -3057,7 +3057,7 @@ void tb_switch_remove(struct tb_switch *sw)usb4_switch_remove_ports (sw);if (tb_route (sw)) -dev_info (&sw->dev,"device disconnected\n" ); +tb_dev_info (&sw->dev,"device disconnected\n" );device_unregister (&sw->dev); }
drivers/thunderbolt/tb.c +4 -4
@@ -2413,11 +2413,11 @@ static void tb_apple_add_links(struct tb_nhi *nhi)DL_FLAG_AUTOREMOVE_SUPPLIER | DL_FLAG_PM_RUNTIME);if (link) { -dev_dbg (&nhi->pdev->dev,"created link from %s\n" , -dev_name (&pdev->dev)); +tb_dev_dbg (&nhi->pdev->dev,"created link from %s\n" , +dev_name (&pdev->dev)); }else { -dev_warn (&nhi->pdev->dev,"device link creation from %s failed\n" , -dev_name (&pdev->dev)); +tb_dev_warn (&nhi->pdev->dev,"device link creation from %s failed\n" , +dev_name (&pdev->dev)); } } }
drivers/thunderbolt/tb.h +17 -8
@@ -720,26 +720,35 @@ static inline bool tb_dbg_trace_enabled(void) }#endif -#define __LOG_TRACE_PRINT(log_func, tb, fmt, arg...) \ +#define __LOG_TRACE_PRINT(log_func, dev, fmt, arg...) \ do { \ - const struct device *dev = &(tb)->nhi->pdev->dev; \ - \ log_func(dev, fmt, ## arg); \ \ if (tb_dbg_trace_enabled()) \ tb_trace_printf(dev, fmt, ## arg); \ } while (0) +#define tb_to_dev (tb) (&(tb)->nhi->pdev->dev) + +#define tb_dev_err(dev, fmt, arg...) \ + __LOG_TRACE_PRINT(dev_err, dev, fmt, ## arg) +#define tb_dev_warn(dev, fmt, arg...) \ + __LOG_TRACE_PRINT(dev_warn, dev, fmt, ## arg) +#define tb_dev_info(dev, fmt, arg...) \ + __LOG_TRACE_PRINT(dev_info, dev, fmt, ## arg) +#define tb_dev_dbg(dev, fmt, arg...) \ + __LOG_TRACE_PRINT(dev_dbg, dev, fmt, ## arg) + #define tb_err(tb, fmt, arg...) \ - __LOG_TRACE_PRINT(dev_err, tb, fmt, ## arg) + __LOG_TRACE_PRINT(dev_err, tb_to_dev(tb), fmt, ## arg) #define tb_WARN(tb, fmt, arg...) \ - dev_WARN(&(tb)->nhi->pdev->dev, fmt, ## arg) + dev_WARN(tb_to_dev(tb), fmt, ## arg) #define tb_warn(tb, fmt, arg...) \ - __LOG_TRACE_PRINT(dev_warn, tb, fmt, ## arg) + __LOG_TRACE_PRINT(dev_warn, tb_to_dev(tb), fmt, ## arg) #define tb_info(tb, fmt, arg...) \ - __LOG_TRACE_PRINT(dev_info, tb, fmt, ## arg) + __LOG_TRACE_PRINT(dev_info, tb_to_dev(tb), fmt, ## arg) #define tb_dbg(tb, fmt, arg...) \ - __LOG_TRACE_PRINT(dev_dbg, tb, fmt, ## arg) + __LOG_TRACE_PRINT(dev_dbg, tb_to_dev(tb), fmt, ## arg) #define __TB_SW_PRINT(level, sw, fmt, arg...) \ do { \
drivers/thunderbolt/usb4_port.c +1 -1
@@ -279,7 +279,7 @@ struct usb4_port *usb4_port_device_add(struct tb_port *port)if (dev_fwnode (&usb4->dev)) { ret =component_add (&usb4->dev, &connector_ops);if (ret) { -dev_err (&usb4->dev,"failed to add component\n" ); +tb_dev_err (&usb4->dev,"failed to add component\n" );device_unregister (&usb4->dev); } }
drivers/thunderbolt/xdomain.c +53 -53
301 lines not on this page · raw message
Signature · 1 line
2.41.0.487.g6d72f3e995-goog
Greg KH
maintainerQuoted 8 lines · Łukasz Bartosik
Thunderbolt tracing is a lightweight alternative to traditional thunderbolt debug logging. While thunderbolt debug logging is quite convenient when reproducing a specific issue, it doesn't help when something goes wrong unexpectedly. There are a couple of reasons why one does not want to enable thunderbolt debug logging at all times:
1. We don't want to overwhelm kernel log with thunderbolt spam, others want to use it too
But doesn't the dynamic debug infrastructure allow this today?
Quoted 1 line
2. Console logging is slow
Slow how?
Quoted 9 lines
Thunderbolt tracing aims to solve both these problems. Use of the thunderbolt tracefs instance allows to enable thunderbolt logging in production without impacting performance or spamming the system logs.
To use thunderbolt tracing, set the thunderbolt.trace module parameter (via cmdline or sysfs) to true:
::
eg: echo true >/sys/module/thunderbolt/parameters/trace
Why yet-another module parameter? Why is this required?
Quoted 9 lines
Once active, all log messages will be written to the thunderbolt trace. Once at capacity, the trace will overwrite old messages with new ones. At any point, one can read the trace file to extract the previous thunderbolt messages:
::
eg: cat/sys/kernel/tracing/instances/thunderbolt/traceThe thunderbolt trace instance is subsystem wide, so if you have multiple devices active, they will be adding logs to the same trace.
This just uses the existing logging functionality and ties it into the trace functionality, right?
If so, why not do this for all printk messages, why should this be unique to thunderbolt?
Normally with tracing, you enable specific tracepoints that you add, not just "all dev_*() messages", are you sure this will actually help?
thanks,
greg k-h
czw., 27 lip 2023 o 16:47 Greg KH <[email protected]> napisał(a):
Quoted 8 lines · Łukasz Bartosik
Quoted 6 lines
Thunderbolt tracing is a lightweight alternative to traditional thunderbolt debug logging. While thunderbolt debug logging is quite convenient when reproducing a specific issue, it doesn't help when something goes wrong unexpectedly. There are a couple of reasons why one does not want to enable thunderbolt debug logging at all times:
Quoted 5 lines
Quoted 2 lines
1. We don't want to overwhelm kernel log with thunderbolt spam, others want to use it too
But doesn't the dynamic debug infrastructure allow this today?
Dynamic debug allows only partially what we would like to achieve.
Our goal is to be able to gather thunderbolt debug logs from ChromeOS end users when an issue happens. Especially that would be very useful for us in case of issues which reproduction is difficult. We would write thunderbolt debug logs to a separate wrap around buffer provided by trace subsystem. When an issue happens and a user sends a feedback then thunderbolt logs would be attached to the feedback providing more insight into what happened.
Dynamic debug sends all debug messages to dmesg and with significant number of dynamic dev_dbg prints enabled dmesg may be quickly overwritten and other important logs lost. Also enabling dynamic debug for the entire kernel might
not be appropriate for production kernels due to impact on kernel size and perf.
Quoted 4 lines
Quoted 1 line
2. Console logging is slow
Slow how?
I meant slow compared to writing messages to trace array instance in memory.
Quoted 5 lines
Quoted 5 lines
Thunderbolt tracing aims to solve both these problems. Use of the thunderbolt tracefs instance allows to enable thunderbolt logging in production without impacting performance or spamming the system logs.
Quoted 7 lines
Quoted 4 lines
To use thunderbolt tracing, set the thunderbolt.trace module parameter (via cmdline or sysfs) to true:
::
eg: echo true >/sys/module/thunderbolt/parameters/traceWhy yet-another module parameter? Why is this required?
This is to enable/disable write of thunderbolt debug logs to thunderbolt trace array instance.
Quoted 7 lines
Quoted 7 lines
Once active, all log messages will be written to the thunderbolt trace. Once at capacity, the trace will overwrite old messages with new ones. At any point, one can read the trace file to extract the previous thunderbolt messages:
::
eg: cat/sys/kernel/tracing/instances/thunderbolt/trace
Quoted 6 lines
Quoted 2 lines
The thunderbolt trace instance is subsystem wide, so if you have multiple devices active, they will be adding logs to the same trace.
This just uses the existing logging functionality and ties it into the trace functionality, right?
Yes, it writes log messages (including debug level) to memory buffer provided by trace framework.
Quoted 3 lines
If so, why not do this for all printk messages, why should this be unique to thunderbolt?
I agree it would be better to come up with a general solution that can be used by any part/subsystem of a kernel. I think it makes sense for me to look more into dynamic debug and see how it could be extended to cover our use case.
Quoted 3 lines
Normally with tracing, you enable specific tracepoints that you add, not just "all dev_*() messages", are you sure this will actually help?
Yes, it would be helpful, here is an example snippet from logs captured into thunderbolt trace array instance:
<...>-177 [000] ..... 217.635100: tb_trace_printf: thunderbolt
0000:00:0d.3: 0: resuming switch
<...>-177 [000] ..... 217.635101: tb_trace_printf: thunderbolt
0000:00:0d.3: restoring Switch at 0x0 (depth: 0, up port: 7)
<...>-177 [000] ..... 217.635400: tb_trace_printf: thunderbolt
0000:00:0d.3: 0:1: USB4 wake: no, connection wake: no, disconnection
wake: yes
Thanks,
Lukasz
Quoted 3 lines
thanks,
greg k-h
Greg KH
maintainerQuoted 17 lines · Łukasz Bartosik
czw., 27 lip 2023 o 16:47 Greg KH <[email protected]> napisał(a):
Quoted 8 lines · Łukasz Bartosik
Quoted 6 lines
Thunderbolt tracing is a lightweight alternative to traditional thunderbolt debug logging. While thunderbolt debug logging is quite convenient when reproducing a specific issue, it doesn't help when something goes wrong unexpectedly. There are a couple of reasons why one does not want to enable thunderbolt debug logging at all times:
Quoted 5 lines
Quoted 2 lines
1. We don't want to overwhelm kernel log with thunderbolt spam, others want to use it too
But doesn't the dynamic debug infrastructure allow this today?
Dynamic debug allows only partially what we would like to achieve.
Quoted 7 lines
Our goal is to be able to gather thunderbolt debug logs from ChromeOS end users when an issue happens. Especially that would be very useful for us in case of issues which reproduction is difficult. We would write thunderbolt debug logs to a separate wrap around buffer provided by trace subsystem. When an issue happens and a user sends a feedback then thunderbolt logs would be attached to the feedback providing more insight into what happened.
The problem is, you don't want 100 different debug log formats and tools for the 100 different driver subsystems.
That is why we unified everything on the dev_* format, and the tracing tools. Use them, don't create something new.
Quoted 5 lines
Dynamic debug sends all debug messages to dmesg and with significant number of dynamic
dev_dbgprints enabled dmesg may be quickly overwritten and other important logs lost. Also enabling dynamic debug for the entire kernel might
not be appropriate for production kernels due to impact on kernel size and perf.
If you look at the typec code, they have their own type of ring-buffer for logging things. Perhaps look at making that more generic like what you need here as well, and adding that to the tracing core for everyone to use and unify with?
I don't want one-off solutions like this, sorry, that way lies madness, madness that we used to have before we unified everything. Let's learn from our past mistakes and not make them again please.
thanks,
greg k-h
pt., 28 lip 2023 o 17:32 Greg KH <[email protected]> napisał(a):
Quoted 39 lines · Łukasz Bartosik
Quoted 17 lines
czw., 27 lip 2023 o 16:47 Greg KH <[email protected]> napisał(a):
Quoted 8 lines · Łukasz Bartosik
Quoted 6 lines
Thunderbolt tracing is a lightweight alternative to traditional thunderbolt debug logging. While thunderbolt debug logging is quite convenient when reproducing a specific issue, it doesn't help when something goes wrong unexpectedly. There are a couple of reasons why one does not want to enable thunderbolt debug logging at all times:
Quoted 5 lines
Quoted 2 lines
1. We don't want to overwhelm kernel log with thunderbolt spam, others want to use it too
But doesn't the dynamic debug infrastructure allow this today?
Dynamic debug allows only partially what we would like to achieve.
Quoted 7 lines
Our goal is to be able to gather thunderbolt debug logs from ChromeOS end users when an issue happens. Especially that would be very useful for us in case of issues which reproduction is difficult. We would write thunderbolt debug logs to a separate wrap around buffer provided by trace subsystem. When an issue happens and a user sends a feedback then thunderbolt logs would be attached to the feedback providing more insight into what happened.
The problem is, you don't want 100 different debug log formats and tools for the 100 different driver subsystems.
That is why we unified everything on the dev_* format, and the tracing tools. Use them, don't create something new.
Quoted 5 lines
Dynamic debug sends all debug messages to dmesg and with significant number of dynamic
dev_dbgprints enabled dmesg may be quickly overwritten and other important logs lost. Also enabling dynamic debug for the entire kernel might
not be appropriate for production kernels due to impact on kernel size and perf.
Quoted 5 lines
If you look at the typec code, they have their own type of ring-buffer for logging things. Perhaps look at making that more generic like what you need here as well, and adding that to the tracing core for everyone to use and unify with?
Thanks for the comments and pointing me to the typec code for the reference.
Lukasz
Quoted 7 lines
I don't want one-off solutions like this, sorry, that way lies madness, madness that we used to have before we unified everything. Let's learn from our past mistakes and not make them again please.
thanks,
greg k-h