自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

看Linux內核前輩解Bug你會有什么感想

系統(tǒng) Linux
正是只憑借這些debug信息,準確分析問題所在,才能體現(xiàn)出對block子系統(tǒng)的專業(yè)性,坐穩(wěn)在這個子系統(tǒng)中的地位。如此熟練掌握一個子系統(tǒng),真不易!

[[355896]]

本文轉載自微信公眾號「相遇Linux」,作者JeffXie。轉載本文請聯(lián)系相遇Linux公眾號。

一名叫John Garry的人給Linux內核社區(qū)上報了一個bug, 說有人升級內核到V5.10-rcX之后,執(zhí)行dd和sync之后看到進程有hang住的情況:

 

  1. Some guys internally upgraded to v5.10-rcX and start to see a hang after  
  2. dd + sync for a large file: 
  3. - mount /dev/sda1 (ext4 filesystem) to directory /mnt; 
  4. - run "if=/dev/zero of=test1 bs=1M count=2000" on directory /mnt; 
  5. - run "sync" 

系統(tǒng)提示打印hang住進程的堆棧信息:

 

  1. and get: 
  2.  
  3. [  367.912761] INFO: task jbd2/sdb1-8:3602 blocked for more than 120 
  4. seconds. 
  5. [  367.919618]       Not tainted 5.10.0-rc1-109488-g32ded76956b6 #948 
  6. [  367.925776] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" 
  7. disables this message. 
  8. [  367.933579] task:jbd2/sdb1-8     state:D stack:    0 pid: 3602 
  9. ppid:     2 flags:0x00000028 
  10. [  367.941901] Call trace: 
  11. [  367.944351] __switch_to+0xb8/0x168 
  12. [  367.947840] __schedule+0x30c/0x670 
  13. [  367.951326] schedule+0x70/0x108 
  14. [  367.954550] io_schedule+0x1c/0xe8 
  15. [  367.957948] bit_wait_io+0x18/0x68 
  16. [  367.961346] __wait_on_bit+0x78/0xf0 
  17. [  367.964919] out_of_line_wait_on_bit+0x8c/0xb0 
  18. [  367.969356] __wait_on_buffer+0x30/0x40 
  19. [  367.973188] jbd2_journal_commit_transaction+0x1370/0x1958 
  20. [  367.978661] kjournald2+0xcc/0x260 
  21. [  367.982061] kthread+0x150/0x158 
  22. [  367.985288] ret_from_fork+0x10/0x34 
  23. [  367.988860] INFO: task sync:3823 blocked for more than 120 seconds. 
  24. [  367.995102]       Not tainted 5.10.0-rc1-109488-g32ded76956b6 #948 
  25. [  368.001265] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" 
  26. disables this message. 
  27. [  368.009067] task:sync            state:D stack:    0 pid: 3823 ppid: 
  28. 3450 flags:0x00000009 
  29. [  368.017397] Call trace: 
  30. [  368.019841] __switch_to+0xb8/0x168 
  31. [  368.023320] __schedule+0x30c/0x670 
  32. [  368.026804] schedule+0x70/0x108 
  33. [  368.030025] jbd2_log_wait_commit+0xbc/0x158 
  34. [  368.034290] ext4_sync_fs+0x188/0x1c8 
  35. [  368.037947] sync_fs_one_sb+0x30/0x40 
  36. [  368.041606] iterate_supers+0x9c/0x138 
  37. [  368.045350] ksys_sync+0x64/0xc0 
  38. [  368.048569] __arm64_sys_sync+0x10/0x20 
  39. [  368.052398] el0_svc_common.constprop.3+0x68/0x170 
  40. [  368.057177] do_el0_svc+0x24/0x90 
  41. [  368.060482] el0_sync_handler+0x118/0x168 
  42. [  368.064478]  el0_sync+0x158/0x180 

并反饋8號硬隊列綁定的第100號cpu上派發(fā)隊列和完成隊列不一致,但是沒有inflight的情況,因為這個情況,苦惱了三天三夜,頭發(fā)掉滿了整個鍵盤。

 

  1. estuary:/sys/kernel/debug/block/sda/hctx8$ cat cpu100/dispatched 
  2. 3 0 
  3. estuary:/sys/kernel/debug/block/sda/hctx8$ cat cpu100/completed 
  4. 2 0 
  5. On cpu100, it seems completed is less than number dispatched. 
  6. /sys/devices/pci0000:74/0000:74:02.0/host0/port-0:0/end_device-0:0/target0:0:0/0:0:0:0/block/sda/sda1/inflight),  
  7. the number of inflight is 0. 

然后Ming Lei (自帶音響出場)給出意見,需要收集/sys/kernel/debug/block/sda 目錄和/sys/block/sda/device 目錄下所有文件的輸出:

 

  1. hello chenxiang, Can you collect the debugfs log via the following commands after the io 
  2. hang is triggered? 
  3.  
  4. 1) debugfs log: 
  5.  
  6.         (cd /sys/kernel/debug/block/sda && find . -type f -exec grep -aH . {} \;) 
  7.  
  8. 2) scsi sysfs info: 
  9.  
  10.         (cd /sys/block/sda/device && find . -type f -exec grep -aH . {} \;) 
  11.  
  12. Suppose the disk is /dev/sda. 

chenxiang 反饋:

 

  1. ~$ cd /sys/kernel/debug/block/sdb && find . -type f -exec grep  
  2. -aH . {} \; 
  3. ... 
  4. ./hctx9/tags:cleared=3891 
  5. ./hctx9/tags:bits_per_word=64 
  6. ./hctx9/tags:map_nr=63 
  7. ./hctx9/tags:alloc_hint={3264, 3265, 0, 3731, 2462, 842, 0, 0, 1278, 27,  
  8. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2424, 0, 0, 0,  
  9. 346, 3, 3191, 235, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,  
  10. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 88, 0, 0, 285, 0, 0, 0, 0, 0, 0, 0, 0, 0,  
  11. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1165, 538, 0,  
  12. 372, 277, 3476, 0, 0, 0, 111, 0, 2081, 0, 112, 0, 0, 0, 0, 904, 1127, 0,  
  13. 0, 0, 113, 0, 0, 0, 0, 0, 0, 321, 0} 
  14. ./hctx9/tags:wake_batch=8 
  15. ./hctx9/tags:wake_index=7 
  16. ./hctx9/tags:ws_active=0 
  17. ./hctx9/tags:ws={ 
  18. ./hctx9/tags:   {.wait_cnt=8, .wait=inactive}, 
  19. ./hctx9/tags:   {.wait_cnt=8, .wait=inactive}, 
  20. ./hctx9/tags:   {.wait_cnt=8, .wait=inactive}, 
  21. ./hctx9/tags:   {.wait_cnt=8, .wait=inactive}, 
  22. ./hctx9/tags:   {.wait_cnt=8, .wait=inactive}, 
  23. ./hctx9/tags:   {.wait_cnt=8, .wait=inactive}, 
  24. ./hctx9/tags:   {.wait_cnt=8, .wait=inactive}, 
  25. ./hctx9/tags:   {.wait_cnt=8, .wait=inactive}, 
  26. ./hctx9/tags:} 
  27. ./hctx9/tags:round_robin=1 
  28. ./hctx9/tags:min_shallow_depth=4294967295 
  29. ./hctx9/ctx_map:00000000: 00 
  30. ... 

Ming Lei 大神看了一下debug輸出,小喝一杯大紅袍,就直接建議去測試這個patch:

 

  1. Please try the following patch: 
  2.  
  3. diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c 
  4. index 60c7a7d74852..03c6d0620bfd 100644 
  5. --- a/drivers/scsi/scsi_lib.c 
  6. +++ b/drivers/scsi/scsi_lib.c 
  7. @@ -1703,8 +1703,7 @@ static blk_status_t scsi_queue_rq(struct blk_mq_hw_ctx *hctx, 
  8.          break; 
  9.      case BLK_STS_RESOURCE: 
  10.      case BLK_STS_ZONE_RESOURCE: 
  11. -        if (atomic_read(&sdev->device_busy) || 
  12. -            scsi_device_blocked(sdev)) 
  13. +        if (scsi_device_blocked(sdev)) 
  14.              ret = BLK_STS_DEV_RESOURCE; 
  15.          break; 
  16.      default

chenxiang 測試反饋之后,問題解決,內心洋溢著Linux從業(yè)者單純的喜悅,眼神中流露出滿滿的崇敬之情,恨不得以身相許:

 

  1. I have tested the patch  100+ times on two envirments(on which the issue  
  2. occurs frequently before), and 
  3. the issue doesn't occur. 

這樣問題就解決了,我想如果是小編處理這個問題,我會要他觸發(fā)一下crash,然后再慢慢分析,真是low了幾百個 levels :)

正是只憑借這些debug信息,準確分析問題所在,才能體現(xiàn)出對block子系統(tǒng)的專業(yè)性,坐穩(wěn)在這個子系統(tǒng)中的地位。

如此熟練掌握一個子系統(tǒng),真不易!

 

責任編輯:武曉燕 來源: 相遇Linux
相關推薦

2020-06-08 09:11:47

Linux 內核Linux內核

2010-09-26 10:10:10

Linux內核

2022-08-01 11:32:57

Linux內核版本

2021-03-01 08:16:44

Linux 內核代碼

2021-02-25 09:50:01

LinuxWindows內核

2014-05-13 15:00:59

2020-02-07 18:32:36

LinuxLinux內核5.6操作系統(tǒng)

2020-10-22 07:09:19

TCP網絡協(xié)議

2009-12-17 15:18:47

2021-03-18 09:52:05

bugLinux內核

2021-03-11 14:28:11

bugLinux內核

2017-01-16 15:20:03

Linux內核Oops

2011-08-08 09:53:24

UbuntuLinux內核

2009-08-18 11:01:51

2015-09-11 15:56:52

內核構建Linux

2016-01-05 11:38:59

Linux內核運行

2020-01-17 19:10:32

Linux發(fā)行版內核

2024-05-30 08:19:52

微服務架構大型應用

2021-02-20 06:08:07

LinuxWindows內核

2012-05-03 08:34:15

LinuxKconfig
點贊
收藏

51CTO技術棧公眾號