//desc_struct 是内核的描述段的结构体
struct gdt_page {
struct desc_struct gdt[GDT_ENTRIES];
} __attribute__((aligned(PAGE_SIZE)));
#ifdef CONFIG_SMP
#define PER_CPU_BASE_SECTION ".data.percpu"
#else
#define PER_CPU_BASE_SECTION ".data"
#endif
#define __PCPU_ATTRS(sec)\
__attribute__((section(PER_CPU_BASE_SECTION sec))) \
PER_CPU_ATTRIBUTES
#define DECLARE_PER_CPU_SECTION(type, name, sec)\
extern __PCPU_ATTRS(sec) __typeof__(type) per_cpu__##name
#define DEFINE_PER_CPU_SECTION(type, name, sec) \
__PCPU_ATTRS(sec) PER_CPU_DEF_ATTRIBUTES \
__typeof__(type) per_cpu__##name
#define DEFINE_PER_CPU_PAGE_ALIGNED(type, name) \
DEFINE_PER_CPU_SECTION(type, name, ".page_aligned") \
__aligned(PAGE_SIZE)
//common.c line 87
DEFINE_PER_CPU_PAGE_ALIGNED
//这里定义了每个cpu的gdt_page
DEFINE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page) = { .gdt = {
}
};
EXPORT_PER_CPU_SYMBOL_GPL(gdt_page);
gdt_page是一个per cpu变量
switch_to_new_gdt