Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lwn 105021: active memory defragmentation #198

Closed
wants to merge 1 commit into from

Conversation

yimin-zhao
Copy link
Contributor

Signed-off-by: tacinight tacingiht@gmail.com

Signed-off-by: tacinight <tacingiht@gmail.com>
album: 'LWN 中文翻译'
group: 'translation'
license: "cc-by-sa-4.0"
permalink: /lwn-105021-active-memory-defragmentation/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

对于 permalink 请使用如下形式:
permalink: /lwn-105021/

方便以后超链接 URL 访问:http://tinylab.org/lwn-105021/ 即可,这个是新定的规矩,对于以前的文档,我后面找个机会会一并改掉。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK

---

> 原文:[Active memory defragmentation](https://lwn.net/Articles/105021/)
> 原创:By corbet @ October 5, 2004
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

原创:By corbet @ October 5, 2004
建议改成:
原创:By corbet @ Oct. 5, 2004

原因:应 falcon wu 的要求,为了方便手机上窄屏浏览不换行。有点细节了,不改其实问题也不大 :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK,统一格式


当然也还有一些小毛病,包括在 SMP 系统上的一些不足,但是 Marcelo 的回应显得毫无畏惧:

> But it works fine on UP (for a few minutes :)), and easily creates large physically contiguous areas of memory.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里UP应该是Uni Processor,单核机器的意思,后续我会修改过来


> "High order" allocations, in the kernel, are attempts to obtain multiple, contiguous pages for an application which needs more than one page in a single, physically-contiguous block. These allocations have always been a problem for the kernel to satisfy; once the system has been running for a while, physical memory is usually fragmented to the point that very few groups of adjacent, free pages exist. Last month, this page looked at Nick Piggin's kswapd changes which attempt to mitigate this problem somewhat. There are other people working in this area, however.

在内核中,“高阶”内存分配指的是,某个程序在单个物理上连续的块上请求多个页框,而系统就为之分配多个连续的页框的内存分配行为。但是这样的分配往往对于内核而言是难以满足的;系统在运行了一段时间之后,物理内存往往散乱到很少存在连续空闲的页框。上一个月,本文的作者还关注了 Nick Piggin 的 kswapd 进程试图缓解内存碎片问题的有关动态。当然也还有很多人专注于这一领域尝试着解决问题。
Copy link

@Bennnyzhao Bennnyzhao Nov 3, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • 页框是否可以考虑翻译成页帧。
  • 某个程序在单个物理上连续的块上请求多个页框,而系统就为之分配多个连续的页框的内存分配行为。是否考虑如下表述:
    某个程序在单个物理上连续的块上请求多个连续的页帧,而系统试图为之分配多个连续页帧的内存分配行为。
  • 但是这样的分配往往对于内核而言是难以满足的;是否考虑如下表述:
    但是内核往往难以满足这种内存分配方式;
  • 上一个月 直接改为 上个月就好吧?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Bennnyzhao @tacinight 还是用“页框”吧,因为内核中一般称物理的内存页叫 “page frame”, 我们很多书上就是翻译称 “页框”, 譬如经典的 ULK3

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

改成 但是内核往往难以满足这种内存分配"请求“ 可好?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok


> Naturally, this process seems rather more complicated when looked at closely. Not all pages can be relocated; those which are locked or reserved, for example, are not touchable. The patch also declines to work with pages which are currently under writeback; until the writeback I/O completes, those pages must not move. A number of more complicated cases, such as moving pages which are part of a nonlinear mapping, are not handled with the current patch.

这个过程自然比初看起来的要复杂的多。首先,并不是所有的页都可以重定位,如果他们被锁定了或者处于保留状态,那么他们是不能被移动的。其次,这个补丁也不能很好的和页框的写回机制共处,因为直到写回的 I/O 操作完成,这些页也都不能被移动。还有一系列更复杂的情况,例如当页框是被非线性映射的,那么这个补丁也无法去处理这些情况。

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • 如果他们被锁定了或者处于保留状态,那么他们是不能被移动的。是否考虑修改如下:
    比如那些被锁定或者预留的页就不能被移动。
  • 其次,这个补丁也不能很好的和页框的写回机制共处
    其次,这个补丁也不能处理那些正在处于回写状态的页;
  • 因为直到写回的 I/O 操作完成,这些页也都不能被移动。这句翻译应该跟原文的意思有点不一致。not ... until 直到...才
    这些页必须等到I/O回写完成才能被移动。
  • 还有一系列更复杂的情况,例如当页框是被非线性映射的,那么这个补丁也无法去处理这些情况。
    还有一系列更复杂的情况,这个补丁也无法处理,例如移动非线性映射的页帧时。


> If a page does appear to be relocatable, it must first be locked and have its contents copied to the new page. Then all page tables which reference the old page must be re-pointed to the new page. Reverse mapping information, if any, must be set correctly. If there is a copy of the page in swap, that copy must be connected with the new page. And so on. Marcelo's patch responds to many of the more complicated cases by simply refusing to move the page. Even so, Marcelo reports good results in creating large, contiguous blocks of free memory.

如果一个页框满足了重定位的条件,他还必须先锁定,等待他将内容拷贝到新的页框中。然后页表中所有指向旧页框的要更正指向新的页框。如果有反向映射信息的也要一一设置正确。在 swap 分区中的副本也要正确关联到新的页框。等等。在 Marcelo 的补丁中,很多复杂情形都是尝试着不去做处理。即使如此,Marcelo 的报告中还是有成功的结果,这些结果验证了创建连续页内存块的正确性。

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • 然后页表中所有指向旧页框的要更正指向新的页框。
    然后页表中所有指向旧页帧的都要重新指向新的页帧。
  • 在 Marcelo 的补丁中,很多复杂情形都是尝试着不去做处理。
    对很多复杂情形在 Marcelo 的补丁中只是简单的不去处理。
  • 这些结果验证了创建连续页内存块的正确性。感觉原文没有提到正确性,只是说这个补丁效果还不错。当然翻译成正确性也说的过去。
    Marcelo 的报告中说创建大的连续页内存块取得了较好的效果。这样翻译是否合适?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

最后一句我又稍微调整一下:即使如此,Marcelo 的报告中给出,这个补丁在创建大的连续页内存块方面取得了不错的效果。

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok


> It was pointed out that this patch has some common features with a different effort: the drive to support hotpluggable memory. When memory is to be removed from the system, all pages currently stored in that memory must be relocated. In essence, the hotplug memory patches seek to create a large block of free memory which happens to cover a specific set of physical addresses.

他的补丁也被指出和一些其他的工作有着相似的特性,例如支持热拔插内存的驱动。当内存要被移除系统时,相应内存区域上的页框必须要被重定位。本质上说,热拔插内存补丁试图创建一块大的内存区域,而这区域刚好覆盖了一系列指定的物理地址。

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • which happens to cover a specific set of physical addresses
    我理解这句应该指的是没有被热拔出的内存地址。感觉翻译成一系列指定的物理地址觉得有点怪,但又没有更好的翻译建议。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我的理解是,热拔插内存要将这一片内存上的内容移走,就像本文中的补丁的作用一样,看似创建了一大块空闲的内存空间,因此 a specific set of physical addresses 指的应该是被热拔插的内存。
翻译内容就是:本质上说,热拔插内存补丁试图创建一块大的内存区域,而这区域刚好覆盖了被移除内存所对应的一系列的物理地址。

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok


> Between Marcelo's work and the hotplug patches, there is a significant amount of experience in moving pages aside to free blocks of memory. An effort to bring together those patches into a single one containing the best of each will probably be necessary before any can be merged. But the end result of that work could be an end to problems with high-order allocations.

在 Marcelo 的工作以及热拔插补丁中,都有大量关于移动页框用以释放成块内存的经验总结。但在合并任何补丁前,都需要额外的努力将这些补丁中最好的部分提取成一个最佳的方案。这些成果最终可能将为高阶内存分配问题画上一个完美的句号。

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • 但在合并任何补丁前,都需要额外的努力将这些补丁中最好的部分提取成一个最佳的方案。
    在合并任一补丁前,有必要做些工作将这些补丁中最好的部分提取成一个最佳的方案。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

谢谢 @Bennnyzhao 的意见,大部分都修改完成了,少数部分还待商讨。

> 原文:[Active memory defragmentation](https://lwn.net/Articles/105021/)
> 原创:By corbet @ October 5, 2004
> 翻译:By [Tacinight](https://github.com/tacinight) of [TinyLab.org][1]
> 校对:By ???
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

请正式提交时不要忘记补充


“他在机器上正常的运转了(尽管只是几分钟 :)),并且可以轻易的创建出大范围物理连续的内存空间”

> It was pointed out that this patch has some common features with a different effort: the drive to support hotpluggable memory. When memory is to be removed from the system, all pages currently stored in that memory must be relocated. In essence, the hotplug memory patches seek to create a large block of free memory which happens to cover a specific set of physical addresses.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • the drive to support hotpluggable memory. 这里的 drive 翻译成驱动不太好,感觉是表达 “某种想法”,就像我们中文中常说 “驱动某人做某事”,而且这个也不是驱动所要做的事情。

  • 这段话我整体上给个建议吧,供参考:

他的补丁用不同的方法实现了和另外一个工作,即热拔插内存所需要实现的类似的特性。当我们从系统上移除内存时,相应内存区域上的页框中的内容必须要被移动到其他地方。本质上说,热插拔内存的目的也是要寻找一大块空闲的内存来容纳要被移除的页框上的内容。

@yimin-zhao yimin-zhao closed this Nov 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants