-
Notifications
You must be signed in to change notification settings - Fork 4
/
block-comment-for-block-and-drivers-for-linux-5.2-rc2.patch
499 lines (482 loc) · 19.8 KB
/
block-comment-for-block-and-drivers-for-linux-5.2-rc2.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
From 2ee25ad0c663b2b0cb090154ab1dff4f42f6febd Mon Sep 17 00:00:00 2001
From: Dongli Zhang <[email protected]>
Date: Wed, 29 May 2019 16:23:28 +0800
Subject: [PATCH 1/1] block comment for block and drivers for linux-5.2-rc2
Signed-off-by: Dongli Zhang <[email protected]>
---
block/blk-mq.c | 87 ++++++++++++++++++++++++++++++++++++++++++++++
block/genhd.c | 11 ++++++
drivers/scsi/hosts.c | 4 +++
drivers/scsi/scsi_scan.c | 83 +++++++++++++++++++++++++++++++++++++++++++
drivers/scsi/scsi_sysfs.c | 16 +++++++++
drivers/scsi/sd.c | 48 +++++++++++++++++++++++++
include/linux/cpuhotplug.h | 19 ++++++++++
kernel/cpu.c | 13 +++++++
8 files changed, 281 insertions(+)
diff --git a/block/blk-mq.c b/block/blk-mq.c
index 32b8ad3..c1fba75 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -42,6 +42,11 @@
static void blk_mq_poll_stats_start(struct request_queue *q);
static void blk_mq_poll_stats_fn(struct blk_stat_callback *cb);
+/*
+ * used by:
+ * - block/blk-mq.c|2862| <<blk_mq_init_allocated_queue>> blk_mq_poll_stats_bkt,
+ * - block/blk-mq.c|3388| <<blk_mq_poll_nsecs>> bucket = blk_mq_poll_stats_bkt(rq);
+ */
static int blk_mq_poll_stats_bkt(const struct request *rq)
{
int ddir, bytes, bucket;
@@ -3330,6 +3335,10 @@ static bool blk_poll_stats_enable(struct request_queue *q)
return false;
}
+/*
+ * called by only:
+ * - block/blk-mq.c|541| <<__blk_mq_end_request>> blk_mq_poll_stats_start(rq->q);
+ */
static void blk_mq_poll_stats_start(struct request_queue *q)
{
/*
@@ -3343,6 +3352,10 @@ static void blk_mq_poll_stats_start(struct request_queue *q)
blk_stat_activate_msecs(q->poll_cb, 100);
}
+/*
+ * used by only:
+ * - block/blk-mq.c|2861| <<blk_mq_init_allocated_queue>> q->poll_cb = blk_stat_alloc_callback(blk_mq_poll_stats_fn,
+ */
static void blk_mq_poll_stats_fn(struct blk_stat_callback *cb)
{
struct request_queue *q = cb->data;
@@ -3539,8 +3552,82 @@ unsigned int blk_mq_rq_cpu(struct request *rq)
}
EXPORT_SYMBOL(blk_mq_rq_cpu);
+/*
+ * 假设为cpuhp_setup_state_multi()的startup添加了blk_mq_hctx_notify_prepare()
+ *
+ * # echo 1 > /sys/devices/system/cpu/cpu2/online
+ *
+ * [ 122.079907] blk_mq_hctx_notify_dead nr_hw_queues=1, cpu=2, queue_num=0
+ * [ 122.080691] blk_mq_hctx_notify_dead nr_hw_queues=1, cpu=2, queue_num=0
+ * [ 122.081429] blk_mq_hctx_notify_dead nr_hw_queues=4, cpu=2, queue_num=3 -> nvme queue 3
+ * [ 122.082158] blk_mq_hctx_notify_dead nr_hw_queues=4, cpu=2, queue_num=2 -> nvme queue 2
+ * [ 122.082919] blk_mq_hctx_notify_dead nr_hw_queues=4, cpu=2, queue_num=1 -> nvme queue 1
+ * [ 122.083680] blk_mq_hctx_notify_dead nr_hw_queues=4, cpu=2, queue_num=0 -> nvme queue 0
+ * [ 122.084443] blk_mq_hctx_notify_dead nr_hw_queues=1, cpu=2, queue_num=0
+ * [ 122.085167] blk_mq_hctx_notify_dead nr_hw_queues=1, cpu=2, queue_num=0
+ * [ 122.085925] blk_mq_hctx_notify_dead nr_hw_queues=1, cpu=2, queue_num=0
+ * [ 122.086694] blk_mq_hctx_notify_dead nr_hw_queues=1, cpu=2, queue_num=0
+ * [ 122.087458] blk_mq_hctx_notify_dead nr_hw_queues=1, cpu=2, queue_num=0
+ * [ 122.088181] blk_mq_hctx_notify_dead nr_hw_queues=1, cpu=2, queue_num=0
+ * [ 122.088938] blk_mq_hctx_notify_dead nr_hw_queues=1, cpu=2, queue_num=0
+ * [ 122.089653] blk_mq_hctx_notify_dead nr_hw_queues=1, cpu=2, queue_num=0
+ * [ 122.090400] blk_mq_hctx_notify_dead nr_hw_queues=1, cpu=2, queue_num=0
+ *
+ * # echo 0 > /sys/devices/system/cpu/cpu2/online
+ *
+ * [ 250.582328] blk_mq_hctx_notify_prepare nr_hw_queues=1, cpu=2, queue_num=0
+ * [ 250.583122] blk_mq_hctx_notify_prepare nr_hw_queues=1, cpu=2, queue_num=0
+ * [ 250.583943] blk_mq_hctx_notify_prepare nr_hw_queues=4, cpu=2, queue_num=3 -> nvme queue 3
+ * [ 250.584760] blk_mq_hctx_notify_prepare nr_hw_queues=4, cpu=2, queue_num=2 -> nvme queue 2
+ * [ 250.585547] blk_mq_hctx_notify_prepare nr_hw_queues=4, cpu=2, queue_num=1 -> nvme queue 1
+ * [ 250.586364] blk_mq_hctx_notify_prepare nr_hw_queues=4, cpu=2, queue_num=0 -> nvme queue 0
+ * [ 250.587114] blk_mq_hctx_notify_prepare nr_hw_queues=1, cpu=2, queue_num=0
+ * [ 250.588158] blk_mq_hctx_notify_prepare nr_hw_queues=1, cpu=2, queue_num=0
+ * [ 250.589193] blk_mq_hctx_notify_prepare nr_hw_queues=1, cpu=2, queue_num=0
+ * [ 250.590144] blk_mq_hctx_notify_prepare nr_hw_queues=1, cpu=2, queue_num=0
+ * [ 250.590757] blk_mq_hctx_notify_prepare nr_hw_queues=1, cpu=2, queue_num=0
+ * [ 250.591372] blk_mq_hctx_notify_prepare nr_hw_queues=1, cpu=2, queue_num=0
+ * [ 250.591963] blk_mq_hctx_notify_prepare nr_hw_queues=1, cpu=2, queue_num=0
+ * [ 250.592574] blk_mq_hctx_notify_prepare nr_hw_queues=1, cpu=2, queue_num=0
+ * [ 250.593163] blk_mq_hctx_notify_prepare nr_hw_queues=1, cpu=2, queue_num=0
+ *
+ * 上面目前是把cpu和每个hctx queue都过一遍
+ *
+ *
+ * [0] blk_mq_hctx_notify_dead
+ * [0] cpuhp_invoke_callback
+ * [0] _cpu_down
+ * [0] do_cpu_down
+ * [0] device_offline
+ * [0] online_store
+ * [0] kernfs_fop_write
+ * [0] vfs_write
+ * [0] ksys_write
+ * [0] do_syscall_64
+ * [0] entry_SYSCALL_64_after_hwframe
+ *
+ * [0] blk_mq_hctx_notify_prepare
+ * [0] cpuhp_invoke_callback
+ * [0] _cpu_up
+ * [0] do_cpu_up
+ * [0] cpu_subsys_online
+ * [0] device_online
+ * [0] online_store
+ * [0] kernfs_fop_write
+ * [0] vfs_write
+ * [0] ksys_write
+ * [0] do_syscall_64
+ * [0] entry_SYSCALL_64_after_hwframe
+ */
+
static int __init blk_mq_init(void)
{
+ /*
+ * CPUHP_BLK_MQ_DEAD在以下使用:
+ * - block/blk-mq.c|2254| <<blk_mq_remove_cpuhp>> cpuhp_state_remove_instance_nocalls(CPUHP_BLK_MQ_DEAD,
+ * - block/blk-mq.c|2313| <<blk_mq_init_hctx>> cpuhp_state_add_instance_nocalls(CPUHP_BLK_MQ_DEAD, &hctx->cpuhp_dead);
+ * - block/blk-mq.c|3544| <<blk_mq_init>> cpuhp_setup_state_multi(CPUHP_BLK_MQ_DEAD, "block/mq:dead", NULL,
+ */
cpuhp_setup_state_multi(CPUHP_BLK_MQ_DEAD, "block/mq:dead", NULL,
blk_mq_hctx_notify_dead);
return 0;
diff --git a/block/genhd.c b/block/genhd.c
index ad68266..060fae3 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -747,6 +747,17 @@ static void __device_add_disk(struct device *parent, struct gendisk *disk,
blk_integrity_add(disk);
}
+/*
+ * virtio_scsi添加sda和sdb(lun=0和lun=1)的例子:
+ *
+ * [0] device_add_disk
+ * [0] sd_probe_async
+ * [0] async_run_entry_fn
+ * [0] process_one_work
+ * [0] worker_thread
+ * [0] kthread
+ * [0] ret_from_fork
+ */
void device_add_disk(struct device *parent, struct gendisk *disk,
const struct attribute_group **groups)
diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
index ff0d8c6..6dd3970 100644
--- a/drivers/scsi/hosts.c
+++ b/drivers/scsi/hosts.c
@@ -365,6 +365,10 @@ static struct device_type scsi_host_type = {
* Return value:
* Pointer to a new Scsi_Host
**/
+/*
+ * 被很多调用, 一个例子是:
+ * - drivers/scsi/virtio_scsi.c|797| <<virtscsi_probe>> shost = scsi_host_alloc(&virtscsi_host_template,
+ */
struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
{
struct Scsi_Host *shost;
diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
index 058079f..e3eb481 100644
--- a/drivers/scsi/scsi_scan.c
+++ b/drivers/scsi/scsi_scan.c
@@ -761,6 +761,31 @@ static int scsi_probe_lun(struct scsi_device *sdev, unsigned char *inq_result,
* SCSI_SCAN_NO_RESPONSE: could not allocate or setup a scsi_device
* SCSI_SCAN_LUN_PRESENT: a new scsi_device was allocated and initialized
**/
+/*
+ * [0] scsi_add_lun
+ * [0] scsi_probe_and_add_lun
+ * [0] __scsi_scan_target
+ * [0] scsi_scan_channel
+ * [0] scsi_scan_host_selected
+ * [0] scsi_scan_host
+ * [0] virtscsi_probe
+ * [0] virtio_dev_probe
+ * [0] really_probe
+ * [0] driver_probe_device
+ * [0] device_driver_attach
+ * [0] __driver_attach
+ * [0] bus_for_each_dev
+ * [0] bus_add_driver
+ * [0] driver_register
+ * [0] init
+ * [0] do_one_initcall
+ * [0] kernel_init_freeable
+ * [0] kernel_init
+ * [0] ret_from_fork
+ *
+ * called by:
+ * - drivers/scsi/scsi_scan.c|1157| <<scsi_probe_and_add_lun>> res = scsi_add_lun(sdev, result, &bflags, shost->async_scan);
+ */
static int scsi_add_lun(struct scsi_device *sdev, unsigned char *inq_result,
blist_flags_t *bflags, int async)
{
@@ -987,6 +1012,10 @@ static int scsi_add_lun(struct scsi_device *sdev, unsigned char *inq_result,
* register it and tell the rest of the kernel
* about it.
*/
+ /*
+ * scsi_sysfs_add_sdev()是重要的函数
+ * 会调用device_add()
+ */
if (!async && scsi_sysfs_add_sdev(sdev) != 0)
return SCSI_SCAN_NO_RESPONSE;
@@ -1040,6 +1069,14 @@ static unsigned char *scsi_inq_str(unsigned char *buf, unsigned char *inq,
* attached at the LUN
* - SCSI_SCAN_LUN_PRESENT: a new scsi_device was allocated and initialized
**/
+/*
+ * called by:
+ * - drivers/scsi/scsi_scan.c|1263| <<scsi_sequential_lun_scan>> if ((scsi_probe_and_add_lun(starget, lun, NULL, NULL, rescan,
+ * - drivers/scsi/scsi_scan.c|1433| <<scsi_report_lun_scan>> res = scsi_probe_and_add_lun(starget,
+ * - drivers/scsi/scsi_scan.c|1480| <<__scsi_add_device>> scsi_probe_and_add_lun(starget, lun, NULL, &sdev, 1, hostdata);
+ * - drivers/scsi/scsi_scan.c|1554| <<__scsi_scan_target>> scsi_probe_and_add_lun(starget, lun, NULL, NULL, rescan, NULL);
+ * - drivers/scsi/scsi_scan.c|1562| <<__scsi_scan_target>> res = scsi_probe_and_add_lun(starget, 0, &bflags, NULL, rescan, NULL);
+ */
static int scsi_probe_and_add_lun(struct scsi_target *starget,
u64 lun, blist_flags_t *bflagsp,
struct scsi_device **sdevp,
@@ -1194,6 +1231,10 @@ static int scsi_probe_and_add_lun(struct scsi_target *starget,
*
* Modifies sdevscan->lun.
**/
+/*
+ * called only by:
+ * - drivers/scsi/scsi_scan.c|1569| <<__scsi_scan_target>> scsi_sequential_lun_scan(starget, bflags,
+ */
static void scsi_sequential_lun_scan(struct scsi_target *starget,
blist_flags_t bflags, int scsi_level,
enum scsi_scan_mode rescan)
@@ -1528,6 +1569,12 @@ void scsi_rescan_device(struct device *dev)
}
EXPORT_SYMBOL(scsi_rescan_device);
+/*
+ * called by:
+ * - drivers/scsi/scsi_scan.c|1619| <<scsi_scan_target>> __scsi_scan_target(parent, channel, id, lun, rescan);
+ * - drivers/scsi/scsi_scan.c|1650| <<scsi_scan_channel>> __scsi_scan_target(&shost->shost_gendev, channel,
+ * - drivers/scsi/scsi_scan.c|1654| <<scsi_scan_channel>> __scsi_scan_target(&shost->shost_gendev, channel,
+ */
static void __scsi_scan_target(struct device *parent, unsigned int channel,
unsigned int id, u64 lun, enum scsi_scan_mode rescan)
{
@@ -1623,6 +1670,11 @@ void scsi_scan_target(struct device *parent, unsigned int channel,
}
EXPORT_SYMBOL(scsi_scan_target);
+/*
+ * called by:
+ * - drivers/scsi/scsi_scan.c|1679| <<scsi_scan_host_selected>> scsi_scan_channel(shost, channel, id, lun,
+ * - drivers/scsi/scsi_scan.c|1682| <<scsi_scan_host_selected>> scsi_scan_channel(shost, channel, id, lun, rescan);
+ */
static void scsi_scan_channel(struct Scsi_Host *shost, unsigned int channel,
unsigned int id, u64 lun,
enum scsi_scan_mode rescan)
@@ -1655,6 +1707,29 @@ static void scsi_scan_channel(struct Scsi_Host *shost, unsigned int channel,
id, lun, rescan);
}
+/*
+ * called by:
+ * - drivers/scsi/scsi_proc.c|255| <<scsi_add_single_device>> error = scsi_scan_host_selected(shost, channel, id, lun,
+ * - drivers/scsi/scsi_scan.c|1817| <<do_scsi_scan_host>> scsi_scan_host_selected(shost, SCAN_WILD_CARD, SCAN_WILD_CARD,
+ * - drivers/scsi/scsi_sysfs.c|150| <<scsi_scan>> res = scsi_scan_host_selected(shost, channel, id, lun,
+ *
+ * [0] scsi_scan_host_selected
+ * [0] scsi_scan_host
+ * [0] virtscsi_probe
+ * [0] virtio_dev_probe
+ * [0] really_probe
+ * [0] driver_probe_device
+ * [0] device_driver_attach
+ * [0] __driver_attach
+ * [0] bus_for_each_dev
+ * [0] bus_add_driver
+ * [0] driver_register
+ * [0] init
+ * [0] do_one_initcall
+ * [0] kernel_init_freeable
+ * [0] kernel_init
+ * [0] ret_from_fork
+ */
int scsi_scan_host_selected(struct Scsi_Host *shost, unsigned int channel,
unsigned int id, u64 lun,
enum scsi_scan_mode rescan)
@@ -1804,8 +1879,16 @@ static void scsi_finish_async_scan(struct async_scan_data *data)
kfree(data);
}
+/*
+ * called by:
+ * - drivers/scsi/scsi_scan.c|1827| <<do_scan_async>> do_scsi_scan_host(shost);
+ * - drivers/scsi/scsi_scan.c|1847| <<scsi_scan_host>> do_scsi_scan_host(shost);
+ */
static void do_scsi_scan_host(struct Scsi_Host *shost)
{
+ /*
+ * 似乎virtio没有scan_finished
+ */
if (shost->hostt->scan_finished) {
unsigned long start = jiffies;
if (shost->hostt->scan_start)
diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index dbb206c..d14b075 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -522,6 +522,17 @@ static int scsi_bus_uevent(struct device *dev, struct kobj_uevent_env *env)
return 0;
}
+/*
+ * used by:
+ * - drivers/scsi/hosts.c|471| <<scsi_host_alloc>> shost->shost_gendev.bus = &scsi_bus_type;
+ * - drivers/scsi/scsi_proc.c|382| <<next_scsi_device>> struct device *next = bus_find_device(&scsi_bus_type, start, NULL,
+ * - drivers/scsi/scsi_scan.c|432| <<scsi_alloc_target>> dev->bus = &scsi_bus_type;
+ * - drivers/scsi/scsi_sysfs.c|539| <<scsi_sysfs_register>> error = bus_register(&scsi_bus_type);
+ * - drivers/scsi/scsi_sysfs.c|543| <<scsi_sysfs_register>> bus_unregister(&scsi_bus_type);
+ * - drivers/scsi/scsi_sysfs.c|552| <<scsi_sysfs_unregister>> bus_unregister(&scsi_bus_type);
+ * - drivers/scsi/scsi_sysfs.c|1513| <<scsi_register_driver>> drv->bus = &scsi_bus_type;
+ * - drivers/scsi/scsi_sysfs.c|1563| <<scsi_sysfs_device_initialize>> sdev->sdev_gendev.bus = &scsi_bus_type;
+ */
struct bus_type scsi_bus_type = {
.name = "scsi",
.match = scsi_bus_match,
@@ -1280,6 +1291,11 @@ static int scsi_target_add(struct scsi_target *starget)
* Return value:
* 0 on Success / non-zero on Failure
**/
+/*
+ * called by:
+ * - drivers/scsi/scsi_scan.c|990| <<scsi_add_lun>> if (!async && scsi_sysfs_add_sdev(sdev) != 0)
+ * - drivers/scsi/scsi_scan.c|1701| <<scsi_sysfs_add_devices>> scsi_sysfs_add_sdev(sdev) != 0)
+ */
int scsi_sysfs_add_sdev(struct scsi_device *sdev)
{
int error, i;
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index a3406bd..74424f9 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -563,7 +563,14 @@ static const struct dev_pm_ops sd_pm_ops = {
.runtime_resume = sd_resume,
};
+/*
+ * used by:
+ * - drivers/scsi/sd.c|3381| <<sd_probe>> sdkp->driver = &sd_template;
+ * - drivers/scsi/sd.c|3677| <<init_sd>> err = scsi_register_driver(&sd_template.gendrv);
+ * - drivers/scsi/sd.c|3711| <<exit_sd>> scsi_unregister_driver(&sd_template.gendrv);
+ */
static struct scsi_driver sd_template = {
+ /* gendrv是struct device_driver */
.gendrv = {
.name = "sd",
.owner = THIS_MODULE,
@@ -1941,6 +1948,9 @@ static unsigned int sd_completed_bytes(struct scsi_cmnd *scmd)
*
* Note: potentially run from within an ISR. Must not block.
**/
+/*
+ * struct scsi_driver sd_template.done = sd_done()
+ */
static int sd_done(struct scsi_cmnd *SCpnt)
{
int result = SCpnt->result;
@@ -3255,6 +3265,17 @@ static int sd_format_disk_name(char *prefix, int index, char *buf, int buflen)
/*
* The asynchronous part of sd_probe
*/
+/*
+ * virtio_scsi添加sda和sdb(lun=0和lun=1)的例子:
+ *
+ * [0] device_add_disk
+ * [0] sd_probe_async
+ * [0] async_run_entry_fn
+ * [0] process_one_work
+ * [0] worker_thread
+ * [0] kthread
+ * [0] ret_from_fork
+ */
static void sd_probe_async(void *data, async_cookie_t cookie)
{
struct scsi_disk *sdkp = data;
@@ -3333,6 +3354,33 @@ static void sd_probe_async(void *data, async_cookie_t cookie)
* Assume sd_probe is not re-entrant (for time being)
* Also think about sd_probe() and sd_remove() running coincidentally.
**/
+/*
+ * virtio_scsi上sda和sdb(lun=0和lun=1)的例子
+ *
+ * [0] sd_probe
+ * [0] really_probe
+ * [0] driver_probe_device
+ * [0] device_driver_attach
+ * [0] __driver_attach
+ * [0] bus_for_each_dev
+ * [0] bus_add_driver
+ * [0] driver_register
+ * [0] init_sd
+ * [0] do_one_initcall
+ * [0] kernel_init_freeable
+ * [0] kernel_init
+ * [0] ret_from_fork
+ *
+ * virtio_scsi添加sda和sdb(lun=0和lun=1)的例子:
+ *
+ * [0] device_add_disk
+ * [0] sd_probe_async
+ * [0] async_run_entry_fn
+ * [0] process_one_work
+ * [0] worker_thread
+ * [0] kthread
+ * [0] ret_from_fork
+ */
static int sd_probe(struct device *dev)
{
struct scsi_device *sdp = to_scsi_device(dev);
diff --git a/include/linux/cpuhotplug.h b/include/linux/cpuhotplug.h
index 6a38159..c710c9f 100644
--- a/include/linux/cpuhotplug.h
+++ b/include/linux/cpuhotplug.h
@@ -47,6 +47,12 @@ enum cpuhp_state {
CPUHP_BLOCK_SOFTIRQ_DEAD,
CPUHP_ACPI_CPUDRV_DEAD,
CPUHP_S390_PFAULT_DEAD,
+ /*
+ * used by:
+ * - block/blk-mq.c|2254| <<blk_mq_remove_cpuhp>> cpuhp_state_remove_instance_nocalls(CPUHP_BLK_MQ_DEAD,
+ * - block/blk-mq.c|2313| <<blk_mq_init_hctx>> cpuhp_state_add_instance_nocalls(CPUHP_BLK_MQ_DEAD, &hctx->cpuhp_dead);
+ * - block/blk-mq.c|3544| <<blk_mq_init>> cpuhp_setup_state_multi(CPUHP_BLK_MQ_DEAD, "block/mq:dead", NULL,
+ */
CPUHP_BLK_MQ_DEAD,
CPUHP_FS_BUFF_DEAD,
CPUHP_PRINTK_DEAD,
@@ -302,6 +308,19 @@ static inline int cpuhp_state_add_instance(enum cpuhp_state state,
* Installs the instance for the @state The @state must have been earlier
* marked as multi-instance by @cpuhp_setup_state_multi.
*/
+/*
+ * called by:
+ * - arch/arm/mach-imx/mmdc.c|518| <<imx_mmdc_perf_init>> cpuhp_state_add_instance_nocalls(cpuhp_mmdc_state, &pmu_mmdc->node);
+ * - block/blk-mq.c|2313| <<blk_mq_init_hctx>> cpuhp_state_add_instance_nocalls(CPUHP_BLK_MQ_DEAD, &hctx->cpuhp_dead);
+ * - drivers/net/ethernet/marvell/mvneta.c|3841| <<mvneta_open>> ret = cpuhp_state_add_instance_nocalls(online_hpstate,
+ * - drivers/net/ethernet/marvell/mvneta.c|3846| <<mvneta_open>> ret = cpuhp_state_add_instance_nocalls(CPUHP_NET_MVNETA_DEAD,
+ * - drivers/net/ethernet/marvell/mvneta.c|4828| <<mvneta_resume>> cpuhp_state_add_instance_nocalls(online_hpstate,
+ * - drivers/net/ethernet/marvell/mvneta.c|4830| <<mvneta_resume>> cpuhp_state_add_instance_nocalls(CPUHP_NET_MVNETA_DEAD,
+ * - drivers/net/virtio_net.c|2000| <<virtnet_cpu_notif_add>> ret = cpuhp_state_add_instance_nocalls(virtionet_online, &vi->node);
+ * - drivers/net/virtio_net.c|2003| <<virtnet_cpu_notif_add>> ret = cpuhp_state_add_instance_nocalls(CPUHP_VIRT_NET_DEAD,
+ * - drivers/perf/arm-ccn.c|1313| <<arm_ccn_pmu_init>> cpuhp_state_add_instance_nocalls(CPUHP_AP_PERF_ARM_CCN_ONLINE,
+ * - drivers/perf/arm_smmuv3_pmu.c|786| <<smmu_pmu_probe>> err = cpuhp_state_add_instance_nocalls(cpuhp_state_num,
+ */
static inline int cpuhp_state_add_instance_nocalls(enum cpuhp_state state,
struct hlist_node *node)
{
diff --git a/kernel/cpu.c b/kernel/cpu.c
index f2ef104..8d31e98 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -126,6 +126,19 @@ struct cpuhp_step {
static DEFINE_MUTEX(cpuhp_state_mutex);
static struct cpuhp_step cpuhp_hp_states[];
+/*
+ * called by:
+ * - kernel/cpu.c|149| <<cpuhp_invoke_callback>> struct cpuhp_step *step = cpuhp_get_step(state);
+ * - kernel/cpu.c|1578| <<cpuhp_store_callbacks>> sp = cpuhp_get_step(state);
+ * - kernel/cpu.c|1592| <<cpuhp_get_teardown_cb>> return cpuhp_get_step(state)->teardown.single;
+ * - kernel/cpu.c|1602| <<cpuhp_issue_call>> struct cpuhp_step *sp = cpuhp_get_step(state);
+ * - kernel/cpu.c|1662| <<__cpuhp_state_add_instance_cpuslocked>> sp = cpuhp_get_step(state);
+ * - kernel/cpu.c|1804| <<__cpuhp_state_remove_instance>> struct cpuhp_step *sp = cpuhp_get_step(state);
+ * - kernel/cpu.c|1851| <<__cpuhp_remove_state_cpuslocked>> struct cpuhp_step *sp = cpuhp_get_step(state);
+ * - kernel/cpu.c|1930| <<write_cpuhp_target>> sp = cpuhp_get_step(target);
+ * - kernel/cpu.c|1977| <<write_cpuhp_fail>> sp = cpuhp_get_step(fail);
+ * - kernel/cpu.c|2020| <<show_cpuhp_states>> struct cpuhp_step *sp = cpuhp_get_step(i);
+ */
static struct cpuhp_step *cpuhp_get_step(enum cpuhp_state state)
{
return cpuhp_hp_states + state;
--
2.7.4