Re: [RFC] Large scale kernel performance recording

Abramo Bagnara (abramo@alsa-project.org)
Wed, 28 Mar 2001 18:49:59 +0200


Keith Owens wrote:
>
> Sigh. Why do you always spot the typos *after* pressing send?
>
> On Thu, 29 Mar 2001 00:07:02 +1000,
> Keith Owens <kaos@ocs3.ocs-net> wrote:
> > copy_desired_counter_values()
> > {
> > volatile int *p_flag = /* address of flag for desired cpu */;
> > volatile __s64 *p_counter = /* address of counter for desired cpu and instance */;
> > __s64 counter; /* local copy */
> >
> > do {
> > counter = *p_counter;
> > } while (!*p_flag && counter == *p_counter);
> > }
>
> Should be while (*p_flag || counter != *p_counter);

And here you've the race:

kernel: user:
++flag;
wmb();
counter += delta; (first 32 bits)
counter = *p_counter;
counter += delta; (last 32 bits)
wmb();
--flag;
wmb();
... *p_flag test
++flag;
counter += delta; (first 32 bits)
counter == *p_counter test
counter += delta; (last 32 bits)
wmb();
--flag;
wmb();

Improbable but theoretically possible.

-- 
Abramo Bagnara                       mailto:abramo@alsa-project.org

Opera Unica Phone: +39.546.656023 Via Emilia Interna, 140 48014 Castel Bolognese (RA) - Italy

ALSA project is http://www.alsa-project.org sponsored by SuSE Linux http://www.suse.com

It sounds good! - 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/