<kernel v5.0>
mm_init_cpumask()
include/linux/mm_types.h
/* Pointer magic because the dynamic array size confuses some compilers. */
static inline void mm_init_cpumask(struct mm_struct *mm)
{
unsigned long cpu_bitmap = (unsigned long)mm;
cpu_bitmap += offsetof(struct mm_struct, cpu_bitmap);
cpumask_clear((struct cpumask *)cpu_bitmap);
}
cpu mask 비트맵을 cpu 수만큼 비트 clear한다.
cpumask_clear()
include/linux/cpumask.h
/** * cpumask_clear - clear all cpus (< nr_cpu_ids) in a cpumask * @dstp: the cpumask pointer */
static inline void cpumask_clear(struct cpumask *dstp)
{
bitmap_zero(cpumask_bits(dstp), nr_cpumask_bits);
}
nr_cpumask_bits 수 만큼 비트를 dstp->bits를 clear 한다.
CONFIG_CPUMASK_OFFSTACK
config CPUMASK_OFFSTACK
bool "Force CPU masks off stack" if DEBUG_PER_CPU_MAPS
help
Use dynamic allocation for cpumask_var_t, instead of putting
them on the stack. This is a bit more expensive, but avoids
stack overflow.
- CONFIG_CPUMASK_OFFSTACK 커널 옵션을 사용하면 cpu 수가 많은 경우 cpu 수 만큼 비트맵으로 처리되는 cpumask의 크기가 커진다. 이의 처리를 스택을 통해 처리하지 않도록 별도의 메모리를 할당받아 사용하는 방법으로 stack overflow를 피할 수 있다.
참고
- Bitmap Operations | 문c