Why interrupting interrupts disables kernel protection and how locking locks disable prevention

I have been reading Linux Kernel Development lately, and I have several questions related to disabling preemption.

  • The Interrupt Management section of Chapter 7 says:

    In addition, disabling interrupts also disables kernel protection.

    I also read from the book that a kernel assumption can occur in the following cases:

    When the interrupt handler exits before returning to kernel space.
    When the kernel code becomes succession again.
    If the task in the kernel explicitly calls the schedule ()
    If the job is in a kernel block (which leads to a schedule () call)

    But I can not associate interrupts with these cases.

  • As far as I know, spinlock will disable continuity using the preempt_disable () function.

    Message What exactly are “spinning locks”? He speaks:

    On a single nuclear computer, spinlocking is simply "disable interrupts" or "boost IRQL," which completely prevents thread scheduling.

    Does preempt_disable () provide a ban on suspension by disabling interrupts?

+8
linux interrupt linux-kernel spinlock
source share
2 answers

I am not a planner guru, but I would like to explain how I see him. Here are a few things.

  • preempt_disable () does not disable IRQ . It just increments the thread_info->preempt_count .
  • Disabling interrupts also disables continuity, because after that the scheduler does not work, but only on a single-processor machine. On SMP, this is not enough, because when you close interrupts on one CPU, others / others still do / do something asynchronously.
  • The Big Lock (means closing all interrupts on all processors) significantly slows down the system - therefore, it is no longer used. This is also the reason that preempt_disable () does not close the IRQ.

You can see what is preempt_disable (). Try this: 1. Get a spin lock. 2. Call schedule ()

In dmesg you will see something like "BUG: scheduling while atomic". This happens when the scheduler discovers that your process is in an atomic (not proactive) context, but he schedules it.

Good luck.

+7
source share

In the kernel test module, I wrote for monitoring / profiling a task, I tried to disable interrupts:

1 - Using local_irq_save ()

2 - Using spin_lock_irqsave ()

3 - Manually disable_irq () for all IRQs in / proc / interrupts

In all three cases, I could still use hrtimer to measure time, even though the IRQs were disabled (and the task that I controlled was also offloaded).

I find this veeeeerrrryyyy weird ... I personally expected Sebastian Mountaniol to point -> No interruptions - no hours. No hours - no timers ...

The Linux 2.6.32 kernel on one core, one processor ... Can anyone have a better explanation?

+1
source share

All Articles