Changeset e394c196 in mainline


Ignore:
Timestamp:
2018-11-12T20:53:57Z (6 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
705ca2b
Parents:
15639ec
git-author:
Jakub Jermar <jakub@…> (2018-08-28 19:55:29)
git-committer:
Jakub Jermar <jakub@…> (2018-11-12 20:53:57)
Message:

Use a dedicated cache for instances of kobject_t

Location:
kernel/generic
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/include/cap/cap.h

    r15639ec re394c196  
    137137extern void cap_free(struct task *, cap_handle_t);
    138138
     139extern kobject_t *kobject_alloc(unsigned int);
     140extern void kobject_free(kobject_t *);
    139141extern void kobject_initialize(kobject_t *, kobject_type_t, void *,
    140142    kobject_ops_t *);
  • kernel/generic/src/cap/cap.c

    r15639ec re394c196  
    9393
    9494static slab_cache_t *cap_cache;
     95static slab_cache_t *kobject_cache;
    9596
    9697static size_t caps_hash(const ht_link_t *item)
     
    123124        cap_cache = slab_cache_create("cap_t", sizeof(cap_t), 0, NULL,
    124125            NULL, 0);
     126        kobject_cache = slab_cache_create("kobject_t", sizeof(kobject_t), 0,
     127            NULL, NULL, 0);
    125128}
    126129
     
    394397}
    395398
     399kobject_t *kobject_alloc(unsigned int flags)
     400{
     401        return slab_alloc(kobject_cache, flags);
     402}
     403
     404void kobject_free(kobject_t *kobj)
     405{
     406        slab_free(kobject_cache, kobj);
     407}
     408
    396409/** Initialize kernel object
    397410 *
     
    462475        if (atomic_postdec(&kobj->refcnt) == 1) {
    463476                kobj->ops->destroy(kobj->raw);
    464                 free(kobj);
     477                kobject_free(kobj);
    465478        }
    466479}
  • kernel/generic/src/ipc/ipc.c

    r15639ec re394c196  
    120120                return NULL;
    121121
    122         kobject_t *kobj = (kobject_t *) malloc(sizeof(kobject_t));
     122        kobject_t *kobj = kobject_alloc(0);
    123123        if (!kobj) {
    124124                slab_free(call_cache, call);
  • kernel/generic/src/ipc/ipcrsc.c

    r15639ec re394c196  
    7676                        return ENOMEM;
    7777                }
    78                 kobject_t *kobj = malloc(sizeof(kobject_t));
     78                kobject_t *kobj = kobject_alloc(FRAME_ATOMIC);
    7979                if (!kobj) {
    8080                        cap_free(TASK, handle);
  • kernel/generic/src/ipc/irq.c

    r15639ec re394c196  
    356356        }
    357357
    358         kobject_t *kobject = malloc(sizeof(kobject_t));
     358        kobject_t *kobject = kobject_alloc(FRAME_ATOMIC);
    359359        if (!kobject) {
    360360                cap_free(TASK, handle);
  • kernel/generic/src/synch/syswaitq.c

    r15639ec re394c196  
    4545
    4646#include <stdint.h>
    47 #include <stdlib.h>
    4847
    4948static slab_cache_t *waitq_cache;
     
    9695        waitq_initialize(wq);
    9796
    98         kobject_t *kobj = (kobject_t *) malloc(sizeof(kobject_t));
     97        kobject_t *kobj = kobject_alloc(0);
    9998        if (!kobj) {
    10099                slab_free(waitq_cache, wq);
     
    107106        if (rc != EOK) {
    108107                slab_free(waitq_cache, wq);
    109                 free(kobj);
     108                kobject_free(kobj);
    110109                return (sys_errno_t) rc;
    111110        }
     
    114113        if (rc != EOK) {
    115114                cap_free(TASK, handle);
    116                 free(kobj);
     115                kobject_free(kobj);
    117116                slab_free(waitq_cache, wq);
    118117                return (sys_errno_t) rc;
Note: See TracChangeset for help on using the changeset viewer.