While doing SMP porting of some of our drivers (on powerpc target) we observed some behavior on which I need you guys to shed some light:
On doing a
local_irq_disable()
on a UP system the jiffies tend to freeze i.e. the count stops incrementing. Is this expected? I thought that the decrementer interrupt is 'internal' and should not get affected by thelocal_irq_disable()
kind off call since I expected it to disable local IRQ interrupt processing (external interrupt). The system of course freezes then also upon doing alocal_irq_enable()
the jiffies count jumps and it seems to be compensating for the 'time lapse' between thelocal_irq_disable()
andenable()
call.Doing the same on an SMP system (P2020 with 2 e500 cores) the results are surprising. Firstly the module that is being inserted to do this testing always executes on core 1. Further it sometimes does not see a freeze of 'jiffies' counter and sometimes we see that it indeed freezes. Again in case of a freeze of count it tends to jump after doing a
local_irq_enable()
. I have no idea why this may be happening.
Do we know in case of an SMP do both cores run a schedule timer, so that in some cases we do not see a freeze of jiffies counts or is it just on core 0 ?
Also since the kernel timers rely on 'jiffies' -- this would mean that
none of our kernel timers will fire if local_irq_disable()
has been
done? What would be the case this is done on one of the cores in an
SMP system?
There are many other questions, but I guess these will be enough to begin on a general discussion about the same :)
TIA
NS
Some more comments from the experimentation done.
My understanding at this point in time is that since kernel timers depend on 'jiffies' to fire, they wont actually fire on a UP system when I issue a local_irq_save()
. Infact some of our code is based on the assumption that when I do issue a local_irq_save()
it guarantees protection against interrupts on the local processor and kernel timers as well.
However carrying out the same experiment on an SMP system, even with both cores executing a local_irq_save()
, the jiffies do NOT stop incrementing and the system doesn't freeze. How is this possible ? Is LINUX using some other mechanism to trigger timer interrupts in the SMP system or possibly using IPIs? This also breaks our assumption that local_irq_disable()
will protect the system against kernel timers running on the same core atleast.
How do we go about writing a code that is safe against async events i.e. interrupts and kernel timers and is valid for both UP and SMP.