lkml.org 
[lkml]   [2009]   [Mar]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] futex: Dynamically size futexes hash table

* Eric Dumazet <dada1@cosmosbay.com> wrote:

> @@ -2016,7 +2021,28 @@ static int __init futex_init(void)
> {
> u32 curval;
> int i;
> +#if !defined(CONFIG_BASE_SMALL)
> +#if defined(CONFIG_PROVE_LOCKING)
> + unsigned int nb_slots = 256;
> +#else
> + unsigned int nb_slots = roundup_pow_of_two(num_possible_cpus()) * 256;
> +#endif
> + size_t sz;
>
> +retry:
> + sz = nb_slots * sizeof(struct futex_hash_bucket);
> + if (sz > PAGE_SIZE)
> + futex_queues = vmalloc(sz);
> + else
> + futex_queues = kmalloc(sz, GFP_KERNEL);
> + if (!futex_queues) {
> + nb_slots >>= 1;
> + if (!nb_slots)
> + panic("Could not allocate futex hash table");
> + goto retry;
> + }
> + futex_hash_mask = nb_slots - 1;
> +#endif

no fundamental objections and the hash sizing problem is causing
real problems and need to be fixed, but this code sequence is too
ugly to live.

Is there really no big-hash-alloc framework in existence? I have
some vague memories of networking having met such problems in the
past - maybe they have some goodness there we could reuse
shamelessly in the futex code?

Ingo


\
 
 \ /
  Last update: 2009-03-21 17:31    [W:0.068 / U:2.940 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site