Re: [PATCH] only irq-safe atomic ops

From: yodaiken@fsmlabs.com
Date: Sat Feb 23 2002 - 17:23:37 EST


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

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sat Feb 23 2002 - 21:00:52 EST