lkml.org 
[lkml]   [2001]   [Mar]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC] Large scale kernel performance recording
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/

\
 
 \ /
  Last update: 2005-03-22 13:18    [W:0.332 / U:1.080 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site