lkml.org 
[lkml]   [2015]   [Apr]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH v3 5/7] tracing: Add 'hist' event trigger command
On Fri, Apr 3, 2015 at 8:51 AM, Tom Zanussi <tom.zanussi@linux.intel.com> wrote:
> +static struct hist_trigger_entry *
> +tracing_map_insert(struct tracing_map *map, void *key)
> +{
> + u32 idx, key_hash, test_key;
> +
> + key_hash = jhash(key, map->key_size, 0);
> + idx = key_hash >> (32 - (map->map_bits + 1));
> +
> + while (1) {
> + idx &= (map->map_size - 1);
> + test_key = map->map[idx].key;
> +
> + if (test_key && test_key == key_hash &&
> + keys_match(key, map->map[idx].val->key, map->key_size))
> + return map->map[idx].val;
> +
> + if (!test_key && !cmpxchg(&map->map[idx].key, 0, key_hash)) {
> + struct hist_trigger_entry *entry;
> +
> + entry = hist_trigger_entry_create(map);
> + if (!entry)
> + break;
> + memcpy(entry->key, key, map->key_size);
> + map->map[idx].val = entry;
> +
> + return map->map[idx].val;
> + }

There is obvious race here, since algorithm is not implemented correctly.
Partially inserted key/value is not handled.


\
 
 \ /
  Last update: 2015-04-04 18:01    [W:0.131 / U:0.076 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site