if (cachep->flags & SLAB_RECLAIM_ACCOUNT) atomic_sub(1<gfporder, &slab_reclaim_pages); } 该函数释放slab页帧,从线性地址为addr的页帧开始。如果当前进程正在执行内存回收(current->reclaim_state字段不是NULL),reclaim_state->reclaimed_slab加上要释放的页帧数,由页帧回收算法计算在内。此外,如果设置了S...
/* Common flags permitted for kmem_cache_create */ #define SLAB_FLAGS_PERMITTED (SLAB_CORE_FLAGS | \ SLAB_RED_ZONE | \ SLAB_POISON | \ SLAB_STORE_USER | \ SLAB_TRACE | \ SLAB_CONSISTENCY_CHECKS | \ SLAB_MEM_SPREAD | \ SLAB_NOLEAKTRACE | \ SLAB_RECLAIM_ACCOUNT | \ SLAB_TEMPORARY...
/*SLAB_RECLAIM_ACCOUNT表示此slab所占页面为可回收的,当内核检测是否有足够的页面满足用户态的需求时,此类页面将被计算在内,通过调用kmem_freepages()函数可以释放分配给slab的页框。由于是可回收的,所以不需要做后面的碎片检测了*/ if (flags & SLAB_RECLAIM_ACCOUNT) break; /* * Large number of objects i...
s->refcount =1;returns; }//新建一个kmem_cachestaticvoid__initnew_kmalloc_cache(intidx,enumkmalloc_cache_type type,slab_flags_tflags){if(type == KMALLOC_RECLAIM) flags |= SLAB_RECLAIM_ACCOUNT;//根据kmalloc_info中信息建立一个kmem_cachekmalloc_caches[type][idx] =create_kmalloc_cache( kmalloc...
(freelist_idx_t); cachep->flags = flags; cachep->allocflags = __GFP_COMP; if (flags & SLAB_CACHE_DMA) cachep->allocflags |= GFP_DMA; if (flags & SLAB_RECLAIM_ACCOUNT) cachep->allocflags |= __GFP_RECLAIMABLE; // size 表示一个 slab 对象的大小 cachep->size = size; cachep-...
/*SLAB_RECLAIM_ACCOUNT表示此slab所占页面为可回收的,当内核检测是否有足够的页面满足用户态的需求时,此类页面将被计算在内,通过调用kmem_freepages()函数可以释放分配给slab的页框。由于是可回收的,所以不需要做后面的碎片检测了*/ if (flags & SLAB_RECLAIM_ACCOUNT) ...
SLAB_RECLAIM_ACCOUNT | \ SLAB_TEMPORARY | \ SLAB_ACCOUNT) 随后flags &= CACHE_CREATE_MASK初始化 slab_flags_t 标志位: /* Common flags available with current configuration */#defineCACHE_CREATE_MASK (SLAB_CORE_FLAGS | SLAB_DEBUG_FLAGS | SLAB_CACHE_FLAGS) ...
*/ if (flags & SLAB_RECLAIM_ACCOUNT) break; /* * Large number of objects is good, but very large slabs are * currently bad for the gfp()s. */ if (gfporder >= slab_max_order) break; /* * Acceptable internal fragmentation? */ if (left_over * 8 <= (PAGE_SIZE << gfporder)...
/* Common flags permitted for kmem_cache_create */#defineSLAB_FLAGS_PERMITTED(SLAB_CORE_FLAGS|\SLAB_RED_ZONE|\SLAB_POISON|\SLAB_STORE_USER|\SLAB_TRACE|\SLAB_CONSISTENCY_CHECKS|\SLAB_MEM_SPREAD|\SLAB_NOLEAKTRACE|\SLAB_RECLAIM_ACCOUNT|\SLAB_TEMPORARY|\SLAB_ACCOUNT) ...
(cachep->flags & SLAB_RECLAIM_ACCOUNT) mod_lruvec_page_state(page, NR_SLAB_RECLAIMABLE, nr_pages); else mod_lruvec_page_state(page, NR_SLAB_UNRECLAIMABLE, nr_pages); __SetPageSlab(page); /* Record if ALLOC_NO_WATERMARKS was set when allocating the slab */ if (sk_memalloc_socks(...