linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm/balloon_compaction: update Chinese docs for movable_ops
@ 2025-06-22  0:42 Nick Huang
  2025-06-22 13:33 ` [PATCH v2] " Nick Huang
  2025-06-23  8:07 ` [PATCH] " David Hildenbrand
  0 siblings, 2 replies; 11+ messages in thread
From: Nick Huang @ 2025-06-22  0:42 UTC (permalink / raw)
  To: alexs
  Cc: si.yanteng, dzm91, corbet, akpm, wangkefeng.wang, vishal.moola,
	linux-doc, linux-kernel, david, linux-mm, Nick Huang

Remove Non-LRU Page Migration and Add Movable_ops Page Migration

Reference: https://lore.kernel.org/all/20250618174014.1168640-28-david@redhat.com/
---
 .../translations/zh_CN/mm/page_migration.rst  | 88 +++----------------
 1 file changed, 10 insertions(+), 78 deletions(-)

diff --git a/Documentation/translations/zh_CN/mm/page_migration.rst b/Documentation/translations/zh_CN/mm/page_migration.rst
index 8c8461c6cb9f..e4f03228dbd9 100644
--- a/Documentation/translations/zh_CN/mm/page_migration.rst
+++ b/Documentation/translations/zh_CN/mm/page_migration.rst
@@ -114,91 +114,23 @@ migrate_pages()对它的页面列表进行了多次处理。如果当时对一
 
 18. 新的页面被移到LRU中,可以被交换器等再次扫描。
 
-非LRU页面迁移
+movable_ops 页面迁移
 =============
 
-尽管迁移最初的目的是为了减少NUMA的内存访问延迟,但压缩也使用迁移来创建高阶页面。
+选定的特定类型且非 folio 的页面(例如 memory balloon 或 zsmalloc 分配的页面)可以借助 movable_ops 迁移框架实现页面迁移。
 
-目前实现的问题是,它被设计为只迁移*LRU*页。然而,有一些潜在的非LRU页面可以在驱动中
-被迁移,例如,zsmalloc,virtio-balloon页面。
+struct movable_operations 提供了与页面类型相关的回调函数,用于隔离、迁移以及将页面放回。
 
-对于virtio-balloon页面,迁移代码路径的某些部分已经被钩住,并添加了virtio-balloon
-的特定函数来拦截迁移逻辑。这对一个驱动来说太特殊了,所以其他想让自己的页面可移动的驱
-动就必须在迁移路径中添加自己的特定钩子。
+一旦页面被标记为具有 movable_ops,在页面被释放回 buddy 系统之前,不应更改其状态。这包括不得更改或清除页面类型,也不得更改或清除 PG_movable_ops 页面标志。
 
-为了克服这个问题,VM支持非LRU页面迁移,它为非LRU可移动页面提供了通用函数,而在迁移
-路径中没有特定的驱动程序钩子。
+目前,任意驱动程序尚无法直接使用此框架,因为使用该机制需满足以下条件:
 
-如果一个驱动程序想让它的页面可移动,它应该定义三个函数,这些函数是
-struct address_space_operations的函数指针。
+(a) 页面类型;
+(b) 在 page_has_movable_ops() 中根据页面类型标示这些页面可能具有 movable_ops;
+(c) 在 page_has_movable_ops() 中根据页面类型返回对应的 movable_ops;
+(d) 不得将 PG_movable_ops 和 PG_movable_ops_isolated 页面标志用于其他用途。
 
-1. ``bool (*isolate_page) (struct page *page, isolate_mode_t mode);``
-
-   VM对驱动的isolate_page()函数的期望是,如果驱动成功隔离了该页,则返回*true*。
-   返回true后,VM会将该页标记为PG_isolated,这样多个CPU的并发隔离就会跳过该
-   页进行隔离。如果驱动程序不能隔离该页,它应该返回*false*。
-
-   一旦页面被成功隔离,VM就会使用page.lru字段,因此驱动程序不应期望保留这些字段的值。
-
-2. ``int (*migratepage) (struct address_space *mapping,``
-|	``struct page *newpage, struct page *oldpage, enum migrate_mode);``
-
-   隔离后,虚拟机用隔离的页面调用驱动的migratepage()。migratepage()的功能是将旧页
-   的内容移动到新页,并设置struct page newpage的字段。请记住,如果你成功迁移了旧页
-   并返回MIGRATEPAGE_SUCCESS,你应该通过page_lock下的__ClearPageMovable()向虚
-   拟机表明旧页不再可移动。如果驱动暂时不能迁移该页,驱动可以返回-EAGAIN。在-EAGAIN
-   时,VM会在短时间内重试页面迁移,因为VM将-EAGAIN理解为 "临时迁移失败"。在返回除
-   -EAGAIN以外的任何错误时,VM将放弃页面迁移而不重试。
-
-   在migratepage()函数中,驱动程序不应该接触page.lru字段。
-
-3. ``void (*putback_page)(struct page *);``
-
-   如果在隔离页上迁移失败,VM应该将隔离页返回给驱动,因此VM用隔离页调用驱动的
-   putback_page()。在这个函数中,驱动应该把隔离页放回自己的数据结构中。
-
-非LRU可移动页标志
-
-   有两个页面标志用于支持非LRU可移动页面。
-
-   * PG_movable
-
-     驱动应该使用下面的函数来使页面在page_lock下可移动。::
-
-	void __SetPageMovable(struct page *page, struct address_space *mapping)
-
-     它需要address_space的参数来注册将被VM调用的migration family函数。确切地说,
-     PG_movable不是struct page的一个真正的标志。相反,VM复用了page->mapping的低
-     位来表示它::
-
-	#define PAGE_MAPPING_MOVABLE 0x2
-	page->mapping = page->mapping | PAGE_MAPPING_MOVABLE;
-
-     所以驱动不应该直接访问page->mapping。相反,驱动应该使用page_mapping(),它可
-     以在页面锁下屏蔽掉page->mapping的低2位,从而获得正确的struct address_space。
-
-     对于非LRU可移动页面的测试,VM支持__PageMovable()函数。然而,它并不能保证识别
-     非LRU可移动页面,因为page->mapping字段与struct page中的其他变量是统一的。如
-     果驱动程序在被虚拟机隔离后释放了页面,尽管page->mapping设置了PAGE_MAPPING_MOVABLE,
-     但它并没有一个稳定的值(看看__ClearPageMovable)。但是__PageMovable()在页
-     面被隔离后,无论页面是LRU还是非LRU可移动的,调用它开销都很低,因为LRU页面在
-     page->mapping中不可能有PAGE_MAPPING_MOVABLE设置。在用pfn扫描中的lock_page()
-     进行更大开销的检查来选择受害者之前,它也很适合只是瞥一眼来测试非LRU可移动的页面。
-
-     为了保证非LRU的可移动页面,VM提供了PageMovable()函数。与__PageMovable()不
-     同,PageMovable()在lock_page()下验证page->mapping和
-     mapping->a_ops->isolate_page。lock_page()可以防止突然破坏page->mapping。
-
-     使用__SetPageMovable()的驱动应该在释放页面之前通过page_lock()下的
-     __ClearMovablePage()清除该标志。
-
-   * PG_isolated
-
-     为了防止几个CPU同时进行隔离,VM在lock_page()下将隔离的页面标记为PG_isolated。
-     因此,如果一个CPU遇到PG_isolated非LRU可移动页面,它可以跳过它。驱动程序不需要
-     操作这个标志,因为VM会自动设置/清除它。请记住,如果驱动程序看到PG_isolated页,
-     这意味着该页已经被VM隔离,所以它不应该碰page.lru字段。PG_isolated标志与
-     PG_reclaim标志是同义的,所以驱动程序不应该为自己的目的使用PG_isolated。
+例如: Balloon 驱动程序可以通过核心内核提供的 balloon-compaction 框架使用该机制。
 
 监测迁移
 ========
-- 
2.48.1



^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v2] mm/balloon_compaction: update Chinese docs for movable_ops
  2025-06-22  0:42 [PATCH] mm/balloon_compaction: update Chinese docs for movable_ops Nick Huang
@ 2025-06-22 13:33 ` Nick Huang
  2025-06-23  2:15   ` Dongliang Mu
  2025-06-23  8:07 ` [PATCH] " David Hildenbrand
  1 sibling, 1 reply; 11+ messages in thread
From: Nick Huang @ 2025-06-22 13:33 UTC (permalink / raw)
  To: sef1548
  Cc: akpm, alexs, corbet, david, dzm91, linux-doc, linux-kernel,
	linux-mm, si.yanteng, vishal.moola, wangkefeng.wang

This patch is identical to v1, with the only change being the addition
of a missing Signed-off-by line.

Sorry for the oversight in the previous submission.

Signed-off-by: Nick Huang <sef1548@gmail.com>



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v2] mm/balloon_compaction: update Chinese docs for movable_ops
  2025-06-22 13:33 ` [PATCH v2] " Nick Huang
@ 2025-06-23  2:15   ` Dongliang Mu
  2025-06-23  3:23     ` Nick Huang
  0 siblings, 1 reply; 11+ messages in thread
From: Dongliang Mu @ 2025-06-23  2:15 UTC (permalink / raw)
  To: Nick Huang
  Cc: akpm, alexs, corbet, david, linux-doc, linux-kernel, linux-mm,
	si.yanteng, vishal.moola, wangkefeng.wang


On 6/22/25 9:33 PM, Nick Huang wrote:
> This patch is identical to v1, with the only change being the addition
> of a missing Signed-off-by line.
>
> Sorry for the oversight in the previous submission.

When you have a new patch, you'd better submit it with a full code 
change other than explanation.

You could check any v2 patch in the LKML for further reference.

Dongliang Mu

>
> Signed-off-by: Nick Huang <sef1548@gmail.com>



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v2] mm/balloon_compaction: update Chinese docs for movable_ops
  2025-06-23  2:15   ` Dongliang Mu
@ 2025-06-23  3:23     ` Nick Huang
  0 siblings, 0 replies; 11+ messages in thread
From: Nick Huang @ 2025-06-23  3:23 UTC (permalink / raw)
  To: Dongliang Mu
  Cc: akpm, alexs, corbet, david, linux-doc, linux-kernel, linux-mm,
	si.yanteng, vishal.moola, wangkefeng.wang

[-- Attachment #1: Type: text/plain, Size: 662 bytes --]

Dongliang Mu <dzm91@hust.edu.cn> 於 2025年6月23日 週一 上午10:15寫道:

>
> On 6/22/25 9:33 PM, Nick Huang wrote:
> > This patch is identical to v1, with the only change being the addition
> > of a missing Signed-off-by line.
> >
> > Sorry for the oversight in the previous submission.
>
> When you have a new patch, you'd better submit it with a full code
> change other than explanation.
>
> You could check any v2 patch in the LKML for further reference.
>
> Dongliang Mu
>
> >
> > Signed-off-by: Nick Huang <sef1548@gmail.com>
>

Thank you for the reminder. I will check for any v2 patches on the LKML for
further reference.

[-- Attachment #2: Type: text/html, Size: 1071 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] mm/balloon_compaction: update Chinese docs for movable_ops
  2025-06-22  0:42 [PATCH] mm/balloon_compaction: update Chinese docs for movable_ops Nick Huang
  2025-06-22 13:33 ` [PATCH v2] " Nick Huang
@ 2025-06-23  8:07 ` David Hildenbrand
  2025-06-23  8:50   ` Nick Huang
  1 sibling, 1 reply; 11+ messages in thread
From: David Hildenbrand @ 2025-06-23  8:07 UTC (permalink / raw)
  To: Nick Huang, alexs
  Cc: si.yanteng, dzm91, corbet, akpm, wangkefeng.wang, vishal.moola,
	linux-doc, linux-kernel, linux-mm

On 22.06.25 02:42, Nick Huang wrote:
> Remove Non-LRU Page Migration and Add Movable_ops Page Migration
> 

I'm afraid most people you CC on Chinese doc updates will not be able to 
help in any reasonable way.

-- 
Cheers,

David / dhildenb



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] mm/balloon_compaction: update Chinese docs for movable_ops
  2025-06-23  8:07 ` [PATCH] " David Hildenbrand
@ 2025-06-23  8:50   ` Nick Huang
  2025-06-23  9:12     ` Dongliang Mu
  2025-06-23  9:14     ` Dongliang Mu
  0 siblings, 2 replies; 11+ messages in thread
From: Nick Huang @ 2025-06-23  8:50 UTC (permalink / raw)
  To: David Hildenbrand
  Cc: alexs, si.yanteng, dzm91, corbet, akpm, wangkefeng.wang,
	vishal.moola, linux-doc, linux-kernel, linux-mm

David Hildenbrand <david@redhat.com> 於 2025年6月23日 週一 下午4:08寫道:
>
> On 22.06.25 02:42, Nick Huang wrote:
> > Remove Non-LRU Page Migration and Add Movable_ops Page Migration
> >
>
> I'm afraid most people you CC on Chinese doc updates will not be able to
> help in any reasonable way.
>
> --
> Cheers,
>
> David / dhildenb

How can I fix these things?


-- 
Regards,
Nick Huang


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] mm/balloon_compaction: update Chinese docs for movable_ops
  2025-06-23  8:50   ` Nick Huang
@ 2025-06-23  9:12     ` Dongliang Mu
  2025-06-23  9:23       ` David Hildenbrand
  2025-06-23  9:14     ` Dongliang Mu
  1 sibling, 1 reply; 11+ messages in thread
From: Dongliang Mu @ 2025-06-23  9:12 UTC (permalink / raw)
  To: Nick Huang
  Cc: David Hildenbrand, alexs, si.yanteng, dzm91, corbet, akpm,
	wangkefeng.wang, vishal.moola, linux-doc, linux-kernel, linux-mm

On Mon, Jun 23, 2025 at 4:51 PM Nick Huang <sef1548@gmail.com> wrote:
>
> David Hildenbrand <david@redhat.com> 於 2025年6月23日 週一 下午4:08寫道:
> >
> > On 22.06.25 02:42, Nick Huang wrote:
> > > Remove Non-LRU Page Migration and Add Movable_ops Page Migration
> > >
> >
> > I'm afraid most people you CC on Chinese doc updates will not be able to
> > help in any reasonable way.
> >
> > --
> > Cheers,
> >
> > David / dhildenb
>
> How can I fix these things?

From my understanding, you can follow this how-to.rst[1] and submit
your patches.

This is more friendly for reviewers and maintainers.

[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/translations/zh_CN/how-to.rst

>
>
> --
> Regards,
> Nick Huang
>


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] mm/balloon_compaction: update Chinese docs for movable_ops
  2025-06-23  8:50   ` Nick Huang
  2025-06-23  9:12     ` Dongliang Mu
@ 2025-06-23  9:14     ` Dongliang Mu
  1 sibling, 0 replies; 11+ messages in thread
From: Dongliang Mu @ 2025-06-23  9:14 UTC (permalink / raw)
  To: Nick Huang
  Cc: David Hildenbrand, alexs, si.yanteng, dzm91, corbet, akpm,
	wangkefeng.wang, vishal.moola, linux-doc, linux-kernel, linux-mm

On Mon, Jun 23, 2025 at 4:51 PM Nick Huang <sef1548@gmail.com> wrote:
>
> David Hildenbrand <david@redhat.com> 於 2025年6月23日 週一 下午4:08寫道:
> >
> > On 22.06.25 02:42, Nick Huang wrote:
> > > Remove Non-LRU Page Migration and Add Movable_ops Page Migration
> > >
> >
> > I'm afraid most people you CC on Chinese doc updates will not be able to
> > help in any reasonable way.
> >
> > --
> > Cheers,
> >
> > David / dhildenb
>
> How can I fix these things?

BTW, you can refer to my patches[1] for Chinese translation updates.

[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/log/?qt=author&q=Dongliang+Mu

>
>
> --
> Regards,
> Nick Huang
>


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] mm/balloon_compaction: update Chinese docs for movable_ops
  2025-06-23  9:12     ` Dongliang Mu
@ 2025-06-23  9:23       ` David Hildenbrand
  2025-06-23  9:35         ` Dongliang Mu
  0 siblings, 1 reply; 11+ messages in thread
From: David Hildenbrand @ 2025-06-23  9:23 UTC (permalink / raw)
  To: Dongliang Mu, Nick Huang
  Cc: alexs, si.yanteng, dzm91, corbet, akpm, wangkefeng.wang,
	vishal.moola, linux-doc, linux-kernel, linux-mm

On 23.06.25 11:12, Dongliang Mu wrote:
> On Mon, Jun 23, 2025 at 4:51 PM Nick Huang <sef1548@gmail.com> wrote:
>>
>> David Hildenbrand <david@redhat.com> 於 2025年6月23日 週一 下午4:08寫道:
>>>
>>> On 22.06.25 02:42, Nick Huang wrote:
>>>> Remove Non-LRU Page Migration and Add Movable_ops Page Migration
>>>>
>>>
>>> I'm afraid most people you CC on Chinese doc updates will not be able to
>>> help in any reasonable way.
>>>
>>> --
>>> Cheers,
>>>
>>> David / dhildenb
>>
>> How can I fix these things?
> 
>  From my understanding, you can follow this how-to.rst[1] and submit
> your patches.

Great, a how-to.rst in a language I don't know. So I assume you meant 
"one can follow", not me in particular. Because I can only parse some 
git commands etc in there that are in English.

Which bring us back to the problem: if you CC me (and many others) on 
something that is Chinese, I will not be able to contribute anything of 
value.

Quite the opposite, I will ramble about how non-sensical these in-tree 
translations are.

So likely, when you perform a Chinese doc update you want to only CC 
Chinese doc maintainers. Because they can actually provide review I hope.

Maybe that should be clarified in the how-to.rst[1] that I'm afraid I 
cannot read.

-- 
Cheers,

David / dhildenb



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] mm/balloon_compaction: update Chinese docs for movable_ops
  2025-06-23  9:23       ` David Hildenbrand
@ 2025-06-23  9:35         ` Dongliang Mu
  2025-06-23  9:38           ` David Hildenbrand
  0 siblings, 1 reply; 11+ messages in thread
From: Dongliang Mu @ 2025-06-23  9:35 UTC (permalink / raw)
  To: David Hildenbrand
  Cc: Nick Huang, alexs, si.yanteng, dzm91, corbet, akpm,
	wangkefeng.wang, vishal.moola, linux-doc, linux-kernel, linux-mm

On Mon, Jun 23, 2025 at 5:23 PM David Hildenbrand <david@redhat.com> wrote:
>
> On 23.06.25 11:12, Dongliang Mu wrote:
> > On Mon, Jun 23, 2025 at 4:51 PM Nick Huang <sef1548@gmail.com> wrote:
> >>
> >> David Hildenbrand <david@redhat.com> 於 2025年6月23日 週一 下午4:08寫道:
> >>>
> >>> On 22.06.25 02:42, Nick Huang wrote:
> >>>> Remove Non-LRU Page Migration and Add Movable_ops Page Migration
> >>>>
> >>>
> >>> I'm afraid most people you CC on Chinese doc updates will not be able to
> >>> help in any reasonable way.
> >>>
> >>> --
> >>> Cheers,
> >>>
> >>> David / dhildenb
> >>
> >> How can I fix these things?
> >
> >  From my understanding, you can follow this how-to.rst[1] and submit
> > your patches.
>
> Great, a how-to.rst in a language I don't know. So I assume you meant
> "one can follow", not me in particular. Because I can only parse some
> git commands etc in there that are in English.

Yes, this is only for Nick.

I should mention the name before the massage. Please ignore it.

>
> Which bring us back to the problem: if you CC me (and many others) on
> something that is Chinese, I will not be able to contribute anything of
> value.

Yes. Nick should not cc you in this thread since this is only about
the Chinese content update in my mind.

>
> Quite the opposite, I will ramble about how non-sensical these in-tree
> translations are.
>
> So likely, when you perform a Chinese doc update you want to only CC
> Chinese doc maintainers. Because they can actually provide review I hope.
>
> Maybe that should be clarified in the how-to.rst[1] that I'm afraid I
> cannot read.

This document is listed in the translations/zh_CN/ folder. No one
except the Chinese translators needs to read it.

>
> --
> Cheers,
>
> David / dhildenb
>


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] mm/balloon_compaction: update Chinese docs for movable_ops
  2025-06-23  9:35         ` Dongliang Mu
@ 2025-06-23  9:38           ` David Hildenbrand
  0 siblings, 0 replies; 11+ messages in thread
From: David Hildenbrand @ 2025-06-23  9:38 UTC (permalink / raw)
  To: Dongliang Mu
  Cc: Nick Huang, alexs, si.yanteng, dzm91, corbet, akpm,
	wangkefeng.wang, vishal.moola, linux-doc, linux-kernel, linux-mm

On 23.06.25 11:35, Dongliang Mu wrote:
> On Mon, Jun 23, 2025 at 5:23 PM David Hildenbrand <david@redhat.com> wrote:
>>
>> On 23.06.25 11:12, Dongliang Mu wrote:
>>> On Mon, Jun 23, 2025 at 4:51 PM Nick Huang <sef1548@gmail.com> wrote:
>>>>
>>>> David Hildenbrand <david@redhat.com> 於 2025年6月23日 週一 下午4:08寫道:
>>>>>
>>>>> On 22.06.25 02:42, Nick Huang wrote:
>>>>>> Remove Non-LRU Page Migration and Add Movable_ops Page Migration
>>>>>>
>>>>>
>>>>> I'm afraid most people you CC on Chinese doc updates will not be able to
>>>>> help in any reasonable way.
>>>>>
>>>>> --
>>>>> Cheers,
>>>>>
>>>>> David / dhildenb
>>>>
>>>> How can I fix these things?
>>>
>>>   From my understanding, you can follow this how-to.rst[1] and submit
>>> your patches.
>>
>> Great, a how-to.rst in a language I don't know. So I assume you meant
>> "one can follow", not me in particular. Because I can only parse some
>> git commands etc in there that are in English.
> 
> Yes, this is only for Nick.
> 
> I should mention the name before the massage. Please ignore it.
> 
>>
>> Which bring us back to the problem: if you CC me (and many others) on
>> something that is Chinese, I will not be able to contribute anything of
>> value.
> 
> Yes. Nick should not cc you in this thread since this is only about
> the Chinese content update in my mind.

Ahhhh, got it. Thanks for clarifying.

-- 
Cheers,

David / dhildenb



^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2025-06-23  9:38 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-22  0:42 [PATCH] mm/balloon_compaction: update Chinese docs for movable_ops Nick Huang
2025-06-22 13:33 ` [PATCH v2] " Nick Huang
2025-06-23  2:15   ` Dongliang Mu
2025-06-23  3:23     ` Nick Huang
2025-06-23  8:07 ` [PATCH] " David Hildenbrand
2025-06-23  8:50   ` Nick Huang
2025-06-23  9:12     ` Dongliang Mu
2025-06-23  9:23       ` David Hildenbrand
2025-06-23  9:35         ` Dongliang Mu
2025-06-23  9:38           ` David Hildenbrand
2025-06-23  9:14     ` Dongliang Mu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).