All of lore.kernel.org
 help / color / mirror / Atom feed
* about runqueues locking
@ 2004-02-27 12:23 Vincent Hanquez
  2004-02-27 13:08 ` Zwane Mwaikambo
  0 siblings, 1 reply; 2+ messages in thread
From: Vincent Hanquez @ 2004-02-27 12:23 UTC (permalink / raw)
  To: lkml

[-- Attachment #1: Type: text/plain, Size: 757 bytes --]

	Hi LKML,

I've got a code for 2.4 which do:

================================================================
spin_lock_irqsave(&runqueue_lock, flags)
for_each_process(p)
{
	// modify p attributes
}
spin_unlock_irqrestore(&runqueue_lock, flags)
================================================================

and I need to translate it to 2.6.
What is exactly the best solution since runqueues are per cpu now ?

Is there a way to lock and browse each runqueues ?
or if not, is tasklist_lock can be use to lock all runqueues at once ?

and one another question, what is the difference between
local_irq_disable() and local_irq_save() ?
irq_save push eflags register on the stack, but why for ?

Thanks for any comments.
-- 
Tab

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: about runqueues locking
  2004-02-27 12:23 about runqueues locking Vincent Hanquez
@ 2004-02-27 13:08 ` Zwane Mwaikambo
  0 siblings, 0 replies; 2+ messages in thread
From: Zwane Mwaikambo @ 2004-02-27 13:08 UTC (permalink / raw)
  To: Vincent Hanquez; +Cc: lkml

On Fri, 27 Feb 2004, Vincent Hanquez wrote:

> I've got a code for 2.4 which do:
>
> ================================================================
> spin_lock_irqsave(&runqueue_lock, flags)
> for_each_process(p)
> {
> 	// modify p attributes
> }
> spin_unlock_irqrestore(&runqueue_lock, flags)
> ================================================================
>
> and I need to translate it to 2.6.
> What is exactly the best solution since runqueues are per cpu now ?

runqueue locking is done in ascending order when you want to lock multiple
runqueues, i.e. you have to lock cpu_rq(0) before cpu_rq(1). There are
functions to aid in doing double lock acquisitions, namely
double_rq_lock() which does all the work for you.

> or if not, is tasklist_lock can be use to lock all runqueues at once ?

If you're going to be walking the task list and modifying then you just
need to write_lock the tasklist_lock. Some operations may require you to
lock the task's runqueue, in which case the runqueue lock must be done
within the tasklist_lock.

> and one another question, what is the difference between
> local_irq_disable() and local_irq_save() ?
> irq_save push eflags register on the stack, but why for ?

local_irq_save() is for when you don't know the interrupt enable status
and would like to restore it upon exit of the given per cpu critical
section. local_irq_disable() is normally paired with a local_irq_enable() so it
unconditionally enables interrupts, something you may not always want to
do. If unsure, local_irq_save() is always the safe bet. You may also find
the following of interest;

http://www.kernel.org/pub/linux/kernel/people/rusty/kernel-locking/

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-02-27 13:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-02-27 12:23 about runqueues locking Vincent Hanquez
2004-02-27 13:08 ` Zwane Mwaikambo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.