设为首页 收藏本站
查看: 566|回复: 0

[经验分享] Linux Kernel Testing and Debugging

[复制链接]

尚未签到

发表于 2018-5-23 08:56:29 | 显示全部楼层 |阅读模式
  Dmesg check Kernel logs

  •   dmesg -t -l emerg
  •   dmesg -t -l crit
  •   dmesg -t -l alert
  •   dmesg -t -l err
  •   dmesg -t -l warn
  •   dmesg -t -k
  •   dmesg -t
  Kernel Testing Tools
  There are several tests under tools/testing that are included in the Linux kernel git. There is a good mix of automated and functional tests.
  

  ktest suite
  ktest is an automated test suite that can test builds, installs, and kernel boots.
  It can also run cross-compile tests provided the system has cross-compilers installed. ktest depends on flex and bison tools. Please consult the ktest documentation in tools/testing/ktest for details on how to run ktest. It is left to the reader as a self-study. A few resources that go into detail on how to run ktest:
  ktest-eLinux.org

  

  tools/testing/selftests
  

  Let's start with selftests. Kernel sources include a set of self-tests which test various sub-systems. As of this writing, breakpoints, cpu-hotplug, efivarfs, ipc, kcmp, memory-hotplug, mqueue, net, powerpc, ptrace, rcutorture, timers, and vm sub-systems have self-tests. In addition to these, user memory self-tests test user memory to kernel memory copies via test_user_copy module. The following is on how to run these self-tests:
  

  Compile tests:
  make -C tools/testing/selftests
  Run all tests: (running some tests needs root access, login as root and run)
  make -C tools/testing/selftests run_tests
  Run only tests targeted for a single sub-system:
  make -C tools/testing/selftests TARGETS=vm run_tests
  tools/testing/fault-injection
  

  Another test suite under tools/testing is fault-injection. failcmd.sh script runs a command to inject slab and page allocation failures. This type of testing helps validate how well kernel can recover from faults. This test should be run as root. The following is a quick summary of currently implemented fault injection capabilities. The list keeps growing as new fault injection capabilities get added. Please refer to the Documentation/fault-injection/fault-injection.txt for the latest.
  

  failslab (default option)
  injects slab allocation failures. kmalloc(), kmem_cache_alloc(), ...
  fail_page_alloc
  injects page allocation failures. alloc_pages(), get_free_pages(), ...
  fail_make_request
  injects disk IO errors on devices permitted by setting, /sys/block//make-it-fail or /sys/block///make-it-fail. (generic_make_request())
  

  fail_mmc_request
  injects MMC data errors on devices permitted by setting debugfs entries under /sys/kernel/debug/mmc0/fail_mmc_request
  

  The capabilities and behavior of fault-injection can be configured. fault-inject-debugfs kernel module provides some debugfs entries for runtime. Ability to specify the error probability rate for faults, the interval between fault injection are just a couple of examples of the configuration choices fault-injection test supports. Please refer to the Documentation/fault-injection/fault-injection.txt for details. Boot options can be used to inject faults during early boot before debugfs becomes available. The following boot options are supported:
  

  failslab=
  fail_page_alloc=
  fail_make_request=
  mmc_core.fail_request=[interval],[probability],[space],[times]
  The fault-injection infrastructure provides interfaces to add new fault-injection capabilities. The following is a brief outline of the steps involved in adding a new capability. Please refer to the above mentioned document for details:
  

  define the fault attributes using DECLARE_FAULT_INJECTION(name);
  Please see the definition of struct fault_attr in fault-inject.h for details.
  

  add a boot option to configure fault attributes
  This can be done using helper function setup_fault_attr(attr, str); Adding a boot option is necessary to enable the fault injection capability during early boot time.
  

  add debugfs entries
  Use the helper function fault_create_debugfs_attr(name, parent, attr); to add new debugfs entries for this new capability.
  

  add module parameters
  Adding module parameters to configure the fault attributes is a good option, when the scope of the new fault capability is limited to a single kernel module.
  

  add a hook to insert failures
  should_fail(attr, size); Upon should_fail() returning true, client code should inject a failure.
  Applications using this fault-injection infrastructure can target a specific kernel module to inject slab and page allocation failures to limit the testing scope if need be.
  

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-480085-1-1.html 上篇帖子: Linux之Strace 下篇帖子: Linux monitor tool
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表