cache_flusharray释放一个batchcount的内存片段到node的链表上。 static void cache_flusharray(struct kmem_cache *cachep, struct array_cache *ac) { int batchcount; struct kmem_cache_node *n; int node = numa_mem_id(); LIST_HEAD(list); batchcount = ac->batchcount; check_irq_off(); n =...
unsignedintpage_shift,intnode){constgfp_t nested_gfp=(gfp_mask&GFP_RECLAIM_MASK)|__GFP_ZERO;unsignedlongaddr=(unsignedlong)area->addr;unsignedlongsize=get_vm_area_size(area);///计算vm_struct包含多少个页面unsignedlongarray_size;unsignedintnr_small_pages=size>>PAGE_SHIFT;unsignedintpage_order;...
void __init setup_kmalloc_cache_index_table(void) { ... for (i = 8; i < KMALLOC_MIN_SIZE; i += 8) { unsigned int elem = size_index_elem(i); if (elem >= ARRAY_SIZE(size_index)) break; size_index[elem] = KMALLOC_SHIFT_LOW; } ... } 结论:通过以上我们可以得出结论,在ARM...
4. 为cache_cache.array[]和malloc_sizes[INDEX_AC].cs_cachep->array[]重新分配空间。 5. 为cache_cache.nodelists[]、malloc_sizes[INDEX_AC].cs_cachep-> nodelists[]和malloc_sizes[INDEX_L3].cs_cachep-> nodelists[]重新分配空间。 通用cache的名字和对象大小用两个数组来记录:malloc_sizes[]和ca...
然后有一个很重要的点就是,如果你读过 mm/slab.c 的源代码,你就会发现,在建立 struct array_cache 的管理结构头和为 kmalloc() 各个管理结构头的 struct array_cache 的时候,内核使用的是 struct arraycache_init 而不是 struct array_cache,这究竟是怎么一回事?其实这是很有讲究的,且听我慢慢到来。
___cache_alloc(cachep, flags); 它是一个统一的接口 (有检测numa和uma,linux默认是uma除非指定了numa) 点击(此处)折叠或打开 static inline void*___cache_alloc(struct kmem_cache*cachep,gfp_t flags) { void*objp; struct array_cache*ac;
struct stub32 *array32[SIZE] = {NULL}; struct stub40 *array40[SIZE] = {NULL}; %} function alloc_test() %{ int i; for (i = 0; i < SIZE; i ++) { array32[i] = kmalloc(sizeof(struct stub32), GFP_KERNEL); printk("32bytes [%d]:%p ", i, array32[i]); ...
array_size= (nr_pages *sizeof(structpage *)); area->nr_pages =nr_pages;/*Please note that the recursion is strictly bounded.*/if(array_size >PAGE_SIZE) { pages= __vmalloc_node(array_size,1, nested_gfp|__GFP_HIGHMEM, PAGE_KERNEL, node, area->caller); ...
/* Kmalloc array is now usable */ slab_state=UP; Expand DownExpand Up@@ -976,7 +1015,7 @@ void *__do_kmalloc_node(size_t size, gfp_t flags, int node, unsigned long caller returnret; } s=kmalloc_slab(size,flags); s=kmalloc_slab(size,flags,caller); ...
#endif/* Kmalloc array is now usable */ slab_state = UP; @@ -976,7 +1015,7 @@ void *__do_kmalloc_node(size_t size, gfp_t flags, int node, unsigned long caller return ret; }s = kmalloc_slab(size, flags); s = kmalloc_slab(size, flags, caller);if...