Changeset a294ad0 in mainline for generic/include/mm/slab.h
- Timestamp:
- 2006-02-02T14:00:32Z (19 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 2d43f3e
- Parents:
- 758e065
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
generic/include/mm/slab.h
r758e065 ra294ad0 1 1 /* 2 * Copyright (C) 200 5Ondrej Palkovsky2 * Copyright (C) 2006 Ondrej Palkovsky 3 3 * All rights reserved. 4 4 * … … 39 39 #define SLAB_INSIDE_SIZE (PAGE_SIZE / 6) 40 40 41 /* slab_alloc constants */ 42 #define SLAB_ATOMIC 0x1 /**< Do not sleep when no free memory, 43 may return NULL */ 44 #define SLAB_NO_RECLAIM 0x2 /**< Do not try to call slab_reclaim, if no 45 free memory is found - avoid deadlock */ 41 /** Maximum wasted space we allow for cache */ 42 #define SLAB_MAX_BADNESS(cache) ((PAGE_SIZE << (cache)->order) / 4) 46 43 47 44 /* slab_reclaim constants */ … … 55 52 typedef struct { 56 53 link_t link; 57 count_t busy; 58 count_t size; 59 void *objs[0]; 54 count_t busy; /**< Count of full slots in magazine */ 55 count_t size; /**< Number of slots in magazine */ 56 void *objs[0]; /**< Slots in magazine */ 60 57 }slab_magazine_t; 61 58 … … 66 63 link_t link; 67 64 /* Configuration */ 68 size_t size; 69 size_t align; 65 size_t size; /**< Size of SLAB position - align_up(sizeof(obj)) */ 70 66 int (*constructor)(void *obj, int kmflag); 71 67 void (*destructor)(void *obj); 72 int flags; 68 int flags; /**< Flags changing behaviour of cache */ 73 69 74 70 /* Computed values */ 75 int pages;76 int objects; 71 __u8 order; /**< Order of frames to be allocated */ 72 int objects; /**< Number of objects that fit in */ 77 73 78 74 /* Statistics */ 79 75 80 76 /* Slabs */ 81 link_t full_slabs; 82 link_t partial_slabs; 77 link_t full_slabs; /**< List of full slabs */ 78 link_t partial_slabs; /**< List of partial slabs */ 83 79 /* Magazines */ 84 link_t magazines; 85 /* CPU cache */ 80 link_t magazines; /**< List o full magazines */ 81 82 /** CPU cache */ 86 83 struct { 87 84 slab_magazine_t *current; … … 91 88 }slab_cache_t; 92 89 93 typedef struct { 94 slab_cache_t *cache; /**< Pointer to parent cache */ 95 void *start; /**< Start address of first available item */ 96 count_t available; /**< Count of available items in this slab */ 97 index_t nextavail; /**< The index of next available item */ 98 }slab_slab_t; 90 extern slab_cache_t * slab_cache_create(char *name, 91 size_t size, 92 size_t align, 93 int (*constructor)(void *obj, int kmflag), 94 void (*destructor)(void *obj), 95 int flags); 96 extern void slab_cache_destroy(slab_cache_t *cache); 99 97 100 101 slab_cache_t * slab_cache_create(char *name, 102 size_t size, 103 size_t align, 104 int (*constructor)(void *obj, int kmflag), 105 void (*destructor)(void *obj), 106 int flags); 107 void slab_cache_destroy(slab_cache_t *cache); 108 109 void * slab_alloc(slab_cache_t *cache, int flags); 110 void slab_free(slab_cache_t *cache, void *obj); 111 count_t slab_reclaim(int flags); 98 extern void * slab_alloc(slab_cache_t *cache, int flags); 99 extern void slab_free(slab_cache_t *cache, void *obj); 100 extern count_t slab_reclaim(int flags); 112 101 113 102 /** Initialize SLAB subsytem */ 114 void slab_cache_init(void);103 extern void slab_cache_init(void); 115 104 116 105 /* KConsole debug */ 117 void slab_print_list(void);106 extern void slab_print_list(void); 118 107 119 108 #endif
Note:
See TracChangeset
for help on using the changeset viewer.