mysql ext4 hack抓取IO 函式

jesselyu發表於2017-04-05

前景:分析底層mysql sync的IO資料大小,用於條帶化分析和最佳化

安裝kernel debug info

yum install kernel-debuginfo kernel-debuginfo-common

 

  1. probe module("ext4").function("ext4_sync_file")
  2. {
  3. if( execname()=="mysqld") {
  4. printf("%s , %s, %d %u \n",pp(),tz_ctime(gettimeofday_s()),cpu(),gettimeofday_ns())
  5. printf("%s , %ld, %ld, %d \n",kernel_string($file->f_path->dentry->d_name->name),$start,$end,$datasync)
  6. }
  7. }
  8. probe kernel.function("filemap_write_and_wait_range")
  9. {
  10. if( execname()=="mysqld")
  11. printf(" %ld, %ld, %ld \n",$lstart, $lend, ($lend - $lstart))
  12. print_backtrace()
  13. }


sudo stap -v ext4_sync.stp

可以看到logfile都是按16k寫出:

module("ext4").function("ext4_sync_file@fs/ext4/fsync.c:88") , Thu Mar 16 21:52:18 2017 CST, 13 1489672338942480490 

ib_logfile1 , 0, 9223372036854775807, 0 

0, 9223372036854775807, 9223372036854775807 

0xffffffff811677c0 : filemap_write_and_wait_range+0x0/0x70 [kernel]

0xffffffffa032b7aa : ext4_sync_file+0xba/0x320 [ext4]

0xffffffff8120dee2 : vfs_fsync_range+0x42/0xb0 [kernel]

0xffffffff8120dfc0 : do_fsync+0x50/0x90 [kernel]

0xffffffff8120e2e0 : SyS_fsync+0x10/0x20 [kernel]

0xffffffff81641fc9 : system_call_fastpath+0x16/0x1b [kernel]

35439378432, 35439394815, 16383 

0xffffffff811677c0 : filemap_write_and_wait_range+0x0/0x70 [kernel]

0xffffffff81168015 : generic_file_direct_write+0x95/0x190 [kernel]

0xffffffff8116842c : __generic_file_aio_write+0x31c/0x3e0 [kernel]

0xffffffffa032ad5c : ext4_file_write+0x2ac/0x460 [ext4]

0xffffffff811dbaed : do_sync_write+0x8d/0xd0 [kernel]

0xffffffff811dc30d : vfs_write+0xbd/0x1e0 [kernel]

0xffffffff811dcf62 : sys_pwrite64+0x92/0xc0 [kernel]

0xffffffff81641fc9 : system_call_fastpath+0x16/0x1b [kernel]

5346672640, 5346689023, 16383 

0xffffffff811677c0 : filemap_write_and_wait_range+0x0/0x70 [kernel]

0xffffffff81168015 : generic_file_direct_write+0x95/0x190 [kernel]

0xffffffff8116842c : __generic_file_aio_write+0x31c/0x3e0 [kernel]

0xffffffffa032ad5c : ext4_file_write+0x2ac/0x460 [ext4]

0xffffffff811dbaed : do_sync_write+0x8d/0xd0 [kernel]

0xffffffff811dc30d : vfs_write+0xbd/0x1e0 [kernel]

0xffffffff811dcf62 : sys_pwrite64+0x92/0xc0 [kernel]

0xffffffff81641fc9 : system_call_fastpath+0x16/0x1b [kernel]

35553755136, 35553771519, 16383 

0xffffffff811677c0 : filemap_write_and_wait_range+0x0/0x70 [kernel]

0xffffffff81168015 : generic_file_direct_write+0x95/0x190 [kernel]

0xffffffff8116842c : __generic_file_aio_write+0x31c/0x3e0 [kernel]

0xffffffffa032ad5c : ext4_file_write+0x2ac/0x460 [ext4]

0xffffffff811dbaed : do_sync_write+0x8d/0xd0 [kernel]

0xffffffff811dc30d : vfs_write+0xbd/0x1e0 [kernel]

0xffffffff811dcf62 : sys_pwrite64+0x92/0xc0 [kernel]

0xffffffff81641fc9 : system_call_fastpath+0x16/0x1b [kernel]

46601191424, 46601207807, 16383 

0xffffffff811677c0 : filemap_write_and_wait_range+0x0/0x70 [kernel]

0xffffffff81168015 : generic_file_direct_write+0x95/0x190 [kernel]

0xffffffff8116842c : __generic_file_aio_write+0x31c/0x3e0 [kernel]

0xffffffffa032ad5c : ext4_file_write+0x2ac/0x460 [ext4]

0xffffffff811dbaed : do_sync_write+0x8d/0xd0 [kernel]

0xffffffff811dc30d : vfs_write+0xbd/0x1e0 [kernel]

0xffffffff811dcf62 : sys_pwrite64+0x92/0xc0 [kernel]

0xffffffff81641fc9 : system_call_fastpath+0x16/0x1b [kernel]

60283502592, 60283518975, 16383 

0xffffffff811677c0 : filemap_write_and_wait_range+0x0/0x70 [kernel]

0xffffffff81168015 : generic_file_direct_write+0x95/0x190 [kernel]

0xffffffff8116842c : __generic_file_aio_write+0x31c/0x3e0 [kernel]

0xffffffffa032ad5c : ext4_file_write+0x2ac/0x460 [ext4]

0xffffffff811dbaed : do_sync_write+0x8d/0xd0 [kernel]

0xffffffff811dc30d : vfs_write+0xbd/0x1e0 [kernel]

0xffffffff811dcf62 : sys_pwrite64+0x92/0xc0 [kernel]

0xffffffff81641fc9 : system_call_fastpath+0x16/0x1b [kernel]

63991283712, 63991300095, 16383 

0xffffffff811677c0 : filemap_write_and_wait_range+0x0/0x70 [kernel]

0xffffffff81168015 : generic_file_direct_write+0x95/0x190 [kernel]

0xffffffff8116842c : __generic_file_aio_write+0x31c/0x3e0 [kernel]

0xffffffffa032ad5c : ext4_file_write+0x2ac/0x460 [ext4]

0xffffffff811dbaed : do_sync_write+0x8d/0xd0 [kernel]

0xffffffff811dc30d : vfs_write+0xbd/0x1e0 [kernel]

0xffffffff811dcf62 : sys_pwrite64+0x92/0xc0 [kernel]

0xffffffff81641fc9 : system_call_fastpath+0x16/0x1b [kernel]

89684754432, 89684770815, 16383 

0xffffffff811677c0 : filemap_write_and_wait_range+0x0/0x70 [kernel]

0xffffffff81168015 : generic_file_direct_write+0x95/0x190 [kernel]

0xffffffff8116842c : __generic_file_aio_write+0x31c/0x3e0 [kernel]

0xffffffffa032ad5c : ext4_file_write+0x2ac/0x460 [ext4]

0xffffffff811dbaed : do_sync_write+0x8d/0xd0 [kernel]

0xffffffff811dc30d : vfs_write+0xbd/0x1e0 [kernel]

0xffffffff811dcf62 : sys_pwrite64+0x92/0xc0 [kernel]

0xffffffff81641fc9 : system_call_fastpath+0x16/0x1b [kernel]

19488227328, 19488243711, 16383 

0xffffffff811677c0 : filemap_write_and_wait_range+0x0/0x70 [kernel]

0xffffffff81168015 : generic_file_direct_write+0x95/0x190 [kernel]

0xffffffff8116842c : __generic_file_aio_write+0x31c/0x3e0 [kernel]

0xffffffffa032ad5c : ext4_file_write+0x2ac/0x460 [ext4]

0xffffffff811dbaed : do_sync_write+0x8d/0xd0 [kernel]

0xffffffff811dc30d : vfs_write+0xbd/0x1e0 [kernel]

0xffffffff811dcf62 : sys_pwrite64+0x92/0xc0 [kernel]

0xffffffff81641fc9 : system_call_fastpath+0x16/0x1b [kernel]

75220402176, 75220418559, 16383 

0xffffffff811677c0 : filemap_write_and_wait_range+0x0/0x70 [kernel]

0xffffffff81168015 : generic_file_direct_write+0x95/0x190 [kernel]

0xffffffff8116842c : __generic_file_aio_write+0x31c/0x3e0 [kernel]

0xffffffffa032ad5c : ext4_file_write+0x2ac/0x460 [ext4]

0xffffffff811dbaed : do_sync_write+0x8d/0xd0 [kernel]

0xffffffff811dc30d : vfs_write+0xbd/0x1e0 [kernel]

0xffffffff811dcf62 : sys_pwrite64+0x92/0xc0 [kernel]

0xffffffff81641fc9 : system_call_fastpath+0x16/0x1b [kernel]

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/30088583/viewspace-2136681/,如需轉載,請註明出處,否則將追究法律責任。

相關文章