- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个关于在 3.10 内核中实现 printk() 的问题。我看到了calls local_irq_save
一开始。然后我看到了 calls raw_spin_lock(&logbuf_lock)
.如果在此之前已经禁用了中断,那么 logbuf_lock 的目的是什么?是不是因为即使在当前 CPU 上禁用了中断,其他 CPU 仍然可以调用 printk,因此需要停止写入日志缓冲区?
基本上我有三个问题:
console_unlock
在循环中,它获取 logbuf_lock 并禁用中断,然后释放 logbuf_lock 并调用控制台驱动程序,然后恢复中断。这个锁定/禁用中断序列的目的是什么?
local_irq_save()
protects against interrupts on the local CPU (and also avoids being rescheduled on another CPU while using a cpu variable to access per-CPU data)
local_irq_save()
仅当它访问每个 CPU 数据时才会阻止当前线程在另一个 CPU 上重新调度,或者它会阻止当前线程在另一个 CPU 周期上重新调度?在这里使用 printk() 的情况下 local_irq_save() 的目的是什么?我记得在 LMKL 上读过一个线程,它说禁用中断是为了确保日志缓冲区中的条目顺序反射(reflect)了 printk() 调用发生的实际顺序。
最佳答案
What's the purpose of logbuf_lock if interrupts have been already disabled prior to this? Is it because even though interrupts are disabled on the current CPU other CPUs can still call printk so they need to be stopped from writing to the log buffer?
local_irq_save()
防止本地 CPU 上的中断(并且还避免在使用
cpu
变量访问每个 CPU 数据时在另一个 CPU 上重新调度),而自旋锁防止其他 CPU。
If code on only 1 CPU were to be calling printk() at any given moment, could interrupts still be handled on other cores in an SMP system?
I see printk acquires logbuf_lock and writes to the log buffer and then tries to grab the console semaphore and releases logbuf_lock. Then inside console_unlock inside a loop it acquires logbuf_lock and disables interrupts, then releases logbuf_lock and calls the console drivers, and then restores interrupts. What's the purpose of this locking/disabling interrupt sequence?
logbuf_lock
保护日志缓冲区,同时
console_sem
保护对控制台驱动程序列表和实际控制台本身的访问。
console_unlock()
中的控制台。 .这两个步骤不需要在对
printk()
的同一次调用中发生。 .此外,在注册/启动/恢复/...控制台时可能会发生将日志缓冲区刷新到控制台的情况。
printk()
试图获得
console_sem
.它甚至可以在中断上下文中执行此操作,因为
down_trylock()
不 sleep 。如果它获得了信号量,它可以继续将日志缓冲区内容发送到控制台。如果它没有获取信号量,则控制台信号量的持有者有责任将日志缓冲区内容发送到控制台,在
console_unlock()
.
console_unlock()
正在发送到控制台,可能有其他 CPU 调用
printk()
.所以
console_unlock()
循环直到没有更多内容可以发送到控制台。在每个循环中,它都会获取指向日志缓冲区部分的指针以发送到控制台,位于
logbuf_lock
下。 ,然后,不再下
logbuf_lock
, 将输出发送到控制台。在向控制台发送内容时,由于
logbuf_lock
没有被占用,其他 CPU 可以继续向日志缓冲区添加内容。
I see comments in printk() about the log buffer possibly being filled up again so the buffer may have to get flushed to the console again. How would this situation occur given all the locking I asked about in #1 above?
logbuf_lock
后缓冲区可能已被填满但之前
up()
ing
console_sem
.和
logbuf_lock
之前发布
up()
ing
console_sem
因为
up()
可能导致唤醒,这需要获取运行队列锁,这可能会产生针对
printk()
的优先级反转问题。使用运行队列锁调用 (
commit 0b5e1c5255 )。
console_unlock()
上无限循环。 (它发生在通过慢速串行控制台记录大量启动事件的大型系统上),将这些工作移交给其他 CPU;并尽量减少在
printk()
上禁用中断的时间.
Do you mean calling local_irq_save() will prevent the current thread from being rescheduled on another CPU only if it accesses per-CPU data or it prevents the current thread from being rescheduled on another CPU period?
local_irq_save()
阻止在本地 CPU 上处理中断,这可能最终会调用
schedule()
从 ISR 返回时。
schedule()
也可以从其他地方调用,但由于
printk()
应该能够在中断上下文中使用,它调用的任何内容都不应该最终调用
schedule()
(例如:出于这个原因,使用
down_trylock()
而不是
down()
)。
What is the purpose of local_irq_save() in the case of printk() here?
logbuf_lock
- 保护数据免受中断。这种情况通常通过自旋锁的 IRQ 变体来解决(例如: raw_spin_lock_irqsave()
),但这里有更多的东西可以在禁用中断的情况下运行。 can_use_console()
,来自 console_trylock_for_printk()
,问:这个时候我们真的可以在这个cpu上使用console吗?,注意:console驱动可能会假设per-cpu的资源已经分配好了。转移到另一个 CPU 可能会令人困惑。 console_sem
带 down_trylock()
所以如果中断也尝试 printk()
应该不是问题,在持有 console_sem()
时被抢占会阻止其他人打印到控制台。 preempt_disable()
中。/
preempt_enable()
,允许中断,但不允许抢占。
I remember reading a thread on LMKL that said the disabling of interrupts was to ensure the order of entries in the log buffer reflected the actual order in which the printk() calls occurred.
cont
缓冲区,它保存了最后一个换行符的所有字符。当换行符到达或不同的任务时,它会被刷新到“真实的”日志缓冲区
printk()
s。
Well, I believe someone got DDetetccctted ed 113223 HHzz CPUCPU
logbuf_lock
保证,
vprintk_emit()
中的日志缓冲区时已禁用中断的情况下进行的。 ,并与锁定变体一起使用,该变体在从
raw_spin_lock_irqsave()
上读取时禁用中断(
console_unlock()
) .因此,访问日志缓冲区是安全的,不会受到其他 CPU 或中断的干扰。
printk()
的情况。在较新的内核中,这种情况包含在
cont
中。缓冲区,它保存部分行,并在另一个 CPU/中断干扰时刷新它们,因此日志行可能被分成几行并且它们之间有不相关的日志行,但没有日志行应该有混合输出。
console_unlock()
来实现的。 (调用控制台驱动程序)在每个
vprintk_emit()
中称呼。如果无法获取控制台信号量,则消息已经在日志缓冲区中,当前信号量所有者会将其输出到控制台。
printk.c
before 和
after ) 在调用
release_console_sem()
之前重新启用中断(这是
console_unlock()
的前一个化身)。显然,当 lockdep(一个锁验证器,能够检测可能的死锁和其他锁定问题,以及
打印 诊断)被启用时,尝试从
printk()
打印时可能会导致锁定。 .因此,调用
spin_{,un}lock_irq{save,restore}()
分为禁用/启用中断和获取/释放锁,
lockdep_on/off()
在两者之间添加了调用,并且扩展了 lockdep 和中断的禁用以涵盖整个功能。
I see printk acquires logbuf_lock and writes to the log buffer and then tries to grab the console semaphore and releases logbuf_lock. Then inside console_unlock inside a loop it acquires logbuf_lock and disables interrupts, then releases logbuf_lock and calls the console drivers, and then restores interrupts. What's the purpose of this locking/disabling interrupt sequence?
console_unlock()
不仅来自
vprintk_emit()
,它也会在注册新控制台、恢复控制台、将 CPU 与待处理的输出热插拔到控制台时调用,......这些地方通常启用中断。所以,
console_unlock()
必须考虑到这一点。
logbuf_lock
时,while 中断被禁用。在
console_unlock()
(它调用
raw_spin_lock_irqsave()
),它们在释放锁(
raw_spin_unlock()
)时不会(可能)重新启用,它们只有在
local_irq_console()
之后才可能重新启用(
call_console_drivers()
) .我看到打电话的唯一原因
call_console_drivers()
禁用中断是为了避免 CPU 在我们的控制下发生变化(控制台驱动程序可以访问每个 CPU 的变量)。
console_unlock()
之前重新启用中断。 ,以及之前
call_console_drivers()
(在 -rt 中受
migrate_disable()/migrate_enable()
保护,不允许 CPU 迁移)在
console_unlock()
中.这样做是为了最大限度地减少
printk()
期间的中断延迟。 .
PREEMPT_RT_FULL
支持低中断延迟。你可以在
printk.c in the linux-stable-rt tree at git.kernel.org 看到它,相关补丁为
printk-rt-aware .
关于linux - printk 中断禁用和锁定,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25873754/
在gdb中获取此消息。我知道它不是错误或任何东西。我也做了分页,所以那不是问题。 有什么办法可以抑制此消息? 最佳答案 我很好奇看到这个问题没有得到解决... 我获得了GDB manual,它说(部分
好吧,这很烦人,而且可能很简单。我想用禁用的复选框启动我的网页,并在选择列表框中的特定行后启用这些框。所以我把它放在 onload 方法中 onload = function () { for
看来我需要以某种方式在我的 php 页面上禁用 IPv6,但我不确定该怎么做。我想我必须在我的 INI 文件中的某处添加 --disable-ipv6 ……虽然这看起来不像正确的语法。 我正在尝试解决
我有这两个代码: 第一个是禁用复制粘贴的宏: Sub Desable_Copy() Dim oCtrl As Office.CommandBarControl For Each oCt
在下面的代码中,我想, 如果我选择/单击“患者类型”按钮。它们在菜单“xmenumain”“儿科心电图”项中应该被禁用(它应该列在菜单列表中,但颜色为淡灰色)。我如何实现它? void MyMenu:
我目前在 Coordinator 布局中有一个底部导航栏,我向其添加了 HideBottomViewOnScrollBehaviour。有些屏幕需要隐藏导航栏,我可以通过从 BottomNavigat
我需要一些关于 jquery if 条件的帮助。我已经搜索和测试了几个小时,任何帮助都会很棒!我得到这个 HTML 代码: Value: No Match Test Test 2 Test 3
我正在开发 Delphi -7 中的自定义组件我有一些published特性 private { Private declarations } FFolderzip ,Fi
尝试学习菜单处理的基础知识。我的测试应用程序的菜单栏有 3 个菜单——即“TestApp”、“File”和“Help”。我发现我可以完全删除这些菜单,只需调用 say: NSMenu* rootMen
我以编程方式创建一个 NSMenuItem,但它被禁用。如果我重写 validateMenuItem: 方法并为所有项目返回 YES,则菜单项工作正常。 当我告诉菜单 autoEnableItems
我的 Web 表单中有一个 asp 按钮 (runat="server") 进入更新面板。 当我点击这个按钮时,它会执行一些操作。 Private Sub ButtonDoI
我目前正在为 video.js 构建一个插件,它可以在某些断点处将覆盖层呈现在屏幕上。但是,在不启动视频的情况下,我无法单击任何叠加层。我认为我需要禁用播放器上的点击播放功能。 我应该如何禁用/启用
设置剑道网格 selectable: "row", navigatable: true, 允许选择列标题单元格并通过键盘切换其排序状态。如何完全禁用使用键盘选择列标题单元格的功能? 最
我不想卸载code rush。我只是想在不需要的时候有机会将其关闭。 这可能吗? (快速版本)... 最佳答案 首先您应该打开“DevExpress”菜单。默认情况下,它在 CodeRush Xpre
设置: 我正在使用 TinyMCE 的 Angular 包装器来允许我的用户构建自己的电子邮件模板。这些电子邮件会发送给每个用户组织内的多个人员。我创建了自定义工具栏按钮来插入小文本 block [[
我希望下拉菜单在悬停时打开,前提是窗口大于 767 像素。我试图在页面加载和窗口调整大小时调用一个函数,并使用宽度大小条件。 enableHover() 函数仅适用于页面加载,不适用于窗口调整大小。
由于我遇到了一些问题,我正在 .NET Framework 4 中尝试连接池。使用 SQL Profiler,我可以看到每次从连接池中获取连接时,都会执行存储过程 sp_reset_connectio
我避免在我的 swift 代码中收到警告。然而,当谈到 Storyboard要求时,这对我来说有点困难。 所以现在我只想禁用 xcode 显示有关 Storyboard问题的警告。 我尝试了以下方法但
我不是 JavaScript 专家,我目前正在尝试为表单创建一个函数,该函数根据上一页上选择的数字重复相同的字段。 表单字段可能有 1 到 10 行,每行都有一个单选按钮选择,可启用/禁用每一行。 目
我正在尝试使用 CPU2006 运行各种基准测试,以查看各种优化在 gcc 速度方面的作用。我熟悉 -O1、-O2 和 -O3,但听说 -msse 是一个不错的优化。 -msse 到底是什么?我还看到
我是一名优秀的程序员,十分优秀!