提交 c30bb2a2 编写于 作者: K KAMEZAWA Hiroyuki 提交者: Linus Torvalds

kcore: add kclist types

Presently, kclist_add() only eats start address and size as its arguments.
Considering to make kclist dynamically reconfigulable, it's necessary to
know which kclists are for System RAM and which are not.

This patch add kclist types as
  KCORE_RAM
  KCORE_VMALLOC
  KCORE_TEXT
  KCORE_OTHER

This "type" is used in a patch following this for detecting KCORE_RAM.
Signed-off-by: NKAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: WANG Cong <xiyou.wangcong@gmail.com>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 2ef43ec7
...@@ -639,9 +639,10 @@ mem_init (void) ...@@ -639,9 +639,10 @@ mem_init (void)
high_memory = __va(max_low_pfn * PAGE_SIZE); high_memory = __va(max_low_pfn * PAGE_SIZE);
kclist_add(&kcore_mem, __va(0), max_low_pfn * PAGE_SIZE); kclist_add(&kcore_mem, __va(0), max_low_pfn * PAGE_SIZE, KCORE_RAM);
kclist_add(&kcore_vmem, (void *)VMALLOC_START, VMALLOC_END-VMALLOC_START); kclist_add(&kcore_vmem, (void *)VMALLOC_START,
kclist_add(&kcore_kernel, _stext, _end - _stext); VMALLOC_END-VMALLOC_START, KCORE_VMALLOC);
kclist_add(&kcore_kernel, _stext, _end - _stext, KCORE_TEXT);
for_each_online_pgdat(pgdat) for_each_online_pgdat(pgdat)
if (pgdat->bdata->node_bootmem_map) if (pgdat->bdata->node_bootmem_map)
......
...@@ -409,11 +409,12 @@ void __init mem_init(void) ...@@ -409,11 +409,12 @@ void __init mem_init(void)
if ((unsigned long) &_text > (unsigned long) CKSEG0) if ((unsigned long) &_text > (unsigned long) CKSEG0)
/* The -4 is a hack so that user tools don't have to handle /* The -4 is a hack so that user tools don't have to handle
the overflow. */ the overflow. */
kclist_add(&kcore_kseg0, (void *) CKSEG0, 0x80000000 - 4); kclist_add(&kcore_kseg0, (void *) CKSEG0,
0x80000000 - 4, KCORE_TEXT);
#endif #endif
kclist_add(&kcore_mem, __va(0), max_low_pfn << PAGE_SHIFT); kclist_add(&kcore_mem, __va(0), max_low_pfn << PAGE_SHIFT, KCORE_RAM);
kclist_add(&kcore_vmalloc, (void *)VMALLOC_START, kclist_add(&kcore_vmalloc, (void *)VMALLOC_START,
VMALLOC_END-VMALLOC_START); VMALLOC_END-VMALLOC_START, KCORE_VMALLOC);
printk(KERN_INFO "Memory: %luk/%luk available (%ldk kernel code, " printk(KERN_INFO "Memory: %luk/%luk available (%ldk kernel code, "
"%ldk reserved, %ldk data, %ldk init, %ldk highmem)\n", "%ldk reserved, %ldk data, %ldk init, %ldk highmem)\n",
......
...@@ -268,11 +268,11 @@ static int __init setup_kcore(void) ...@@ -268,11 +268,11 @@ static int __init setup_kcore(void)
size); size);
} }
kclist_add(kcore_mem, __va(base), size); kclist_add(kcore_mem, __va(base), size, KCORE_RAM);
} }
kclist_add(&kcore_vmem, (void *)VMALLOC_START, kclist_add(&kcore_vmem, (void *)VMALLOC_START,
VMALLOC_END-VMALLOC_START); VMALLOC_END-VMALLOC_START, KCORE_VMALLOC);
return 0; return 0;
} }
......
...@@ -128,10 +128,11 @@ static int __init setup_kcore(void) ...@@ -128,10 +128,11 @@ static int __init setup_kcore(void)
if (!kcore_mem) if (!kcore_mem)
panic("%s: kmalloc failed\n", __func__); panic("%s: kmalloc failed\n", __func__);
kclist_add(kcore_mem, __va(base), size); kclist_add(kcore_mem, __va(base), size, KCORE_RAM);
} }
kclist_add(&kcore_vmem, (void *)VMALLOC_START, VMALLOC_END-VMALLOC_START); kclist_add(&kcore_vmem, (void *)VMALLOC_START,
VMALLOC_END-VMALLOC_START, KCORE_VMALLOC);
return 0; return 0;
} }
......
...@@ -226,9 +226,9 @@ void __init mem_init(void) ...@@ -226,9 +226,9 @@ void __init mem_init(void)
datasize = (unsigned long) &_edata - (unsigned long) &_etext; datasize = (unsigned long) &_edata - (unsigned long) &_etext;
initsize = (unsigned long) &__init_end - (unsigned long) &__init_begin; initsize = (unsigned long) &__init_end - (unsigned long) &__init_begin;
kclist_add(&kcore_mem, __va(0), max_low_pfn << PAGE_SHIFT); kclist_add(&kcore_mem, __va(0), max_low_pfn << PAGE_SHIFT, KCORE_RAM);
kclist_add(&kcore_vmalloc, (void *)VMALLOC_START, kclist_add(&kcore_vmalloc, (void *)VMALLOC_START,
VMALLOC_END - VMALLOC_START); VMALLOC_END - VMALLOC_START, KCORE_VMALLOC);
printk(KERN_INFO "Memory: %luk/%luk available (%dk kernel code, " printk(KERN_INFO "Memory: %luk/%luk available (%dk kernel code, "
"%dk data, %dk init)\n", "%dk data, %dk init)\n",
......
...@@ -886,9 +886,9 @@ void __init mem_init(void) ...@@ -886,9 +886,9 @@ void __init mem_init(void)
datasize = (unsigned long) &_edata - (unsigned long) &_etext; datasize = (unsigned long) &_edata - (unsigned long) &_etext;
initsize = (unsigned long) &__init_end - (unsigned long) &__init_begin; initsize = (unsigned long) &__init_end - (unsigned long) &__init_begin;
kclist_add(&kcore_mem, __va(0), max_low_pfn << PAGE_SHIFT); kclist_add(&kcore_mem, __va(0), max_low_pfn << PAGE_SHIFT, KCORE_RAM);
kclist_add(&kcore_vmalloc, (void *)VMALLOC_START, kclist_add(&kcore_vmalloc, (void *)VMALLOC_START,
VMALLOC_END-VMALLOC_START); VMALLOC_END-VMALLOC_START, KCORE_VMALLOC);
printk(KERN_INFO "Memory: %luk/%luk available (%dk kernel code, " printk(KERN_INFO "Memory: %luk/%luk available (%dk kernel code, "
"%dk reserved, %dk data, %dk init, %ldk highmem)\n", "%dk reserved, %dk data, %dk init, %ldk highmem)\n",
......
...@@ -677,13 +677,14 @@ void __init mem_init(void) ...@@ -677,13 +677,14 @@ void __init mem_init(void)
initsize = (unsigned long) &__init_end - (unsigned long) &__init_begin; initsize = (unsigned long) &__init_end - (unsigned long) &__init_begin;
/* Register memory areas for /proc/kcore */ /* Register memory areas for /proc/kcore */
kclist_add(&kcore_mem, __va(0), max_low_pfn << PAGE_SHIFT); kclist_add(&kcore_mem, __va(0), max_low_pfn << PAGE_SHIFT, KCORE_RAM);
kclist_add(&kcore_vmalloc, (void *)VMALLOC_START, kclist_add(&kcore_vmalloc, (void *)VMALLOC_START,
VMALLOC_END-VMALLOC_START); VMALLOC_END-VMALLOC_START, KCORE_VMALLOC);
kclist_add(&kcore_kernel, &_stext, _end - _stext); kclist_add(&kcore_kernel, &_stext, _end - _stext, KCORE_TEXT);
kclist_add(&kcore_modules, (void *)MODULES_VADDR, MODULES_LEN); kclist_add(&kcore_modules, (void *)MODULES_VADDR, MODULES_LEN,
KCORE_OTHER);
kclist_add(&kcore_vsyscall, (void *)VSYSCALL_START, kclist_add(&kcore_vsyscall, (void *)VSYSCALL_START,
VSYSCALL_END - VSYSCALL_START); VSYSCALL_END - VSYSCALL_START, KCORE_OTHER);
printk(KERN_INFO "Memory: %luk/%luk available (%ldk kernel code, " printk(KERN_INFO "Memory: %luk/%luk available (%ldk kernel code, "
"%ldk absent, %ldk reserved, %ldk data, %ldk init)\n", "%ldk absent, %ldk reserved, %ldk data, %ldk init)\n",
......
...@@ -62,10 +62,11 @@ static LIST_HEAD(kclist_head); ...@@ -62,10 +62,11 @@ static LIST_HEAD(kclist_head);
static DEFINE_RWLOCK(kclist_lock); static DEFINE_RWLOCK(kclist_lock);
void void
kclist_add(struct kcore_list *new, void *addr, size_t size) kclist_add(struct kcore_list *new, void *addr, size_t size, int type)
{ {
new->addr = (unsigned long)addr; new->addr = (unsigned long)addr;
new->size = size; new->size = size;
new->type = type;
write_lock(&kclist_lock); write_lock(&kclist_lock);
list_add_tail(&new->list, &kclist_head); list_add_tail(&new->list, &kclist_head);
......
...@@ -78,10 +78,18 @@ struct proc_dir_entry { ...@@ -78,10 +78,18 @@ struct proc_dir_entry {
struct list_head pde_openers; /* who did ->open, but not ->release */ struct list_head pde_openers; /* who did ->open, but not ->release */
}; };
enum kcore_type {
KCORE_TEXT,
KCORE_VMALLOC,
KCORE_RAM,
KCORE_OTHER,
};
struct kcore_list { struct kcore_list {
struct list_head list; struct list_head list;
unsigned long addr; unsigned long addr;
size_t size; size_t size;
int type;
}; };
struct vmcore { struct vmcore {
...@@ -233,11 +241,12 @@ static inline void dup_mm_exe_file(struct mm_struct *oldmm, ...@@ -233,11 +241,12 @@ static inline void dup_mm_exe_file(struct mm_struct *oldmm,
#endif /* CONFIG_PROC_FS */ #endif /* CONFIG_PROC_FS */
#if !defined(CONFIG_PROC_KCORE) #if !defined(CONFIG_PROC_KCORE)
static inline void kclist_add(struct kcore_list *new, void *addr, size_t size) static inline void
kclist_add(struct kcore_list *new, void *addr, size_t size, int type)
{ {
} }
#else #else
extern void kclist_add(struct kcore_list *, void *, size_t); extern void kclist_add(struct kcore_list *, void *, size_t, int type);
#endif #endif
union proc_op { union proc_op {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册