mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-22 18:44:44 +08:00
87400c0475
fs/proc/mmu.c consists of only one function which uses only: 1) struct vmalloc_info * 2) struct vm_struct * 3) struct vmalloc_info 4) vmlist 5) VMALLOC_TOTAL, VMALLOC_START, VMALLOC_END 6) read_lock, read_unlock 7) vmlist_lock 8) struct vm_struct This gives us linux/spinlock.h, asm/pgtable.h, "internal.h", linux/vmalloc.h. asm/pgtable.h uses PKMAP_BASE on i386, for which asm/highmem.h is needed. But, linux/highmem.h is actually used to make it compile everywhere. I'll deal later with this particular i386 surprise. Cross-compile tested on many archs and configs. Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
61 lines
1.4 KiB
C
61 lines
1.4 KiB
C
/* mmu.c: mmu memory info files
|
|
*
|
|
* Copyright (C) 2004 Red Hat, Inc. All Rights Reserved.
|
|
* Written by David Howells (dhowells@redhat.com)
|
|
*
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU General Public License
|
|
* as published by the Free Software Foundation; either version
|
|
* 2 of the License, or (at your option) any later version.
|
|
*/
|
|
#include <linux/spinlock.h>
|
|
#include <linux/vmalloc.h>
|
|
#include <linux/highmem.h>
|
|
#include <asm/pgtable.h>
|
|
#include "internal.h"
|
|
|
|
void get_vmalloc_info(struct vmalloc_info *vmi)
|
|
{
|
|
struct vm_struct *vma;
|
|
unsigned long free_area_size;
|
|
unsigned long prev_end;
|
|
|
|
vmi->used = 0;
|
|
|
|
if (!vmlist) {
|
|
vmi->largest_chunk = VMALLOC_TOTAL;
|
|
}
|
|
else {
|
|
vmi->largest_chunk = 0;
|
|
|
|
prev_end = VMALLOC_START;
|
|
|
|
read_lock(&vmlist_lock);
|
|
|
|
for (vma = vmlist; vma; vma = vma->next) {
|
|
unsigned long addr = (unsigned long) vma->addr;
|
|
|
|
/*
|
|
* Some archs keep another range for modules in vmlist
|
|
*/
|
|
if (addr < VMALLOC_START)
|
|
continue;
|
|
if (addr >= VMALLOC_END)
|
|
break;
|
|
|
|
vmi->used += vma->size;
|
|
|
|
free_area_size = addr - prev_end;
|
|
if (vmi->largest_chunk < free_area_size)
|
|
vmi->largest_chunk = free_area_size;
|
|
|
|
prev_end = vma->size + addr;
|
|
}
|
|
|
|
if (VMALLOC_END - prev_end > vmi->largest_chunk)
|
|
vmi->largest_chunk = VMALLOC_END - prev_end;
|
|
|
|
read_unlock(&vmlist_lock);
|
|
}
|
|
}
|