Re: [PATCH] only irq-safe atomic ops

yodaiken
2002-02-23T22:25:33Z

On Sat, Feb 23, 2002 at 02:10:25PM -0800, Andrew Morton wrote:
> Roman Zippel wrote:
> >
> > Hi,
> >
> > yodaiken@fsmlabs.com wrote:
> >
> > > Right. Without preemption it is safe to do
> > > c = smp_get_cpuid();
> > > ...
> > > x = ++local_cache[c]
> > > ..
> > >
> > > y = ++different_local_cache[c];
> > > ..
> >
> > Just add:
> > smp_put_cpuid();
> >
> > Is that so much worse?
> >
>
> ooh. me likee.

Cool.
Me likee code with unmatched smp_get_cpuid/smp_put_cpuid.
Much nicer to write
x = ++local_cache[smp_getcpuid()];
smp_put_cuid();
than boring old
x = ++ local_cache[c];

Is this part of some scheme to make the GPL support model actually
pay?

c = smp_get_cpuid(); // disables preemption

...
f(); // oops, me forgotee, this function also references cpuid
..
x = ++local_cache[c]; // live dangerously
smp_put_cpuid(); // G_d knows what that does now.

Oh, wait, I know - reference counts for get_cpuid! How hard can that
be? See how simple it is? One simple step at a time.

--
---------------------------------------------------------
Victor Yodaiken
Finite State Machine Labs: The RTLinux Company.
www.fsmlabs.com www.rtlinux.com