Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 164769
b: refs/heads/master
c: 26562c5
h: refs/heads/master
i:
  164767: ba74105
v: v3
  • Loading branch information
KAMEZAWA Hiroyuki authored and Linus Torvalds committed Sep 23, 2009
1 parent b5c7663 commit fe61b28
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 3 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 3089aa1b0c07fb7c48f9829c619f50198307789d
refs/heads/master: 26562c59fa9111ae3ea7b78045889662aac9e5ac
52 changes: 50 additions & 2 deletions trunk/fs/proc/kcore.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ static void free_kclist_ents(struct list_head *head)
}
}
/*
* Replace all KCORE_RAM information with passed list.
* Replace all KCORE_RAM/KCORE_VMEMMAP information with passed list.
*/
static void __kcore_update_ram(struct list_head *list)
{
Expand All @@ -113,7 +113,8 @@ static void __kcore_update_ram(struct list_head *list)
write_lock(&kclist_lock);
if (kcore_need_update) {
list_for_each_entry_safe(pos, tmp, &kclist_head, list) {
if (pos->type == KCORE_RAM)
if (pos->type == KCORE_RAM
|| pos->type == KCORE_VMEMMAP)
list_move(&pos->list, &garbage);
}
list_splice_tail(list, &kclist_head);
Expand Down Expand Up @@ -151,6 +152,47 @@ static int kcore_update_ram(void)

#else /* !CONFIG_HIGHMEM */

#ifdef CONFIG_SPARSEMEM_VMEMMAP
/* calculate vmemmap's address from given system ram pfn and register it */
int get_sparsemem_vmemmap_info(struct kcore_list *ent, struct list_head *head)
{
unsigned long pfn = __pa(ent->addr) >> PAGE_SHIFT;
unsigned long nr_pages = ent->size >> PAGE_SHIFT;
unsigned long start, end;
struct kcore_list *vmm, *tmp;


start = ((unsigned long)pfn_to_page(pfn)) & PAGE_MASK;
end = ((unsigned long)pfn_to_page(pfn + nr_pages)) - 1;
end = ALIGN(end, PAGE_SIZE);
/* overlap check (because we have to align page */
list_for_each_entry(tmp, head, list) {
if (tmp->type != KCORE_VMEMMAP)
continue;
if (start < tmp->addr + tmp->size)
if (end > tmp->addr)
end = tmp->addr;
}
if (start < end) {
vmm = kmalloc(sizeof(*vmm), GFP_KERNEL);
if (!vmm)
return 0;
vmm->addr = start;
vmm->size = end - start;
vmm->type = KCORE_VMEMMAP;
list_add_tail(&vmm->list, head);
}
return 1;

}
#else
int get_sparsemem_vmemmap_info(struct kcore_list *ent, struct list_head *head)
{
return 1;
}

#endif

static int
kclist_add_private(unsigned long pfn, unsigned long nr_pages, void *arg)
{
Expand Down Expand Up @@ -181,6 +223,12 @@ kclist_add_private(unsigned long pfn, unsigned long nr_pages, void *arg)

ent->type = KCORE_RAM;
list_add_tail(&ent->list, head);

if (!get_sparsemem_vmemmap_info(ent, head)) {
list_del(&ent->list);
goto free_out;
}

return 0;
free_out:
kfree(ent);
Expand Down
1 change: 1 addition & 0 deletions trunk/include/linux/proc_fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ enum kcore_type {
KCORE_TEXT,
KCORE_VMALLOC,
KCORE_RAM,
KCORE_VMEMMAP,
KCORE_OTHER,
};

Expand Down

0 comments on commit fe61b28

Please sign in to comment.