Changeset a294ad0 in mainline for generic/include/mm/slab.h


Ignore:
Timestamp:
2006-02-02T14:00:32Z (19 years ago)
Author:
Ondrej Palkovsky <ondrap@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
2d43f3e
Parents:
758e065
Message:

Currently not-working SLAB allocator.

  • slightly changed interface to frame_alloc, allow zone preference
File:
1 edited

Legend:

Unmodified
Added
Removed
  • generic/include/mm/slab.h

    r758e065 ra294ad0  
    11/*
    2  * Copyright (C) 2005 Ondrej Palkovsky
     2 * Copyright (C) 2006 Ondrej Palkovsky
    33 * All rights reserved.
    44 *
     
    3939#define SLAB_INSIDE_SIZE   (PAGE_SIZE / 6)
    4040
    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)
    4643
    4744/* slab_reclaim constants */
     
    5552typedef struct {
    5653        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 */
    6057}slab_magazine_t;
    6158
     
    6663        link_t link;
    6764        /* Configuration */
    68         size_t size;
    69         size_t align;
     65        size_t size;      /**< Size of SLAB position - align_up(sizeof(obj)) */
    7066        int (*constructor)(void *obj, int kmflag);
    7167        void (*destructor)(void *obj);
    72         int flags;
     68        int flags;        /**< Flags changing behaviour of cache */
    7369
    7470        /* 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 */
    7773
    7874        /* Statistics */
    7975
    8076        /* 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 */
    8379        /* Magazines  */
    84         link_t magazines;
    85         /* CPU cache */
     80        link_t magazines;      /**< List o full magazines */
     81
     82        /** CPU cache */
    8683        struct {
    8784                slab_magazine_t *current;
     
    9188}slab_cache_t;
    9289
    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;
     90extern 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);
     96extern void slab_cache_destroy(slab_cache_t *cache);
    9997
    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);
     98extern void * slab_alloc(slab_cache_t *cache, int flags);
     99extern void slab_free(slab_cache_t *cache, void *obj);
     100extern count_t slab_reclaim(int flags);
    112101
    113102/** Initialize SLAB subsytem */
    114 void slab_cache_init(void);
     103extern void slab_cache_init(void);
    115104
    116105/* KConsole debug */
    117 void slab_print_list(void);
     106extern void slab_print_list(void);
    118107
    119108#endif
Note: See TracChangeset for help on using the changeset viewer.