Subversion Repositories HelenOS

Rev

Rev 2927 | Rev 4344 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2927 Rev 3191
Line 51... Line 51...
51
 
51
 
52
/** If object size is less, store control structure inside SLAB */
52
/** If object size is less, store control structure inside SLAB */
53
#define SLAB_INSIDE_SIZE   (PAGE_SIZE >> 3)
53
#define SLAB_INSIDE_SIZE   (PAGE_SIZE >> 3)
54
 
54
 
55
/** Maximum wasted space we allow for cache */
55
/** Maximum wasted space we allow for cache */
-
 
56
#define SLAB_MAX_BADNESS(cache) \
56
#define SLAB_MAX_BADNESS(cache)   (((unsigned int) PAGE_SIZE << (cache)->order) >> 2)
57
    (((unsigned int) PAGE_SIZE << (cache)->order) >> 2)
57
 
58
 
58
/* slab_reclaim constants */
59
/* slab_reclaim constants */
59
 
60
 
60
/** Reclaim all possible memory, because we are in memory stress */
61
/** Reclaim all possible memory, because we are in memory stress */
61
#define SLAB_RECLAIM_ALL  0x1 
62
#define SLAB_RECLAIM_ALL  0x1 
Line 97... Line 98...
97
 
98
 
98
    /** Flags changing behaviour of cache */
99
    /** Flags changing behaviour of cache */
99
    int flags;
100
    int flags;
100
 
101
 
101
    /* Computed values */
102
    /* Computed values */
102
    uint8_t order;              /**< Order of frames to be allocated */
103
    uint8_t order;          /**< Order of frames to be allocated */
103
    unsigned int objects;       /**< Number of objects that fit in */
104
    unsigned int objects;       /**< Number of objects that fit in */
104
 
105
 
105
    /* Statistics */
106
    /* Statistics */
106
    atomic_t allocated_slabs;
107
    atomic_t allocated_slabs;
107
    atomic_t allocated_objs;
108
    atomic_t allocated_objs;
Line 119... Line 120...
119
 
120
 
120
    /** CPU cache */
121
    /** CPU cache */
121
    slab_mag_cache_t *mag_cache;
122
    slab_mag_cache_t *mag_cache;
122
} slab_cache_t;
123
} slab_cache_t;
123
 
124
 
124
extern slab_cache_t * slab_cache_create(char *name, size_t size, size_t align,
125
extern slab_cache_t *slab_cache_create(char *, size_t, size_t,
125
    int (*constructor)(void *obj, int kmflag), int (*destructor)(void *obj),
126
    int (*)(void *, int), int (*)(void *), int);
126
    int flags);
-
 
127
extern void slab_cache_destroy(slab_cache_t *cache);
127
extern void slab_cache_destroy(slab_cache_t *);
128
 
128
 
129
extern void * slab_alloc(slab_cache_t *cache, int flags);
129
extern void * slab_alloc(slab_cache_t *, int);
130
extern void slab_free(slab_cache_t *cache, void *obj);
130
extern void slab_free(slab_cache_t *, void *);
131
extern count_t slab_reclaim(int flags);
131
extern count_t slab_reclaim(int);
132
 
132
 
133
/* slab subsytem initialization */
133
/* slab subsytem initialization */
134
extern void slab_cache_init(void);
134
extern void slab_cache_init(void);
135
extern void slab_enable_cpucache(void);
135
extern void slab_enable_cpucache(void);
136
 
136
 
137
/* kconsole debug */
137
/* kconsole debug */
138
extern void slab_print_list(void);
138
extern void slab_print_list(void);
139
 
139
 
140
/* malloc support */
140
/* malloc support */
141
extern void * malloc(unsigned int size, int flags);
141
extern void *malloc(unsigned int, int);
142
extern void * realloc(void *ptr, unsigned int size, int flags);
142
extern void *realloc(void *, unsigned int, int);
143
extern void free(void *ptr);
143
extern void free(void *);
144
#endif
144
#endif
145
 
145
 
146
/** @}
146
/** @}
147
 */
147
 */