local_bh_disable,preempt_disable,local_irq_disable [英] local_bh_disable, preempt_disable, local_irq_disable

查看:108
本文介绍了local_bh_disable,preempt_disable,local_irq_disable的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

local_bh_disable 禁用下半部分(softirqs)的处理.Softirq可以在中断返回路径上处理,也可以通过ksoftirqd-(每个cpu)线程处理,如果系统承受大量softirq负载,则该线程将被唤醒.

local_bh_disable disables the processing of bottom halves (softirqs). Softirqs are processed on either, interrupt return path, or by the ksoftirqd-(per cpu)-thread that will be woken up if the system suffers of heavy softirq-load.

preempt_disable 禁用抢占,这意味着,当线程在 preempt_disable <-> preemt_enable 范围内执行时,它将不会由调度程序进入睡眠状态.这意味着,如果当前线程在该作用域内时发生system-timer-interrupt,则它可能会更新调度程序的帐户表,但不会将上下文切换到另一个线程.这包括softirqd.

preempt_disable disables preemption, which means, that while a thread is executing inside a preempt_disable <-> preemt_enable scope, it will not be put to sleep by the scheduler. This means that, if the system-timer-interrupt occurs while the current thread is inside that scope, it might update the accouting tables of the scheduler, but it will not switch context to another thread. this includes the softirqd.

local_irq_disable local_irq_save 禁用本地CPU的中断.这意味着本地cpu将不会对任何irq作出反应,因此它将不会运行任何中断返回路径,因此无法在其中运行softirqs.

local_irq_disable or local_irq_save disable interrupts for the local cpu. this means that the local cpu will not react to any irqs, so it will not run any interrupt return paths and hence, cannot run softirqs there.

假设我的上述说法是正确的(我不确定),那么在您分别调用 preempt_disable local_irq_save (在进程上下文中)?

Assuming my above statements are true (which i am not sure about), then wouldnt it be redundant to call local_bh_disable AFTER you called preempt_disable and local_irq_save (while being in process context)?

推荐答案

是.调用local_irq_save/disable后,就不需要进一步的保护了-您将不会被打扰(除非受到NMI或代码中的异常的影响).

Yes. Once local_irq_save / disable has been called, no further protection is needed -- you won't be interrupted (except by an NMI or an exception in your code).

但是,通常,您会发现设计成可在不同上下文中调用的代码位,因此它们可以为某些子操作提供保护,而这些子操作最终在某些路径中是多余的.

Often, however, you'll find bits of code that are designed to be callable from different contexts, so they may provide protection for some sub-operation that ends up being redundant in some paths.

这篇关于local_bh_disable,preempt_disable,local_irq_disable的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆