【Linux 内核 内存管理】Linux 内核堆内存管理 ③ ( CPU 计数器瓶颈 | per-CPU 计数器 | Linux 内核 percpu_counter 结构体源码 )
文章目錄
- 一、CPU 計(jì)數(shù)器瓶頸
- 二、per-CPU 計(jì)數(shù)器及 percpu_counter 結(jié)構(gòu)體源碼
一、CPU 計(jì)數(shù)器瓶頸
如果 操作系統(tǒng) 中有 多個(gè) CPU , 假設(shè)只有一個(gè) CPU 計(jì)數(shù)器工作 , 如果 某個(gè) CPU 正在訪問(wèn)計(jì)數(shù)器 , 其它 CPU 需要等待計(jì)數(shù)器釋放 , 才能訪問(wèn) CPU 計(jì)數(shù)器 , 這里 CPU 計(jì)數(shù)器會(huì)出現(xiàn)瓶頸 , 影響系統(tǒng)性能 ;
二、per-CPU 計(jì)數(shù)器及 percpu_counter 結(jié)構(gòu)體源碼
Linux 內(nèi)核中 , 引入了 " per-CPU 計(jì)數(shù)器 “ , 用于加速 ” SMP 系統(tǒng) " 的計(jì)數(shù)器操作 ;
" per-CPU 計(jì)數(shù)器 " 在 Linux 內(nèi)核中被定義為 percpu_counter 結(jié)構(gòu)體 , 該 結(jié)構(gòu)體 定義在 Linux 內(nèi)核源碼 的 linux-5.6.18\include\linux\percpu_counter.h#20 中 ;
raw_spinlock_t lock 字段是一個(gè) 自旋鎖 ;
s64 count 字段是 計(jì)數(shù)器的值 ;
struct percpu_counter {raw_spinlock_t lock;s64 count; #ifdef CONFIG_HOTPLUG_CPUstruct list_head list; /* All percpu_counters are on a list */ #endifs32 __percpu *counters; };源碼路徑 : linux-5.6.18\include\linux\percpu_counter.h#20
總結(jié)
以上是生活随笔為你收集整理的【Linux 内核 内存管理】Linux 内核堆内存管理 ③ ( CPU 计数器瓶颈 | per-CPU 计数器 | Linux 内核 percpu_counter 结构体源码 )的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 【Linux 内核 内存管理】Linux
- 下一篇: 【Linux 内核 内存管理】内存管理架