swappiness 修改_什么是Linux上的Swappiness? (以及如何更改)

swappiness 修改

swappiness 修改

Sticks of random access memory (RAM) for a computer.
subin-ch/Shutterstock.com subin-ch / Shutterstock.com

The Linux swappiness value has nothing to do with how much RAM is used before swapping starts. That’s a widely reported and widely believed mistake. We explain what it really is.

Linux swappiness值与交换开始之前使用了多少内存无关。 这是一个被广泛报道并被广泛认为的错误。 我们解释它的真正含义。

关于Swapiness的破坏神话 (Busting Myths About Swapiness)

Swapping is a technique where data in Random Access Memory (RAM) is written to a special location on your hard disk—either a swap partition or a swap file—to free up RAM.

交换是一种将随机存取存储器 (RAM)中的数据写入硬盘上特殊位置(交换分区或交换文件)以释放RAM的技术。

Linux has a setting called the swappiness value. There’s a lot of confusion about what this setting controls. The most common incorrect description of swappiness is that it sets a threshold for RAM usage, and when the amount of used RAM hits that threshold, swapping starts.

Linux有一个称为swappiness值的设置。 此设置所控制的内容令人困惑。 交换性最常见的错误描述是它为RAM使用率设置了阈值,并且当已用RAM的数量达到该阈值时,交换就开始了。

This is a misconception that has been repeated so often that it is now received wisdom. If (almost) everyone else tells you that’s exactly how swappiness works, why should you believe us when we say it isn’t?

这是一种误解,这种误解已屡屡发生,以至于现在被人们所接受。 如果(几乎)其他所有人都告诉您交换性确实是如何工作的,那么当我们说不行时您为什么要相信我们?

Simple. We’re going to prove it.

简单。 我们将证明这一点。

您的RAM被分成区域 (Your RAM is Split Into Zones)

Linux doesn’t think of your RAM as one big homogenous pool of memory. It considers it to be divided into a number of different regions called zones. Which zones are present on your computer depends on whether it is 32-bit or 64-bit. Here’s a simplified description of the possible zones on an x86 architecture computer.

Linux不会将您的RAM视为一大同质的内存池。 它认为它被分为许多不同的区域,称为区域。 您的计算机上存在哪些区域取决于它是32位还是64位 。 这是x86架构计算机上可能区域的简化描述。

  • Direct Memory Access (DMA): This is the low 16 MB of memory. The zone gets its name because, a long time ago, there were computers that could only do direct memory access into this area of physical memory.

    直接内存访问(DMA) :这是低16 MB的内存。 该区域之所以得名,是因为很久以前,有些计算机只能直接对物理内存区域进行内存访问。

  • Direct Memory Access 32: Despite its name, Direct Memory Access 32 (DMA32) is a zone only found in 64-bit Linux. It’s the low 4 GB of memory. Linux running on 32-bit computers can only do DMA to this amount of RAM (unless they are using the physical address extension (PAE) kernel), which is how the zone got its name. Although, on 32-bit computers, it is called HighMem.

    直接内存访问32 :尽管有直接内存访问32(DMA32)的名称,但它是仅在64位Linux中找到的区域。 这是低4 GB的内存。 在32位计算机上运行Linux只能对此数量的RAM进行DMA(除非它们使用的是物理地址扩展 (PAE)内核),这就是该区域的名称。 尽管在32位计算机上,它称为HighMem。

  • Normal: On 64-bit computers, normal memory is all of the RAM above 4GB (roughly). On 32-bit machines, it is RAM between 16 MB and 896 MB.

    普通 :在64位计算机上,普通内存是4GB以上(大约)的所有RAM。 在32位计算机上,它是16 MB到896 MB之间的RAM。

  • HighMem: This only exists on 32-bit Linux computers. It is all RAM above 896 MB, including RAM above 4 GB on sufficiently large machines.

    HighMem :仅在32位Linux计算机上存在。 它是所有大于896 MB的RAM,包括足够大的计算机上大于4 GB的RAM。

PAGESIZE值 (The PAGESIZE Value)

RAM is allocated in pages, which are of a fixed size. That size is determined by the kernel at boot time by detecting the architecture of the computer. Typically the page size on a Linux computer is 4 Kbytes.

RAM以固定大小的页面分配。 该大小由内核在启动时通过检测计算机的体系结构确定。 通常,Linux计算机上的页面大小为4 KB。

You can see your page size using the getconf command:

您可以使用getconf命令查看页面大小:

getconf PAGESIZE
getconf PAGESIZE

区域附加到节点 (Zones Are Attached to Nodes)

Zones are attached to nodes. Nodes are associated with a Central Processing Unit (CPU). The kernel will try to allocate memory for a process running on a CPU from the node associated with that CPU.

区域连接到节点。 节点与中央处理器(CPU)关联。 内核将尝试从与该CPU关联的节点为该CPU上运行的进程分配内存。

The concept of nodes being tied to CPUs allows

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值