sys_read() from /dev/stdin
[akaros.git] / kern / src / slab.c
index e6d1ab4..aaf080d 100644 (file)
  * controlling bufctl at the top of the slab object.  Fix this with TODO (BUF).
  */
 
+#ifdef __IVY__
+#pragma nodeputy
+#pragma nosharc
+#endif
+
 #include <slab.h>
 #include <stdio.h>
 #include <assert.h>
@@ -30,7 +35,7 @@ static void __kmem_cache_create(struct kmem_cache *kc, const char *name,
 {
        assert(kc);
        assert(align);
-       kc->cache_lock = 0;
+       spinlock_init(&kc->cache_lock);
        kc->name = name;
        kc->obj_size = obj_size;
        kc->align = align;
@@ -60,7 +65,7 @@ static void __kmem_cache_create(struct kmem_cache *kc, const char *name,
 
 void kmem_cache_init(void)
 {
-       kmem_caches_lock = 0;
+       spinlock_init(&kmem_caches_lock);
        SLIST_INIT(&kmem_caches);
        /* We need to call the __ version directly to bootstrap the global
         * kmem_cache_cache. */
@@ -240,9 +245,8 @@ void kmem_cache_grow(struct kmem_cache *cp)
        if (cp->obj_size <= SLAB_LARGE_CUTOFF) {
                // Just get a single page for small slabs
                page_t *a_page;
-               if (page_alloc(&a_page))
-                       panic("[German Accent]: OOM!!!");
-               page_incref(a_page);
+               if (kpage_alloc(&a_page))
+                       panic("[German Accent]: OOM for a small slab growth!!!");
                // the slab struct is stored at the end of the page
                a_slab = (struct kmem_slab*)(page2kva(a_page) + PGSIZE -
                                             sizeof(struct kmem_slab));
@@ -273,6 +277,8 @@ void kmem_cache_grow(struct kmem_cache *cp)
                                           PGSIZE;
                // round up for the contiguous page allocator
                void *buf = get_cont_pages(LOG2_UP(num_pgs), 0);
+               if (!buf)
+                       panic("[German Accent]: OOM for a large slab growth!!!");
                a_slab->num_busy_obj = 0;
                a_slab->num_total_obj = ROUNDUPPWR2(num_pgs)*PGSIZE / a_slab->obj_size;
                TAILQ_INIT(&a_slab->bufctl_freelist);