在Linux内核的SMP如何安排工作? (ARM架构) [英] How SMP schedule work in Linux kernel? (ARM architecture)

查看:3047
本文介绍了在Linux内核的SMP如何安排工作? (ARM架构)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Linux中,调度将在特定的时间量已经过去了触发。我的理解,定时器触发中断从而触发调用进度

In linux, the scheduler will be triggered when a specific amount of time has passed. As I understood, the timer triggers an interrupt which in turn triggers a call to schedule.

在一个SMP系统中,我在书上看到深入理解Linux内核,即每个处理器运行在其自己的调度程序()函数。
这是否意味着每一个定时器中断触发每个处理器在同一时间做了重新安排?

In a SMP system, I read in the book "Understanding the Linux Kernel" that "each processor runs the scheduler() function on its own". Does this mean every timer interrupt triggers every cpus to do a re-schedule at the same time?

推荐答案

ARM SMP系统支持两种类型的中断。 SPI(共享外设中断)和PPI(外围私人中断)。生产者价格指数是一个的每个CPU 的中断源。对于PPI的SMP一个特殊情况是SGI(软件生成的中断);这是一个CPU到CPU中断,用于信号从一个CPU到另一个的世界SMP(称为<一href=\"http://en.wikipedia.org/wiki/Inter-processor_interrupt\">IPI).Note1

The ARM SMP systems support two types of interrupts. SPI (shared peripheral interrupt) and PPI (peripheral private interrupts). The PPI is a per-CPU interrupt source. A special case for SMP of the PPI is an SGI (software generated interrupt); this is a CPU-to-CPU interrupt that is used to signal from one CPU to another in the SMP world (called IPI).Note1

A <一个href=\"https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/drivers/clocksource/arm_arch_timer.c\">PPI计时器可用于允许每个CPU使用'空循环调度';这是定时器中断通过未来的时间事件(谷歌计时轮的知识计划,看<一个href=\"https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/timers/NO_HZ.txt\"><$c$c>NO_HZ文档等)。当前的Linux内核不使用这个特定的PPI计时器进行调度。它只是用来作为延迟循环时间源。相反,<一个href=\"https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/drivers/clocksource/arm_global_timer.c\">Global PPI计时器的被使用。该定时器可以选择性中断每个CPU,但寄存器组是全局的所有CPU。一个特定的CPU可能会安排为自己的中断;随着时间基准是全球性的。

A PPI timer can be used to allow each CPU to use 'tickless scheduling'; that is timer interrupts are scheduled via knowledge of future time events (google timing wheel, look at the NO_HZ documentation, etc). The current Linux kernel doesn't use this specific PPI timer for scheduling. It is only used as a delay loop time source. Instead the Global PPI timer is used. This timer can interrupt each CPU selectively, but the register set is global to all CPUs. A particular CPU may schedule an interrupt for itself; with the time base being global.

并发症是任务必须从一个CPU到另一个以平衡CPU之间的工作进行迁移。同时,Linux内核的核心code /调度为多个CPU(或体系结构)的书面和他们可能没有这些的每个CPU 的中断源。一个明确的答案可能取决于你的内核版本和所使用的调度程序(或更一般的内核配置)。一般情况下,一个繁忙的CPU会做的迁移的,其它的CPU可能会在计时器滴答醒来只是为了看看它任务的设置应该运行(可能是迁移的过程)。如果 NO_HZ 生效时,某些CPU可能不会唤醒所有;他们将在迁移的情况下获得的IPI。

The complication is that tasks must be migrated from one CPU to another in order to balance work among CPUs. Also, the Linux kernel's core code/scheduler is written for multiple CPUs (or architectures) and they may not have these per-CPU interrupt sources. An definitive answer may depend on your kernel version and the scheduler used (or more generally kernel configuration). Generally, a busy CPU will do the migration, other CPUs may wake on a timer tick just to see if a task in it's set should run (maybe a migrated process). If NO_HZ is in effect, some CPUs may not wake at all; they will get an IPI in the case of migration.

在任何情况下,没有什么是的 ARM 在特定除了时钟源的CPU调度。一个 ARM SMP系统,没有一个的全球PPI定时器的这是可能的。在这种情况下,每个CPU可以唤醒到服务中断,但多数可以立即入睡。这可以在任何系统上发生因恶劣定时器/中断控制器的设计或坏的系统配置。然而,即使在这些情况下,code不会称之为成除了在需要调度

In any case, there is nothing that is ARM specific in the CPU scheduling besides the clock source. It is possible for an ARM SMP system to not have the a global PPI timer. In this case, every CPU may wake to service an interrupt, but the majority may sleep immediately. This could happen on any system due to a bad timer/interrupt controller design or a bad system configuration. However, even in these cases, the code would not call into the scheduler except where needed.

请参阅: Linux调度对SMP (这可能重复虽然答案不是很大IMO), IBM的完全公平调度文章和的O'Reillys Linux内核调度章。

See: Linux Scheduler on SMP (which maybe a duplicate although the answer is not great IMO), IBMs completely fair scheduler article and O'Reillys Linux Kernel scheduler chapter.

注1:这其实就是 GIC (或通用中断控制器的)术语。然而,大多数ARM SMP系统使用该中断控制器。它是捆绑在一起的Cortex-A处理器,来到作为某些ARMv6的系统外部软组件。它有可能为一个ARM SMP系统使用其他的控制器,但它可能是极其罕见的或不存在的

Note1: This is actually GIC (or generic interrupt controller) terminology. However, most ARM SMP systems use this interrupt controller. It is bundled with Cortex-A CPUs and came as an external soft-component for some ARMv6 systems. It is possible for an ARM SMP systems to use another controller, but it is probably extremely rare or non-existent.

编辑:有两个ARM片上定时器;这些都是有用的,因为每个的Cortex-A它们具有相对于SOC厂商定时器。其中之一来代替对延迟的'计数循环。这部作品在中断的情况下更好。我不认为这关键是要了解SMP计划,你可能会忽略评论,只是知道该源文件不用于调度。这是第一个我看。如果你觉得很分心,我会删除该信息。

There are two ARM on-chip timers; these are useful as every Cortex-A has them compared to SOC vender timers. One of them is used instead of a 'counting loop' for a delay. This works better in the case of interrupts. I don't think it is critical to understand SMP scheduling, you may ignore that comment and just know that that source file is not used for scheduling. It was the first one I looked at. If you find it really distracting, I will remove that information.

请参阅上的定时轮本文 ;它是关于IP/网络,但 NO_HZ 的概念是相似的。 IE浏览器。不要中断每隔10ms,只是递增蜱。在 NO_HZ 的情况下,每个CPU可以设置基于给予什么样的请求驱动程序和子系统的一个未来的唤醒时间。也就是说, schedule_work()需要175ms之间要运行,则定时器设置为CPU的价值,我们不唤醒17倍(如果系统蜱是10毫秒),但只是通过增加蜱17.一些CPU可能需要暂停驱逐目前的进程运行另一个用于多任务一样,所以调度器本身可能设置一个计时器。

See this paper on timing wheels; it is about 'IP'/networking, but the concept of NO_HZ is similar. Ie. Don't interrupt every 10mS, just to increment ticks. In the NO_HZ case, each CPU can set a future wake-up time based on what sort of requests drivers and sub-systems have given. Ie, schedule_work() needs to be run in 175ms, then the timer is set to that value for the CPU and we don't wake-up 17 times (if the system tick is 10mS), but just increment ticks by 17. Some CPUs may need a timeout to evict the current process to run another for multi-tasking as well, so the scheduler itself may set a timer.

这篇关于在Linux内核的SMP如何安排工作? (ARM架构)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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