Skip to contentSkip to conversation

/dev/anon available

uml-devel BlaisorBlade 2 participants 5 messages Jan 17, 2004 – Jan 20, 2004 1 message not in the archive User-mode Linux (UML)

lore
Share & tools
lore
#1 lore raw
In reply to a message not in the archive

Alle 06:10, martedì 13 gennaio 2004, Jeff Dike ha scritto:

Quoted 10 lines

I released two /dev/anon patches today - one for stock 2.4.23 and one for RH8 2.4.8-14.

In short, /dev/anon is a device which UML can map its physical memory from and which can free dirty pages back to the host. In conjunction with 'ubd=mmap', this can noticably reduce the memory consumption of UMLs on the host. See http://user-mode-linux.sourceforge.net/devanon.html for more details.

This requires the next version of UML, which will be released shortly.

I've given a look to the page, but yet I cannot see (this can be for my fault, but I'd really like an explaination of this) why you couldn't just mmap /dev/zero with MAP_PRIVATE to get the behaviour you want to get from /dev/anon (or maybe using MAP_ANONYMOUS). When you munmap a page, that goes out of your address space, so it cannot be dirty any more dirty. Also, with mmap you cannot modify /dev/zero, as it's a special case (mmap'ing that gives you a COW reference to the zero-filled page).

Beyond, I've checked that munmap works even for partial unmapping of files. So you could even mmap it as a single chunk (or better two chunks, read-only and read-write memory on i386; it would be harder on other arch's), at the end and munmap to free any page (that splits the old mapping into two new ones that map the pages around the unmapped ones). The problem is that using this means you cannot do mremap to enlarge mapped space, since in that case you don't know which mapping to remap (if you don't track it by hand, which would be actually hard).

Bye

Signature · 16 lines
cat <<EOSIGN
Paolo Giarrusso, aka Blaisorblade
Linux Kernel 2.4.23/2.6.0 on an i686; Linux registered user n. 292729
EOSIGN



-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
User-mode-linux-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
#2 lore raw
Quoted 4 lines · BlaisorBlade

I've given a look to the page, but yet I cannot see (this can be for my fault, but I'd really like an explaination of this) why you couldn't just mmap /dev/zero with MAP_PRIVATE to get the behaviour you want to get from /dev/anon (or maybe using MAP_ANONYMOUS).

Because when you map a /dev/zero page, modify it, then map it (i.e. the same offset and the same fd) again someplace else, you don't get the modifications.
You get a page full of zeros. This obviously breaks the UML VM system.

Jeff

-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004 Premiere Conference on Open Tools Development and Integration See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
User-mode-linux-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

#3 lore raw

Alle 05:54, domenica 18 gennaio 2004, Jeff Dike ha scritto:

Quoted 10 lines · BlaisorBlade
Quoted 4 lines

I've given a look to the page, but yet I cannot see (this can be for my fault, but I'd really like an explaination of this) why you couldn't just mmap /dev/zero with MAP_PRIVATE to get the behaviour you want to get from /dev/anon (or maybe using MAP_ANONYMOUS).

Because when you map a /dev/zero page, modify it, then map it (i.e. the same offset and the same fd) again someplace else, you don't get the
modifications. You get a page full of zeros. This obviously breaks the
UML VM system.

Yes, that's obvious with MAP_PRIVATE (and using MAP_SHARED would be meaningless, if at all worked). But I wasn't aware you needed to map the same region twice; I guess this is done for pages shared (even with copy on write) between different processes inside UML, right? Also, since with skas the mm_struct's of the virtual processes have nothing in common, they cannot

However, have you asked to Linus if he likes /dev/anon? Maybe he'll suggest another interface for the same need (like when you two discussed skas4).

Signature · 17 lines
cat <<EOSIGN
Paolo Giarrusso, aka Blaisorblade
Linux Kernel 2.4.23/2.6.0 on an i686; Linux registered user n. 292729
EOSIGN




-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
User-mode-linux-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
#4 lore raw
Quoted 4 lines · BlaisorBlade

Yes, that's obvious with MAP_PRIVATE (and using MAP_SHARED would be meaningless, if at all worked). But I wasn't aware you needed to map the same region twice; I guess this is done for pages shared (even with copy on write) between different processes inside UML, right?

Pages are shared all over the place. Pages are mapped into
the UML physical memory region (the entire file as one chunk) the UML virtual memory region (in response to vmalloc) UML processes

They can be shared between processes
between a fork and exec
as shared memory
as shared readonly data (i.e. program text)

Quoted 2 lines

Also, since with skas the
mm_struct's of the virtual processes have nothing in common, they cannot

What do you mean by this?

Quoted 2 lines

However, have you asked to Linus if he likes /dev/anon? Maybe he'll suggest another interface for the same need (like when you two discussed skas4).

No, I haven't. I did get a reaction from the tmpfs author. He wasn't too fond of the interface, but didn't immediately have any better suggestions.

I'm not too fond of it either, but it's the best I could think of off the top of my head.

Jeff

-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004 Premiere Conference on Open Tools Development and Integration See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
User-mode-linux-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

#5 lore raw

Alle 00:53, lunedì 19 gennaio 2004, Jeff Dike ha scritto:

Quoted 4 lines · BlaisorBlade

Pages are shared all over the place.
[...]

Thanks for the info.

Quoted 4 lines
Quoted 2 lines

Also, since with skas the
mm_struct's of the virtual processes have nothing in common, they cannot

What do you mean by this?

Sorry, nothing (I was writing of an idea about MAP_ANON, but dropped almost all the sentence).

Signature · 16 lines
cat <<EOSIGN
Paolo Giarrusso, aka Blaisorblade
Linux Kernel 2.4.23/2.6.0 on an i686; Linux registered user n. 292729
EOSIGN



-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
User-mode-linux-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel