在发生内核恐慌时,我可以打印出系统崩溃时持有哪些锁吗?
我正在写一个作业(所以我压力很大,呵呵)并且我的项目有一个特定的地方取消引用 NULL。
详细信息是这样的:这是一个系统调用,它遍历该进程的页表条目并报告自上次调用以来访问过的内容。请不要对问题本身提出建议,因为我不想违反任何学术诚实规则。
然而,情况似乎是系统调用的执行被抢占,并且某些东西进入并破坏了我正在使用的结构。令人气愤的是我不明白是什么。
因此,我希望恐慌告诉我在恐慌时正在持有什么自旋锁/信号量等。这会给我一个提示,让我知道到底发生了什么。
I am writing an assignment (so I'm under lots of pressure, hehe) and I have a particular place where my project is dereferencing NULL.
The details are this: it's a system call that walks the page table entries of this process and reports which were accessed since the call last happened. Please do no give suggestions about the problem itself, as I don't want to violate any academic honesty rules.
It seems to be the case, however, that the execution of the system call is preempted, and something goes in and screws with the structures I'm using. The infuriating thing is that I can't figure out what.
Therefore, I want the panic to tell me what spinlocks/semaphores, etc. are being held at the time of the panic. This would give me a hint as to what the hell is going on.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您在启用
CONFIG_LOCKDEP
的情况下构建内核,您应该能够使用alt-sysrq-D
转储所有锁。请参阅drivers/tty/sysrq.c。If you build your kernel with
CONFIG_LOCKDEP
enabled you should be able to dump all locks withalt-sysrq-D
. Seedrivers/tty/sysrq.c
.方法 1:附加内核启动时参数
方法 2:等效内核 sysctl 旋钮
参考:
/proc/sys/kernel 的文档
panic_print
用于在发生紧急情况时打印系统信息的位掩码。
用户可以选择以下位的组合:
===== ======================================== ========
位 0 打印所有任务信息
位 1 打印系统内存信息
位 2 打印定时器信息
如果
CONFIG_LOCKDEP
开启,则第 3 位打印锁定信息位 4 打印 ftrace 缓冲区
位 5 打印缓冲区中的所有 printk 消息
位 6 打印所有 CPU 回溯(如果在架构中可用)
=====================================================
所以例如,要在紧急情况下打印任务和内存信息,用户可以::
echo 3 > /proc/sys/内核/panic_print
Method 1: Append kernel boot-time parameter
Method 2: Equivalent kernel sysctl knob
Reference:
Documentation for /proc/sys/kernel
panic_print
Bitmask for printing system info when panic happens.
User can chose combination of the following bits:
===== ============================================
bit 0 print all tasks info
bit 1 print system memory info
bit 2 print timer info
bit 3 print locks info if
CONFIG_LOCKDEP
is onbit 4 print ftrace buffer
bit 5 print all printk messages in buffer
bit 6 print all CPUs backtrace (if available in the arch)
===== ============================================
So for example to print tasks and memory info on panic, user can::
echo 3 > /proc/sys/kernel/panic_print