��谢谢����陌�忙
: �����芏�胤��到��vmalloc���������页(kmalloc)���被������去����������一�������������kmalloc��什么��思�兀� 
�谋�����写�模��铱���������通��vmalloc���������页ms����������去��

��vmalloc���������页(kmalloc)���被������去������话��������坛�峡����模������谋����辖��模��业玫��拇�����实����说�木���vmalloc��kmalloc���������页������swap��去����思��

����凇�vmalloc�牟�����一����通��kmalloc����一���植��山������存”���业玫��拇鸶春�����说�摹�vmalloc�����kmalloc�����������������������亩��蟆保�应����一����思���业������芫���
void * __vmalloc (unsigned long size, int gfp_mask, pgprot_t prot)
{
    void * addr;
    struct vm_struct *area;

    size = PAGE_ALIGN(size);
    if (!size || (size >> PAGE_SHIFT) > num_physpages) {
        BUG();
        return NULL;
    }
������ area = get_vm_area(size, VM_ALLOC);
struct vm_struct * get_vm_area(unsigned long size, unsigned long flags) 
{ 
    unsigned long addr; 
    struct vm_struct **p, *tmp, *area; 
������    area = (struct vm_struct *) kmalloc(sizeof(*area), GFP_KERNEL); 

也����ulk2����说��
The function first calls kmalloc( ) to obtain a memory area for the new descriptor. It then scans the list of descriptors of type struct vm_struct looking for an available range of linear addresses that includes at least size+4096 addresses.
����拇�������2.4�峡����模�������2.6�洗�������同��
void *__vmalloc(unsigned long size, int gfp_mask, pgprot_t prot)
{
��������������
    nr_pages = size >> PAGE_SHIFT;
    array_size = (nr_pages * sizeof(struct page *));

    area->nr_pages = nr_pages;
    /* Please note that the recursion is strictly bounded. */
    if (array_size > PAGE_SIZE)
        pages = __vmalloc(array_size, gfp_mask, PAGE_KERNEL);
    else
        pages = kmalloc(array_size, (gfp_mask & ~__GFP_HIGHMEM));

��������������
}
����understanding the linux virtual memory manager������说��2.6��vmalloc��2.4应�貌�鸩淮���要�化为
vmalloc_area_pages��2.4������map_vm_area(2.6)������2.6������kmalloc��vmalloc��������啥�兀�


���诟叨��存,����些�胤���太�解,������2.4.17����拇��,

fixmap.h������
enum fixed_addresses {
#ifdef CONFIG_X86_LOCAL_APIC
    FIX_APIC_BASE,    /* local (CPU) APIC) -- required for SMP or not */
#endif
#ifdef CONFIG_X86_IO_APIC
    FIX_IO_APIC_BASE_0,
    FIX_IO_APIC_BASE_END = FIX_IO_APIC_BASE_0 + MAX_IO_APICS-1,
#endif
#ifdef CONFIG_X86_VISWS_APIC
    FIX_CO_CPU,    /* Cobalt timer */
    FIX_CO_APIC,    /* Cobalt APIC Redirection Table */ 
    FIX_LI_PCIA,    /* Lithium PCI Bridge A */
    FIX_LI_PCIB,    /* Lithium PCI Bridge B */
#endif
#ifdef CONFIG_HIGHMEM
    FIX_KMAP_BEGIN,    /* reserved pte's for temporary kernel mappings */
    FIX_KMAP_END = FIX_KMAP_BEGIN+(KM_TYPE_NR*NR_CPUS)-1,
#endif
    __end_of_fixed_addresses
};

�约��� include/linux/highmem.h ��没�卸��� CONFIG_HIGHMEM 时, �� 
void *kmap(struct page *page) 
{ return page_address(page); }
#define page_address(page) ((page)->virtual)

���诙�����CONFIG_HIGHMEM 时�定���为:
include/linux/asm_i386/highmem.h
static inline void *kmap(struct page *page)
{
if (in_interrupt())
BUG();
if (page < highmem_start_page) 
return page_address(page);
return kmap_high(page); 
}

通�����������约���understanding the linux virtual memory manager����说��Fixed virtual addresses are needed for subsystems that need to know the virtual address at compile time such as the APIC. FIXADDR TOP is statically defined to be 0xFFFFE000 on the x86 which is one page before the end of the virtual address space.��

������一�����系统没��define APIC�����������诖�也没�谐���896M����也没�卸���CONFIG_HIGHMEM ������么�欠�筒�����fixed_address��
同���欠���������存超��896M����������CONFIG_HIGHMEM��������没�卸���APIC���遣�����时�墓潭�映������也����fixed_address����只��kmap�����兀�

����一�������牵��������苫�vmalloc�芊�映��叨说������诖��耍�����ulk2�����到
In short, allocation of high-memory page frames must be done only through the alloc_pages( ) function and its alloc_page( ) shortcut, which both return the address of the page descriptor of the first allocated page frame. Once allocated, a high-memory page frame has to be mapped into the fourth gigabyte of the linear address space, even though the physical address of the page frame may well exceed 4 GB. 

To do this, the kernel may use three different mechanisms, which are called permanent kernel mappings, temporary kernel mappings, and noncontiguous memory allocation. In this section, we focus on the first two techniques; the third one is discussed in Section 7.3 later in this chapter. 
���������实���vmalloc�遣�����映������叨��诖����诘����械������存,��映�工�������������到�幕��诨���法��alloc_page(s)��实�值模�同��模�ldd����说��叨��诖���������映���没���蹋�high memory tends to be reserved for user-space process pages���������映��也��说������通��alloc_page(s)��实�值陌桑�






�� �� judicious (�薹������) �拇������到: ��
: kmalloc�����目��:




--

�� ��源:��水木���� http://newsmth.net��[FROM: 221.215.0.*]