Skip to contentSkip to conversation

init_idle and local_irq_save

parisc-linux Grant Grundler 3 participants 3 messages Mar 29, 2004

lore
Share & tools
lore
#0 lore raw

Hi all,
I'm trying to get 2.6 SMP working on a UP box and was walking through the init sequence. I have two questions related to init_idle() in kernel/sched.c:

o local_irq_save()/local_irq_restore are called without an obvious local_irq_disable() call in between. Is this really needed for some other reason or is the local_irq_disable() missing?

o double_rq_lock() acquires the locks with lowest address first. double_rq_unlock() does not release those in the inverse order. Is that a problem?
I'm just nervous since I didn't see the local_irq_disable() in init_idle() which would guarantee both unlock's happen atomically.

thanks,
grant

#1 lore raw
Quoted 3 lines · Grant Grundler

o local_irq_save()/local_irq_restore are called without an obvious local_irq_disable() call in between. Is this really needed for some other reason or is the local_irq_disable() missing?

local_irq_save() does do an irq disable. You're thinking of local_save_flags() which only saves the flags but doesn't disable interrupts.

Quoted 5 lines

o double_rq_lock() acquires the locks with lowest address first. double_rq_unlock() does not release those in the inverse order. Is that a problem?
I'm just nervous since I didn't see the local_irq_disable() in init_idle() which would guarantee both unlock's happen atomically.

No. The deadlock potential comes only from lock acquisition order, not lock release order: nothing can block a lock release from proceeding.

James

#2 lore raw
In reply to Grant Grundler
Quoted 3 lines · Grant Grundler

o double_rq_lock() acquires the locks with lowest address first. double_rq_unlock() does not release those in the inverse order. Is that a problem?

No. You have two possibilities (locks A, B; acquire and release):

1. Aa Ba Ar Br
2. Aa Ba Br Ar

It doesn't matter how you combine them; either you are waiting for A or you have A and are waiting for B. You never have B and are waiting for A. Case 2 is the more common idiom since B is then entirely nested within A, but lock A ranks lock B in both cases, so you're safe.

Signature · 6 lines
"Next the statesmen will invent cheap lies, putting the blame upon 
the nation that is attacked, and every man will be glad of those
conscience-soothing falsities, and will diligently study them, and refuse
to examine any refutations of them; and thus he will by and by convince 
himself that the war is just, and will thank God for the better sleep 
he enjoys after this process of grotesque self-deception." -- Mark Twain