Skip to content

Commit 1f5000b

Browse files
toddpoynorgregkh
authored andcommitted
initcall_debug: add deferred probe times
initcall_debug attributes all deferred device probe retries for the late_initcall level to function deferred_probe_initcall. Add logs of the individual device probe routines called, to identify which drivers are executing for how long during the initcall path. Deferred probes that occur after initcall processing are not shown. Example log messages added: [ 0.505119] deferred probe my-sound-device @ 6 [ 0.517656] deferred probe my-sound-device returned after 1227 usecs Signed-off-by: Todd Poynor <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 1af824f commit 1f5000b

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

drivers/base/dd.c

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <linux/device.h>
2121
#include <linux/delay.h>
2222
#include <linux/dma-mapping.h>
23+
#include <linux/init.h>
2324
#include <linux/module.h>
2425
#include <linux/kthread.h>
2526
#include <linux/wait.h>
@@ -53,6 +54,7 @@ static DEFINE_MUTEX(deferred_probe_mutex);
5354
static LIST_HEAD(deferred_probe_pending_list);
5455
static LIST_HEAD(deferred_probe_active_list);
5556
static atomic_t deferred_trigger_count = ATOMIC_INIT(0);
57+
static bool initcalls_done;
5658

5759
/*
5860
* In some cases, like suspend to RAM or hibernation, It might be reasonable
@@ -61,6 +63,26 @@ static atomic_t deferred_trigger_count = ATOMIC_INIT(0);
6163
*/
6264
static bool defer_all_probes;
6365

66+
/*
67+
* For initcall_debug, show the deferred probes executed in late_initcall
68+
* processing.
69+
*/
70+
static void deferred_probe_debug(struct device *dev)
71+
{
72+
ktime_t calltime, delta, rettime;
73+
unsigned long long duration;
74+
75+
printk(KERN_DEBUG "deferred probe %s @ %i\n", dev_name(dev),
76+
task_pid_nr(current));
77+
calltime = ktime_get();
78+
bus_probe_device(dev);
79+
rettime = ktime_get();
80+
delta = ktime_sub(rettime, calltime);
81+
duration = (unsigned long long) ktime_to_ns(delta) >> 10;
82+
printk(KERN_DEBUG "deferred probe %s returned after %lld usecs\n",
83+
dev_name(dev), duration);
84+
}
85+
6486
/*
6587
* deferred_probe_work_func() - Retry probing devices in the active list.
6688
*/
@@ -106,7 +128,10 @@ static void deferred_probe_work_func(struct work_struct *work)
106128
device_pm_unlock();
107129

108130
dev_dbg(dev, "Retrying from deferred list\n");
109-
bus_probe_device(dev);
131+
if (initcall_debug && !initcalls_done)
132+
deferred_probe_debug(dev);
133+
else
134+
bus_probe_device(dev);
110135

111136
mutex_lock(&deferred_probe_mutex);
112137

@@ -215,6 +240,7 @@ static int deferred_probe_initcall(void)
215240
driver_deferred_probe_trigger();
216241
/* Sort as many dependencies as possible before exiting initcalls */
217242
flush_work(&deferred_probe_work);
243+
initcalls_done = true;
218244
return 0;
219245
}
220246
late_initcall(deferred_probe_initcall);

0 commit comments

Comments
 (0)