From: Robert Love <rml@tech9.net>
To: Ravikiran G Thirumalai <kiran@in.ibm.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [patch] get/put_cpu in up need not disable preemption
Date: 09 Nov 2002 13:53:52 -0500 [thread overview]
Message-ID: <1036868033.760.6996.camel@phantasy> (raw)
In-Reply-To: <20021109153634.M2298@in.ibm.com>
On Sat, 2002-11-09 at 05:06, Ravikiran G Thirumalai wrote:
> AFAICS, get_cpu, put_cpu and put_cpu_no_resched need not disable
> preemption on a uniprocessor. Foll patch removes the disable/enable
> premeption stuff for the UP case. Tested on a PIII 4 way for both
> UP and SMP configs. Pls apply.
No, it needs to.
Per-CPU data can alleviate the need for a lock. On SMP, a per-CPU
variable does not need a lock since it is impossible for another task to
enter the same critical section and access the same variable, from
another CPU. On preempt it is fully possible.
For example, this is a critical section, and you do not want two threads
on the same CPU concurrently inside:
extern struct my_struct[NR_CPUS];
int cpu = get_cpu();
do_stuff(my_struct[cpu]);
do_more_stuff(my_struct[cpu]);
foo = my_struct[cpu].bar;
put_cpu();
So get_cpu() must disable preemption even on UP. The problem you are
thinking of (being preempted and returning on a different CPU) is only a
subset of the issues. All processor accesses must be atomic.
Robert Love
prev parent reply other threads:[~2002-11-09 18:47 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-11-09 10:06 [patch] get/put_cpu in up need not disable preemption Ravikiran G Thirumalai
2002-11-09 18:53 ` Robert Love [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=1036868033.760.6996.camel@phantasy \
--to=rml@tech9.net \
--cc=kiran@in.ibm.com \
--cc=linux-kernel@vger.kernel.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