Linux vmallocµÄʵÏÖ
Äں˰汾:2.6.28
linuxÈçºÎÀûÓûï°éϵͳ,slab·ÖÅäÆ÷·ÖÅäÄÚ´æ,ÓÃÕâЩ·½·¨µÃµ½µÄÄÚ´æÔÚÎïÀíµØÖ·É϶¼ÊÇÁ¬ÐøµÄ, È»¶ø,ÓÐЩʱºò,ÿ´ÎÇëÇóÄÚ´æʱ,ϵͳ¶¼·ÖÅäÎïÀíµØÖ·Á¬ÐøµÄÄÚ´æ¿éÊDz»ºÏÊʵÄ,¿ÉÒÔÀûÓÃС¿éÄÚ´æ“Á¬½Ó”³É´ó¿é¿ÉʹÓõÄÄÚ´æ.ÕâÔÚ²Ù×÷ϵͳÉè¼ÆÖÐÒ²±»³ÆΪ “ÄÚ´æÆ´½Ó”,ÏÔÈ»,ÄÚ´æÆ´½ÓÔÚÐèÒª½Ï´óÄÚ´æ,¶øÄÚ´æ·ÃÎÊÏà±È֮ϲ»ÊǺÜƵ·±µÄÇé¿öÏÂÊDZȽÏÓÐЧµÄ.
¡¡¡¡ÔÚlinuxÄÚºËÖÐÓÃÀ´¹ÜÀíÄÚ´æÆ´½ÓµÄ½Ó¿ÚÊÇvmalloc/vfree.ÓÃvmalloc·ÖÅäµÃµ½µÄÄÚ´æÔÚÏßÐÔµØÖ·ÊÇƽ»¬µÄ,µ«ÊÇÎïÀíµØÖ·ÉÏÊÇ·ÇÁ¬ÐøµÄ.
º¯ÊývmallocÁгöÈçÏÂ:(mm/vmalloc.c)
size: ·ÖÅäµÄÐéÄâ¿Õ¼äµÄ´óС.
gfp_mask: Ò³¼¶·ÖÅäÆ÷µÄ±êÖ¾.
prot: ÒÑ·ÖÅäµÄ±£»¤ÑÚÂë.
void *__vmalloc(unsigned long size, gfp_t gfp_mask, pgprot_t prot)
{
return __vmalloc_node(size, gfp_mask, prot, -1,
__builtin_return_address(0));
}
º¯Êý_vmalloc·ÖÅä×ã¹»µÄÒ³ÊýÓësizeÏàÅä,°ÑËüÃÇÓ³Éä½øÁ¬ÐøµÄÄÚºËÐéÄâ¿Õ¼ä,µ«·ÖÅäµÄÄÚ´æ¿é²»Ò»¶¨Á¬Ðø.ÔÚº¯ÊýÖеÚÒ»²½ÊÇÔÚvmlistÖÐÑ°ÕÒµ½Ò»¸ö´óСºÏÊʵÄÐéÄâÄÚ´æ¿é(_get_vm_area_node(...)).
static void *__vmalloc_node(unsigned long size, gfp_t gfp_mask, pgprot_t prot,
int node, void *caller)
{
struct vm_struct *area;
//¼ì²éÇëÇó·ÖÅäµÄÄÚ´æ´óСÓÐûÓг¬¹ý×î´óµÄÎïÀíÒ³ÃæÊý¡£Èç¹û³¬¹ý·µ»Ø 0 £¬±íʾ·ÖÅäʧ°Ü¡£
size = PAGE_ALIGN(size);
//ÓÐЧÐÔ¼ì²é
if (!size || (size >> PAGE_SHIFT) > num_physpages)
return NULL;
//È¡µÃÒ»¸öÓÐЧµÄvma
area = __get_vm_area_node(size, VM_ALLOC, VMALLOC_START, VMALLOC_END,
node, gfp_mask, caller);
//Èç¹ûÉêÇëµÄÎÞЧ£¬·µ»ØÒ»¸öNULLÖ¸Õë
&nb
Ïà¹ØÎĵµ£º
Ò»¡¢ÏÂÔØ°²×°³ÌÐò
1¡¢ ÏÂÔØÄÚºËÔ´Â루linux-2.6.33.tar.bz2£©£¬Î»Öãºhttps://www.kernel.org
2¡¢ ÏÂÔØ×îаæµÄmodule-init-tools£¨module-init-tools-3.8.tar.bz2£©ºÍmodutils£¨modutils-2.4.26-1.src.rpm£©µÄÔ´Âë
λÖãºhttp://www.kernel.org/pub/linux/kernel/people/rusty/modules/
λÖãºhttp://www. ......
ÏÈÓÃwhoÃüÁî²é¿´ËùÓеǽÖÕ¶Ë
#who -uH
Êä³öÈçÏ£º
NAME LINE TIME IDLE PID COMMENT
root :0 2010-03-01 19:13 ? & ......
-----------------------------
Based on Fedora 8 version:
-----------------------------
1. No common command like ifconfig in os?
Root cause is the standard search path not include /sbin and /usr/sbin. Try to include them in /etc/profile. As belows:
#Kenny add /sbin and /usr/sbin here.
&n ......
°²×°£¬Éý¼¶ºÍжÔØÓ¦ÓÃÈí¼þÊÇÓ°ÏìÓû§¶Ô²Ù×÷ϵͳÆÀ¼ÛµÄ¾ö¶¨ÐÔÒòËØÖ®Ò»¡£¶ÔÓÚÈÕ½¥Á÷ÐÐµÄ GNU/Linux ²Ù×÷ϵͳ£¬ÓµÓмò½àÇ¿´óµÄÈí¼þ°ü¹ÜÀí»úÖƹ¦²»¿Éû¡£±¾ÎÄ´Ó»ù±¾µÄ rpm/dpkg ÃüÁîÐгö·¢£¬ÒÔ RHEL ºÍ UBUNTU ΪÀý£¬½éÉܵäÐÍ Linux ϵͳÖÐÓ¦ÓÃÈí¼þµÄ¹ÜÀíºÍʹÓá£
RPM/DPKG Á½´óÕóÓª¼ò½é
ÔÚ GNU/Linux( ÒÔϼò³Æ Linux) ²Ù×÷Ï ......
ÔÚÀàunix
²Ù×÷ϵͳ
ÖУ¬Çý¶¯
¼ÓÔØ
·½Ê½Ò»°ã·ÖΪ£º¶¯Ì¬¼ÓÔغ;²Ì¬¼ÓÔØ£¬ÏÂÃæ·Ö±ð¶ÔÆäÏêϸÂÛÊö¡£
Ò»¡¢¶¯Ì¬¼ÓÔØ
¶¯Ì¬¼ÓÔØÊǽ«Çý¶¯Ä£¿é¼ÓÔص½ÄÚºË
ÖУ¬¶ø²»ÄÜ·ÅÈë/lib/modules/Ï¡£
ÔÚ2.4ÄÚºËÖУ¬¼ÓÔØÇý¶¯ÃüÁî
Ϊ£ºinsmod ,ɾ³ýÄ£¿éΪ£ºrmmod£»
ÔÚ2 ......