lkml.org 
[lkml]   [2016]   [May]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [patch V2 2/7] futex: Hash private futexes per process
On Thu, May 05, 2016 at 08:44:04PM -0000, Thomas Gleixner wrote:
> +struct futex_hash {
> + struct raw_spinlock lock;

raw_spinlock_t ?

> + unsigned int hash_bits;
> + struct futex_hash_bucket *hash;
> +};

> +static void futex_populate_hash(unsigned int hash_bits)
> +{
> + struct mm_struct *mm = current->mm;
> + struct futex_hash_bucket *hb = NULL;
> +
> + /*
> + * We don't need an explicit smp_mb() when the hash is populated
> + * because before we dereference mm->futex_hash.hash_bits in the hash
> + * function we have an smp_mb() in futex_get_key_refs() already.
> + */
> + if (mm->futex_hash.hash)
> + return;
> +
> + /*
> + * If we failed to allocate a hash on the fly, fall back to the global
> + * hash.
> + */
> + hb = futex_alloc_hash(hash_bits);
> + if (!hb)
> + hb = FUTEX_USE_GLOBAL_HASH;
> +
> + raw_spin_lock(&mm->futex_hash.lock);
> + /* We might have raced with another task allocating the hash. */
> + if (!mm->futex_hash.hash) {
> + mm->futex_hash.hash_bits = hash_bits;
> + /*
> + * Ensure that the above is visible before we store
> + * the pointer.
> + */
> + smp_wmb(); /* (A0) Pairs with (B) */
> + mm->futex_hash.hash = hb;

smp_store_release(&mm->futex_hash.hash, hb); ?

> + hb = NULL;
> + }
> + raw_spin_unlock(&mm->futex_hash.lock);
> + kfree(hb);
> +}

\
 
 \ /
  Last update: 2016-05-19 14:41    [W:0.207 / U:0.588 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site