From: Zwane Mwaikambo <zwane@linuxpower.ca>
To: Vincent Hanquez <tab@snarc.org>
Cc: lkml <linux-kernel@vger.kernel.org>
Subject: Re: about runqueues locking
Date: Fri, 27 Feb 2004 08:08:37 -0500 (EST) [thread overview]
Message-ID: <Pine.LNX.4.58.0402270749010.17504@montezuma.fsmlabs.com> (raw)
In-Reply-To: <20040227122311.GA28181@snarc.org>
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/
prev parent reply other threads:[~2004-02-27 13:08 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-02-27 12:23 Vincent Hanquez
2004-02-27 13:08 ` Zwane Mwaikambo [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Pine.LNX.4.58.0402270749010.17504@montezuma.fsmlabs.com \
--to=zwane@linuxpower.ca \
--cc=linux-kernel@vger.kernel.org \
--cc=tab@snarc.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®