Skip to contentSkip to conversation

Why frontswap and cleancache make copies in tmem?

DISCUSSION Jinchun Kim 3 participants 4 messages Feb 16, 2014 – Feb 17, 2014

lore
Share & tools
lore
#0 lore raw

Hi, All.

While I was digging tmem and its source code, I found suspicious things about frontswap and cleancache. When the guest OS wants to evict either a dirty or clean page, frontswap and cleancache will store it in tmem. The linux kernel document tells that

[Documentation/vm/frontswap.txt]
A “store” will copy the page to transcendent memory ….
A “load” will copy the page, if found, from transcendent memory into kernel memory ...

[Documentation/vm/cleancache.txt]
A “put_page” will copy a page (presumably about-to-be-evicted) page into cleancache ... A “get_page” will copy the page, if found, from cleancache into kernel memory ...

My colleagues and I think copying the page is not necessary (especially for cleancache) because both kernel memory and tmem have same data. Why don’t we just change the pointer to the page and let it belong to tmem? We were wondering if there is any specific reason not to copy the pages to tmem.

Thanks.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#1 lore raw
Quoted 19 lines · Jinchun Kim

Hi, All.

While I was digging tmem and its source code, I found suspicious things about frontswap and cleancache.
When the guest OS wants to evict either a dirty or clean page, frontswap and cleancache will store it in tmem.
The linux kernel document tells that

[Documentation/vm/frontswap.txt]
A "store" will copy the page to transcendent memory ....
A "load" will copy the page, if found, from transcendent memory into kernel memory ...

[Documentation/vm/cleancache.txt]
A "put_page" will copy a page (presumably about-to-be-evicted) page into cleancache ...
A "get_page" will copy the page, if found, from cleancache into kernel memory ...

Quoted 4 lines

My colleagues and I think copying the page is not necessary (especially for cleancache) because both kernel memory and tmem have same data. Why don't we just change the pointer to the page and let it belong to tmem? We were wondering if there is any specific reason not to copy the pages to tmem.

Konrad / Boris? (Sorry, I can't remember the other person who's been sending tmem patches recently.)

-George

#2 lore raw
Quoted 20 lines · George Dunlap
Quoted 19 lines · Jinchun Kim

Hi, All.

While I was digging tmem and its source code, I found suspicious things about frontswap and cleancache.
When the guest OS wants to evict either a dirty or clean page, frontswap and cleancache will store it in tmem.
The linux kernel document tells that

[Documentation/vm/frontswap.txt]
A "store" will copy the page to transcendent memory ....
A "load" will copy the page, if found, from transcendent memory into kernel memory ...

[Documentation/vm/cleancache.txt]
A "put_page" will copy a page (presumably about-to-be-evicted) page into cleancache ...
A "get_page" will copy the page, if found, from cleancache into kernel memory ...

Quoted 7 lines
Quoted 4 lines

My colleagues and I think copying the page is not necessary (especially for cleancache) because both kernel memory and tmem have same data. Why don't we just change the pointer to the page and let it belong to tmem? We were wondering if there is any specific reason not to copy the pages to tmem.

Konrad / Boris? (Sorry, I can't remember the other person who's been sending tmem patches recently.)

Oh, it was Bob Liu. :-)

-George

#3 lore raw
Quoted 16 lines · George Dunlap
Quoted 14 lines · George Dunlap
Quoted 13 lines · Jinchun Kim

Hi, All.

While I was digging tmem and its source code, I found suspicious things about frontswap and cleancache.
When the guest OS wants to evict either a dirty or clean page, frontswap and cleancache will store it in tmem.
The linux kernel document tells that

[Documentation/vm/frontswap.txt]
A "store" will copy the page to transcendent memory ....
A "load" will copy the page, if found, from transcendent memory into kernel memory ...

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

[Documentation/vm/cleancache.txt]
A "put_page" will copy a page (presumably about-to-be-evicted) page into cleancache ...
A "get_page" will copy the page, if found, from cleancache into kernel memory ...

Jinchun, I'm glad you are interested with tmem.

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

My colleagues and I think copying the page is not necessary (especially for cleancache) because both kernel memory and tmem have same data. Why don't we just change the pointer to the page and let it belong to tmem? We were

No, kernel memory won't have the data any more.
For cleancache, the data exist only in tmem and the disk storage.

It's impossible to 'change the pointer to the page and let it belong to tmem', because the page need to be reclaimed by guest os. One possible way is to allocate a new page and return it to guest os, so that we can let the original page belong to tmem instead of copy data. But by this way, there is also some map/unmap cost and will make tmem more complicated.

Welcome any ideas about making tmem better.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

wondering if there is any specific reason not to copy the pages to tmem.

Konrad / Boris? (Sorry, I can't remember the other person who's been sending tmem patches recently.)

Oh, it was Bob Liu. :-)

George, thanks for your cc.

Signature · 2 lines
Regards,
-Bob