++static kmem_cache_t * dynlock_cachep = NULL;
++
++void __init dynlock_cache_init(void)
++{
++ printk(KERN_INFO "init dynlocks cache\n");
++ dynlock_cachep = kmem_cache_create("dynlock_cache",
++ sizeof(struct dynlock_member),
++ 0,
++ SLAB_HWCACHE_ALIGN,
++ NULL, NULL);
++ if (dynlock_cachep == NULL)
++ panic("Can't create dynlock cache");
++}
++
++static void dynlock_check_consistency(struct dynlock *dl)
++{
++ struct dynlock_member *hl;
++ struct list_head *cur;
++ int num = 0;
++
++ spin_lock(&dl->dl_list_lock);
++ BUG_ON(dl == NULL);
++ BUG_ON(dl->dl_magic != DYNLOCK_LIST_MAGIC);
++ BUG_ON(dl->dl_back != dl);
++ list_for_each(cur, &dl->dl_list) {
++ BUG_ON(cur->next == NULL);
++ BUG_ON(cur->prev == NULL);
++ hl = list_entry(cur, struct dynlock_member, dl_list);
++ if (hl->dl_magic != DYNLOCK_MAGIC || hl->dl_head != dl) {
++ printk("corrupted lock 0x%p/%d: magic 0x%x (!=0x%x)\n",
++ hl, num, hl->dl_magic, DYNLOCK_MAGIC);
++ printk(" value 0x%lx, %d readers, %d writers, pid %d, %d refs\n",
++ hl->dl_value, hl->dl_readers, hl->dl_writers,
++ hl->dl_pid, hl->dl_refcount);
++ printk(" head 0x%p\n", hl->dl_head);
++ BUG();
++ }
++ num++;
++ }
++ BUG_ON(num != dl->dl_locks);
++ spin_unlock(&dl->dl_list_lock);
++}
++