日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > linux >内容正文

linux

linux内核函数kmalloc,Linux_Linux平台上几个常见内核内存分配函数,* kmallocPrototype:#incl - phpStudy...

發布時間:2023/12/15 linux 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 linux内核函数kmalloc,Linux_Linux平台上几个常见内核内存分配函数,* kmallocPrototype:#incl - phpStudy... 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

Linux平臺上幾個常見內核內存分配函數

* kmalloc

Prototype:

#include

void *kmalloc(size_t size, int flags);

Kmalloc分配一段未清0的連續物理內存頁,并返回虛存地址。有點是快,并且可指定flag,如DMA內存,高地址區域內存等。缺點是不能分配大于128KB(處于跨平臺考慮),幾個重要的flag:

GFP_ATOMIC

Used to allocate memory from interrupt handlers and other code outside of a process context. Never sleeps.

GFP_KERNEL

Normal allocation of kernel memory. May sleep.

GFP_USER

Used to allocate memory for user-space pages; it may sleep.

GFP_HIGHUSER

Like GFP_USER, but allocates from high memory, if any. High memory is described in the next subsection.

* slab allocator(lookaside cache)

從Memcached的實現知道有這么一個內存管理策略,其顯著特點是分配一組相同大小的內存塊作為內存池,其實現對應于源代碼中的和mm/slab.c。

Prototype:

#include

kmem_cache_t *kmem_cache_create(char *name, size_t size, size_t offset,

unsigned long flags, constructor( ), destructor( ));

int kmem_cache_destroy(kmem_cache_t *cache);

/proc/slabinfo

A virtual file containing statistics on slab cache usage.

*__get_free_pages

Prototype:

_ _get_free_pages(unsigned int flags, unsigned int order);

返回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 .

DEFINE_PER_CPU(type, name);

get_cpu_var(sockets_in_use)++;

put_cpu_var(sockets_in_use);相關閱讀:

PHP完整的日歷類(CLASS)

function, new function, new Function之間的區別

解析CSS列表樣式屬性list-style

discuz7 phpMysql操作類

LumaQQ的安裝和使用

MYSQL導入導出命令詳解

css利用A標簽的背景可能作出很有意思的效果

javascript做的日歷,完全對象化,望高手提出改進意見。(1/3,將3部分拼成一個html文件瀏覽)_QQGB.co

在Access2007中使用“多值”實現文字的sum

oracle時間用法

JavaScript教程:淺析JS運行機制

GhostXP裝機版v3.0

查找亂碼字符串的SQL

Vormetric推出Oracle和SQL Server數據庫安全包

總結

以上是生活随笔為你收集整理的linux内核函数kmalloc,Linux_Linux平台上几个常见内核内存分配函数,* kmallocPrototype:#incl - phpStudy...的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。