手机版
你好,游客 登录 注册 搜索
背景:
阅读新闻

Linux平台上几个常见内核内存分配函数

[日期:2010-02-07] 来源:Linux社区  作者:Linux [字体:大 中 小]

  返回2^order个未清0连续物理页面,flags与kmalloc中flags一致,允许的最大order值为10或者11(根据体系结构不同)

  *alloc_pages

  Prototype:

  struct page *alloc_pages_node(int nid, unsigned int flags,

  unsigned int order);

  Kernel中页分配器实现,__get_free_pages即调用alloc_pages实现的

  The real core of the Linux page allocator is a function called alloc_pages_node:

  *vmalloc

  分配地址连续虚存,而不保证物理地址连续,大部分情况下适合“软件”,而不是驱动程序。相对而言,kmalloc和__get_free_pages虚存map到物理内存只需要增减一个偏移,而使用vmalloc分配需要修改页表,故vmalloc的开销较大,分配少数几个页面的效率太低。

  *per-cpu variables

  Each cpu hold an independant copy in their respective processor's caches, so there is no lock required and improve better performance, implemented as a linux 2.6 feature. Defined in <linux/percpu.h>.

  DEFINE_PER_CPU(type, name);

  get_cpu_var(sockets_in_use)++;

  put_cpu_var(sockets_in_use);

linux
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款