lkml.org 
[lkml]   [2009]   [May]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH tip 1/1] perf_counter tools: Add locking to perf top
From
Date
On Fri, 2009-05-29 at 17:03 -0300, Arnaldo Carvalho de Melo wrote:
> /* Sort the active symbols */
> - list_for_each_entry_safe(syme, n, &active_symbols, node) {
> - if (syme->count[0] != 0) {
> + pthread_mutex_lock(&active_symbols_lock);
> + syme = list_entry(active_symbols.next, struct sym_entry, node);
> + pthread_mutex_unlock(&active_symbols_lock);
> +
> + list_for_each_entry_safe_from(syme, n, &active_symbols, node) {
> + syme->snap_count = syme->count[0];
> + if (syme->snap_count != 0) {
> + syme->weight = sym_weight(syme);

That looks wrong, you basically do a fancy cast while holding the lock,
then you overwrite the variable doing a list iteration without holding
the lock.

If list_add and list_del are under a lock, the iteration should be too.



\
 
 \ /
  Last update: 2009-05-29 22:33    [W:0.098 / U:0.588 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site