1630 * vmalloc - allocate virtually contiguous memory 1631 * @size: allocation size 1632 * Allocate enough pages to cover @size from the page level 1633 * allocator and map them into contiguous kernel virtual space. 1634 * 1635 * For tight control over page level allocator and protection flags 1636 * use __vmalloc() instead. 1637 */
1638 void *vmalloc(unsigned long size) 1639 { 1640 return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL, 1641 -1, __builtin_return_address(0)); 1642 }
1572 /** 1573 * __vmalloc_node - allocate virtually contiguous memory 1574 * @size: allocation size 1575 * @align: desired alignment 1576 * @gfp_mask: flags for the page level allocator 1577 * @prot: protection mask for the allocated pages 1578 * @node: node to use for allocation or -1 1579 * @caller: caller's return address 1580 * 1581 * Allocate enough pages to cover @size from the page level 1582 * allocator with @gfp_mask flags. Map them into contiguous 1583 * kernel virtual space, using a pagetable protection of @prot. 1584 */
1585 static void *__vmalloc_node(unsigned long size, unsigned long align, 1586 gfp_t gfp_mask, pgprot_t prot, 1587 int node, void *caller) 1588 { 1589 struct vm_struct *area; 1590 void *addr; 1591 unsigned long real_size = size; 1592 1593 size = PAGE_ALIGN(size); 1594 if (!size || (size >> PAGE_SHIFT) > totalram_pages) 1595 return NULL; 1596 1597 area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNLIST, 1598 VMALLOC_START, VMALLOC_END, node, 1599 gfp_mask, caller); 1600 1601 if (!area) 1602 return NULL; 1603 1604 addr = __vmalloc_area_node(area, gfp_mask, prot, node, caller); 1605 1606 /* 1607 * In this function, newly allocated vm_struct is not added 1608 * to vmlist at __get_vm_area_node(). so, it is added here. 1609 */ 1610 insert_vmalloc_vmlist(area); 1611 1612 /* 1613 * A ref_count = 3 is needed because the vm_struct and vmap_area 1614 * structures allocated in the __get_vm_area_node() function contain 1615 * references to the virtual address of the vmalloc'ed block. 1616 */ 1617 kmemleak_alloc(addr, real_size, 3, gfp_mask); 1618 1619 return addr; 1620 }
세그먼트 페이지
http://snowwiki.fuzewire.com/wiki/applied_sciences/computer_science/infor_science/read.html?psno=*D30ACDF27AEAFC44D3AF426EF24F0DA54E784B89
|