커널 V. 2.6.32.65

참고 링크

페이지 테이블에 주소 변환 정보가  채워지는 원리  http://www.iamroot.org/xe/Kernel_8_ARM/54103

초보자를 위한 리눅스 커널의 메모리 관리 http://dojeun.egloos.com/317480

 

/linux/vmalloc.h

 27 struct vm_struct {
 28     struct vm_struct    *next;   
 29     void            *addr;
 30     unsigned long       size;
 31     unsigned long       flags;
 32     struct page     **pages;
 33     unsigned int        nr_pages;
 34     unsigned long       phys_addr;
 35     void            *caller;
 36 };

 54 extern void *vmalloc(unsigned long size); 

/usr/src/linux-2.6.32.65/mm/vmalloc.c

 

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

 

'리눅스커널' 카테고리의 다른 글

systemcall  (0) 2015.04.15
스와퍼(Swapper)프로세스  (0) 2015.04.15
schedule()함수  (0) 2015.04.15
프로세스1-3  (0) 2015.04.14
프로세스1-1(프로세스디스크립터, 상태전이)  (0) 2015.04.14

+ Recent posts