Example #1
0
/* get a request from request queue */
struct request * rq_get_fn(struct request_queue *rq)
{
    struct request *req = NULL;
    struct list_head *item = NULL;

    if(list_get_del(&rq->queue_head, &item) != 0)
    {
        return NULL;
    }

    req = list_entry(item, struct request, queuelist);

    return req;
}
Example #2
0
int buddy_list_del(struct list_head *head, const int order, struct list_head **item)
{
    if(head == NULL || order >= NR_MEM_LISTS || item == NULL)
    {
        return -1;
    }

    if(list_get_del(head, item) != 0)
    {
        return -2;
    }

    --buddy_list[order].nr_free_pages;
    return 0;
}
Example #3
0
static struct slab * kmem_get_slab(kmem_cache_t *cachep)
{
    if(cachep == NULL)
    {
        return NULL;
    }

    struct slab *slabp = NULL;
    struct kmem_list *lists = NULL;
    struct list_head *head = NULL, *item = NULL, *pos = NULL;

    lists = &(cachep->kmem_lists);

    /* first find the partial slab*/
    head = &(lists->partial);
    if(list_empty_careful(head))
    {
        head = &(lists->free);
        if(list_empty_careful(head))
        {
            return NULL;
        }
        else
        {
            if(list_get_del(head, &item) != 0)
            {
                return NULL;
            }
            list_add(item, &(cachep->kmem_lists.partial));
        }
    }

    head = &(lists->partial);
    if(list_get(head, &pos) != 0)
    {
        return NULL;
    }

    slabp = list_entry(pos, struct slab, list);
    return slabp;
}