On Mon, 2014-09-15 at 14:18 +0200, Thomas Graf wrote: > +static int alloc_bucket_locks(struct rhashtable *ht, struct bucket_table > *tbl) > +{ > + unsigned int i, size; > +#if defined(CONFIG_PROVE_LOCKING) > + unsigned int nr_pcpus = 2; > +#else > + unsigned int nr_pcpus = num_possible_cpus(); > +#endif > + > + nr_pcpus = min_t(unsigned int, nr_pcpus, 32UL); > + size = nr_pcpus * ht->p.locks_mul; > +
You need to roundup to next power of two. > + if (sizeof(spinlock_t) != 0) { > +#ifdef CONFIG_NUMA > + if (size * sizeof(spinlock_t) > PAGE_SIZE) > + tbl->locks = vmalloc(size * sizeof(spinlock_t)); > + else > +#endif > + tbl->locks = kmalloc_array(size, sizeof(spinlock_t), > + GFP_KERNEL); > + if (!tbl->locks) > + return -ENOMEM; > + for (i = 0; i < size; i++) > + spin_lock_init(&tbl->locks[i]); > + } > + tbl->locks_mask = size - 1; > + > + return 0; > +} -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/