缥缈峰一座01号

梁二伯的窝

  DonewsBlog  |  Donews首页  |  Donews社区  |  Donews邮箱  |  我的首页  |  联系作者  |  聚合   |  登录
  86篇文章 :: 0篇收藏:: 27篇评论:: 0个Trackbacks

公告

Equality && Free

文章

收藏

相册

存档


正在读取评论……


linux的cache分为两类:通用cache(cache_sizes)和专用cache (cache_cache)
    两类cache的很多函数都是共用的。
    cache相关的数据结构:
1.cache_cache (mm/slab.c)
        674 /* internal cache of cache description objs */
        675 static struct kmem_cache cache_cache = {
        676     .batchcount = 1,
        677     .limit = BOOT_CPUCACHE_ENTRIES,
        678     .shared = 1,
        679     .buffer_size = sizeof(struct kmem_cache),
        680     .name = "kmem_cache",
        681 #if DEBUG  682     .obj_size = sizeof(struct kmem_cache),
        683 #endif
        684 };

2.kmem_cache (mm/slab.c)
        381 struct kmem_cache {
        382 /* 1) per-cpu data, touched during every alloc/free */
        383     struct array_cache *array[NR_CPUS];
        384 /* 2) Cache tunables. Protected by cache_chain_mutex */
        385     unsigned int batchcount;
        386     unsigned int limit;
        387     unsigned int shared;
        388
        389     unsigned int buffer_size;
        390     u32 reciprocal_buffer_size;
        391 /* 3) touched by every alloc & free from the backend */
        392     struct kmem_list3 *nodelists[MAX_NUMNODES]; //维护着free,full,patrial三个slab队列
        393
        394     unsigned int flags;     /* constant flags */
        //在初始化的时候计算出来,每个slab包含的对象个数
        395     unsigned int num;       /* # of objs per slab */
        396
        397 /* 4) cache_grow/shrink */
        398     /* order of pgs per slab (2^n) */
        399     unsigned int gfporder; //每个slab需要的页面数(2的n次方)
        400
        401     /* force GFP flags, e.g. GFP_DMA */
        402     gfp_t gfpflags;
        403//关于colour和colour_off我会专门撰文讲解
        404     size_t colour;          /* cache colouring range */
        405     unsigned int colour_off;    /* colour offset */
        406     struct kmem_cache *slabp_cache; //如果slab结构指针(分开存储时候)
        407     unsigned int slab_size; //kmem_bufctl_t数组和slab的大小   
        408     unsigned int dflags;        /* dynamic flags */
        409
        410     /* 构造函数 */
        411     void (*ctor) (void *, struct kmem_cache *, unsigned long);
        412
        413     /* 析构函数 */
        414     void (*dtor) (void *, struct kmem_cache *, unsigned long);
        415
        416 /* 5) cache creation/removal */
        417     const char *name; //该cache出现在proc中的名字
        418     struct list_head next;
        447 };


Trackback: http://tb.donews.net/TrackBack.aspx?PostId=1177943


[点击此处收藏本文]  发表于2007年06月20日 11:46 PM




正在读取评论……

发表评论

大名:
网址:
验证码
评论