diff options
| author | Linus Torvalds <torvalds@penguin.transmeta.com> | 2002-07-21 23:42:32 -0700 |
|---|---|---|
| committer | Linus Torvalds <torvalds@home.transmeta.com> | 2002-07-21 23:42:32 -0700 |
| commit | 7ee2f6c993a829cc24cce819261bc2b6053348cc (patch) | |
| tree | 5070cee11150ce4d489dcbc7b33c4165c2b71fe7 /Documentation | |
| parent | 8d27a6479b349d2431a114092824a52a2b1af037 (diff) | |
Ingo Molnar's update to remove irqlock (documentation and fixing
a number of drivers)
Diffstat (limited to 'Documentation')
| -rw-r--r-- | Documentation/cli-sti-removal.txt | 39 | ||||
| -rw-r--r-- | Documentation/preempt-locking.txt | 7 |
2 files changed, 36 insertions, 10 deletions
diff --git a/Documentation/cli-sti-removal.txt b/Documentation/cli-sti-removal.txt index 8192ffefc711..13c744dac866 100644 --- a/Documentation/cli-sti-removal.txt +++ b/Documentation/cli-sti-removal.txt @@ -2,10 +2,10 @@ #### cli()/sti() removal guide, started by Ingo Molnar <mingo@redhat.com> -as of 2.5.28, four popular macros have been removed on SMP, and +as of 2.5.28, five popular macros have been removed on SMP, and are being phased out on UP: - cli(), sti(), save_flags(flags), restore_flags(flags) + cli(), sti(), save_flags(flags), save_flags_cli(flags), restore_flags(flags) until now it was possible to protect driver code against interrupt handlers via a cli(), but from now on other, more lightweight methods @@ -86,25 +86,44 @@ the above code has a number of advantages: cli() on the other hand was used by many drivers, and extended the critical section to the whole IRQ handler function - creating serious lock contention. - + to make the transition easier, we've still kept the cli(), sti(), -save_flags() and restore_flags() macros defined on UP systems - but -their usage will be phased out until the 2.6 kernel is released. +save_flags(), save_flags_cli() and restore_flags() macros defined +on UP systems - but their usage will be phased out until 2.6 is +released. drivers that want to disable local interrupts (interrupts on the -current CPU), can use the following four macros: +current CPU), can use the following five macros: - __cli(), __sti(), __save_flags(flags), __restore_flags(flags) + local_irq_disable(), local_irq_enable(), local_irq_save(flags), + local_irq_save_off(flags), local_irq_restore(flags) but beware, their meaning and semantics are much simpler, far from -that of cli(), sti(), save_flags(flags) and restore_flags(flags). +that of the old cli(), sti(), save_flags(flags) and restore_flags(flags) +SMP meaning: + + local_irq_disable() => turn local IRQs off + + local_irq_enable() => turn local IRQs on + local_irq_save(flags) => save the current IRQ state into flags. The + state can be on or off. (on some + architectures there's even more bits in it.) + + local_irq_save_off(flags) => save the current IRQ state into flags and + disable interrupts. + + local_irq_restore(flags) => restore the IRQ state from flags. + +(local_irq_save can save both irqs on and irqs off state, and +local_irq_restore can restore into both irqs on and irqs off state.) another related change is that synchronize_irq() now takes a parameter: synchronize_irq(irq). This change too has the purpose of making SMP -synchronization more lightweight - this way you can wait for your own -interrupt handler to finish, no need to wait for other IRQ sources. +to make the transition easier, we've still kept the cli(), sti(), +save_flags() and restore_flags() macros defined on UP systems - but +their usage will be phased out until the 2.6 kernel is released. why were these changes done? The main reason was the architectural burden diff --git a/Documentation/preempt-locking.txt b/Documentation/preempt-locking.txt index 580814915c70..08e6035a0e13 100644 --- a/Documentation/preempt-locking.txt +++ b/Documentation/preempt-locking.txt @@ -82,6 +82,13 @@ Note that you do not need to explicitly prevent preemption if you are holding any locks or interrupts are disabled, since preemption is implicitly disabled in those cases. +But keep in mind that 'irqs disabled' is a fundamentally unsafe way of +disabling preemption - any spin_unlock() decreasing the preemption count +to 0 might trigger a reschedule. A simple printk() might trigger a reschedule. +So use this implicit preemption-disabling property only if you know that the +affected codepath does not do any of this. Best policy is to use this only for +small, atomic code that you wrote and which calls no complex functions. + Example: cpucache_t *cc; /* this is per-CPU */ |
