linux – 30%的RAM是“缓冲区”.它是什么?
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了linux – 30%的RAM是“缓冲区”.它是什么?,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含6850字,纯文字阅读大概需要10分钟。
内容图文
![linux – 30%的RAM是“缓冲区”.它是什么?](/upload/InfoBanner/zyjiaocheng/959/dbd948de48b645d28db6fd6b52a4e286.jpg)
$free -h
total used free shared buff/cache available
Mem: 501M 146M 19M 9.7M 335M 331M
Swap: 1.0G 85M 938M
$free -w -h
total used free shared buffers cache available
Mem: 501M 146M 19M 9.7M 155M 180M 331M
Swap: 1.0G 85M 938M
如何在免费输出中描述或解释“缓冲区”?
我对这个系统没有任何(已知的)问题.我很惊讶并且好奇地看到“缓冲区”几乎和“缓存”一样高(155M v.s.180M).我认为“缓存”代表文件内容的页面缓存,并且往往是“缓存/缓冲区”中最重要的部分.我不太清楚什么是“缓冲”.
例如,我把它与我的笔记本电脑进行了比较在我的笔记本电脑上,“缓冲”数字比“缓存”(200M v.s. 4G)小一个数量级.如果我对“缓冲区”有了正确的理解,那么我就可以开始问为什么缓冲区可能会在较小的系统上增长到如此大的比例.
man proc(我忽略了“大”的滑稽过时的定义):
Buffers %lu
Relatively temporary storage for raw disk blocks that shouldn’t get tremendously large (20MB or so).
Cached %lu
In-memory cache for files read from the disk (the page cache). Doesn’t include SwapCached.
$free -V
free from procps-ng 3.3.12
$uname -r
4.9.0-6-marvell
$systemd-detect-virt
none
$cat /proc/meminfo
MemTotal: 513976 kB
MemFree: 20100 kB
MemAvailable: 339304 kB
Buffers: 159220 kB
Cached: 155536 kB
SwapCached: 2420 kB
Active: 215044 kB
Inactive: 216760 kB
Active(anon): 56556 kB
Inactive(anon): 73280 kB
Active(file): 158488 kB
Inactive(file): 143480 kB
Unevictable: 10760 kB
Mlocked: 10760 kB
HighTotal: 0 kB
HighFree: 0 kB
LowTotal: 513976 kB
LowFree: 20100 kB
SwapTotal: 1048572 kB
SwapFree: 960532 kB
Dirty: 240 kB
Writeback: 0 kB
AnonPages: 126912 kB
Mapped: 40312 kB
Shmem: 9916 kB
Slab: 37580 kB
SReclaimable: 29036 kB
SUnreclaim: 8544 kB
KernelStack: 1472 kB
PageTables: 3108 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
WritebackTmp: 0 kB
CommitLimit: 1305560 kB
Committed_AS: 1155244 kB
VmallocTotal: 507904 kB
VmallocUsed: 0 kB
VmallocChunk: 0 kB
$sudo slabtop --once
Active / Total Objects (% used) : 186139 / 212611 (87.5%)
Active / Total Slabs (% used) : 9115 / 9115 (100.0%)
Active / Total Caches (% used) : 66 / 92 (71.7%)
Active / Total Size (% used) : 31838.34K / 35031.49K (90.9%)
Minimum / Average / Maximum Object : 0.02K / 0.16K / 4096.00K
OBJS ACTIVE USE OBJ SIZE SLABS OBJ/SLAB CACHE SIZE NAME
59968 57222 0% 0.06K 937 64 3748K buffer_head
29010 21923 0% 0.13K 967 30 3868K dentry
24306 23842 0% 0.58K 4051 6 16204K ext4_inode_cache
22072 20576 0% 0.03K 178 124 712K kmalloc-32
10290 9756 0% 0.09K 245 42 980K kmalloc-96
9152 4582 0% 0.06K 143 64 572K kmalloc-node
9027 8914 0% 0.08K 177 51 708K kernfs_node_cache
7007 3830 0% 0.30K 539 13 2156K radix_tree_node
5952 4466 0% 0.03K 48 124 192K jbd2_revoke_record_s
5889 5870 0% 0.30K 453 13 1812K inode_cache
5705 4479 0% 0.02K 35 163 140K file_lock_ctx
3844 3464 0% 0.03K 31 124 124K anon_vma
3280 3032 0% 0.25K 205 16 820K kmalloc-256
2730 2720 0% 0.10K 70 39 280K btrfs_trans_handle
2025 1749 0% 0.16K 81 25 324K filp
1952 1844 0% 0.12K 61 32 244K kmalloc-128
1826 532 0% 0.05K 22 83 88K trace_event_file
1392 1384 0% 0.33K 116 12 464K proc_inode_cache
1067 1050 0% 0.34K 97 11 388K shmem_inode_cache
987 768 0% 0.19K 47 21 188K kmalloc-192
848 757 0% 0.50K 106 8 424K kmalloc-512
450 448 0% 0.38K 45 10 180K ubifs_inode_slab
297 200 0% 0.04K 3 99 12K eventpoll_pwq
288 288 100% 1.00K 72 4 288K kmalloc-1024
288 288 100% 0.22K 16 18 64K mnt_cache
287 283 0% 1.05K 41 7 328K idr_layer_cache
240 8 0% 0.02K 1 240 4K fscrypt_info
解决方法:
>“缓冲区”和其他缓存有什么区别?
> Linux何时使用缓冲区缓存而不是页面缓存?
>为什么我们可以期望缓冲区缓存更大或更小?
1.“缓冲区”和其他缓存有什么区别?
可以肯定地说缓冲区缓存是“原始磁盘块的存储”.文件系统使用的磁盘块可能小至512字节.这与用于文件数据的页面缓存不同.
页面缓存与MMU页面大小相关联,通常最小为4096字节.这对于存储器映射文件访问[2]是必不可少的,并且具体地用于按需加载运行程序的各个代码页. (另外,当其他东西需要空间时卸载页面,并且最近没有使用它们).
2. Linux什么时候使用缓冲区缓存而不是页面缓存?
在现代Linux上,缓冲区缓存很可能由文件系统元数据组成.这包括目录内容.
缓冲区缓存的这种使用取决于文件系统,但它包括有问题的系统使用的ext4.
Buffers
[in /proc/meminfo] are in-memory block I/O buffers. They are relatively short-lived. Prior to Linux kernel version 2.4, Linux had separate page and buffer caches. Since 2.4, the page and buffer cache are unified andBuffers
is raw disk blocks not represented in the page cache—i.e., not file data.…
The buffer cache remains, however, as the kernel still needs to perform block I/O in terms of blocks, not pages. As most blocks represent file data, most of the buffer cache is represented by the page cache. But a small amount of block data isn’t file backed—metadata and raw block I/O for example—and thus is solely represented by the buffer cache.
– Robert Love by Robert Love,最后更新2013.
Certain file systems, including ext3, ext4, and ocfs2, use the jbd or
jbd2 layer to handle their physical block journalling, and this layer
fundamentally uses the buffer cache, since it is concerned with
controlling when specific file system blocks are allowed to ben
written back to the hard drive.Other file systems may not support file system blocks smaller than 4k.
This may make it easier for them to use the page cache for their
metadata blocks, although I don’t know what happens if you try to
mount a btrfs file system formatted with 4k blocks on an architecture
such as Power which has 16k pages. I don’t know if it will work, or
blow up in a spectacular display of sparks.标签:,, 来源: https://codeday.me/bug/20190809/1630831.html
内容总结
以上是互联网集市为您收集整理的linux – 30%的RAM是“缓冲区”.它是什么?全部内容,希望文章能够帮你解决linux – 30%的RAM是“缓冲区”.它是什么?所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。