- 论坛徽章:
- 9
|
回复 2# nswcfd
谢谢!
我在做 SLUB 分配器初始化的时候,需要从 Percpu 分配器内分配内存.
经测试之后只有 percpu-km.c 里面的代码可以完成 SLUB 的初始化, percpu-vm.c 的分配依赖于 SLUB 分配器.
所以在 SLUB 期间我使用的是 percpu-km.c
我看来 percpu-km.c 的代码中有讲这些函数用在 nommu 的体系中,但我的代码是基于 MMU 去实现的.
这里有点纠结不懂,既然我的 MMU 代码只有使用 percpu-km.c 才能对 SLUB 初始化,但源码中又那么说,不知道我使用 percpu-km.c 可不可以?
/*
* mm/percpu-km.c - kernel memory based chunk allocation
*
* Copyright (C) 2010 SUSE Linux Products GmbH
* Copyright (C) 2010 Tejun Heo <tj@kernel.org>
*
* This file is released under the GPLv2.
*
* Chunks are allocated as a contiguous kernel memory using gfp
* allocation. This is to be used on nommu architectures.
*
* To use percpu-km,
*
* - define CONFIG_NEED_PER_CPU_KM from the arch Kconfig.
*
* - CONFIG_NEED_PER_CPU_PAGE_FIRST_CHUNK must not be defined. It's
* not compatible with PER_CPU_KM. EMBED_FIRST_CHUNK should work
* fine.
*
* - NUMA is not supported. When setting up the first chunk,
* @cpu_distance_fn should be NULL or report all CPUs to be nearer
* than or at LOCAL_DISTANCE.
*
* - It's best if the chunk size is power of two multiple of
* PAGE_SIZE. Because each chunk is allocated as a contiguous
* kernel memory block using alloc_pages(), memory will be wasted if
* chunk size is not aligned. percpu-km code will whine about it.
*/
|
|