* shmfs/tmpfs/vm-fs @ 2001-12-06 15:54 der erste Schuettler 2001-12-07 10:51 ` shmfs/tmpfs/vm-fs Christoph Rohland 0 siblings, 1 reply; 6+ messages in thread From: der erste Schuettler @ 2001-12-06 15:54 UTC (permalink / raw) To: linux-mm hi all, How is SysV sharedmem implemented and how/why is shmfs/tmpfs integrated in this topic? A file in the shmfs/tmpfs is created with the required size and then with mmap mapped into the prozessspace? thanks lothar:x -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: shmfs/tmpfs/vm-fs 2001-12-06 15:54 shmfs/tmpfs/vm-fs der erste Schuettler @ 2001-12-07 10:51 ` Christoph Rohland 2001-12-07 11:37 ` shmfs/tmpfs/vm-fs der erste Schuettler 0 siblings, 1 reply; 6+ messages in thread From: Christoph Rohland @ 2001-12-07 10:51 UTC (permalink / raw) To: lothar.maerkle; +Cc: linux-mm [-- Attachment #1: Type: text/plain, Size: 498 bytes --] Hi der, On Thu, 6 Dec 2001, der erste Schuettler wrote: > How is SysV sharedmem implemented and how/why is > shmfs/tmpfs integrated in this topic? shmem.c (^=tmpfs) is the implementation used by the SYSV SHM user space API. > A file in the shmfs/tmpfs is created with the required size and then > with mmap mapped into the prozessspace? Yes. shmget does create and size a tmpfs file and shmat maps it. See the appended tmpfs.txt which was just included into 2.4.17-pre Greetings Christoph [-- Attachment #2: tmpfs.txt --] [-- Type: text/plain, Size: 4181 bytes --] Tmpfs is a file system which keeps all files in virtual memory. Everything in tmpfs is temporary in the sense that no files will be created on your hard drive. If you unmount a tmpfs instance, everything stored therein is lost. tmpfs puts everything into the kernel internal caches and grows and shrinks to accommodate the files it contains and is able to swap unneeded pages out to swap space. It has maximum size limits which can be adjusted on the fly via 'mount -o remount ...' If you compare it to ramfs (which was the template to create tmpfs) you gain swapping and limit checking. Another similar thing is the RAM disk (/dev/ram*), which simulates a fixed size hard disk in physical RAM, where you have to create an ordinary filesystem on top. Ramdisks cannot swap and you do not have the possibility to resize them. Since tmpfs lives completely in the page cache and on swap, all tmpfs pages currently in memory will show up as cached. It will not show up as shared or something like that. Further on you can check the actual RAM+swap use of a tmpfs instance with df(1) and du(1). tmpfs has the following uses: 1) There is always a kernel internal mount which you will not see at all. This is used for shared anonymous mappings and SYSV shared memory. This mount does not depend on CONFIG_TMPFS. If CONFIG_TMPFS is not set, the user visible part of tmpfs is not build. But the internal mechanisms are always present. 2) glibc 2.2 and above expects tmpfs to be mounted at /dev/shm for POSIX shared memory (shm_open, shm_unlink). Adding the following line to /etc/fstab should take care of this: tmpfs /dev/shm tmpfs defaults 0 0 Remember to create the directory that you intend to mount tmpfs on if necessary (/dev/shm is automagically created if you use devfs). This mount is _not_ needed for SYSV shared memory. The internal mount is used for that. (In the 2.3 kernel versions it was necessary to mount the predecessor of tmpfs (shm fs) to use SYSV shared memory) 3) Some people (including me) find it very convenient to mount it e.g. on /tmp and /var/tmp and have a big swap partition. But be aware: loop mounts of tmpfs files do not work due to the internal design. So mkinitrd shipped by most distributions will fail with a tmpfs /tmp. 4) And probably a lot more I do not know about :-) tmpfs has a couple of mount options: size: The limit of allocated bytes for this tmpfs instance. The default is half of your physical RAM without swap. If you oversize your tmpfs instances the machine will deadlock since the OOM handler will not be able to free that memory. nr_blocks: The same as size, but in blocks of PAGECACHE_SIZE. nr_inodes: The maximum number of inodes for this instance. The default is half of the number of your physical RAM pages. These parameters accept a suffix k, m or g for kilo, mega and giga and can be changed on remount. To specify the initial root directory you can use the following mount options: mode: The permissions as an octal number uid: The user id gid: The group id These options do not have any effect on remount. You can change these parameters with chmod(1), chown(1) and chgrp(1) on a mounted filesystem. So 'mount -t tmpfs -o size=10G,nr_inodes=10k,mode=700 tmpfs /mytmpfs' will give you tmpfs instance on /mytmpfs which can allocate 10GB RAM/SWAP in 10240 inodes and it is only accessible by root. TODOs: 1) give the size option a percent semantic: If you give a mount option size=50% the tmpfs instance should be able to grow to 50 percent of RAM + swap. So the instance should adapt automatically if you add or remove swap space. 2) loop mounts: This is difficult since loop.c relies on the readpage operation. This operation gets a page from the caller to be filled with the content of the file at that position. But tmpfs always has the page and thus cannot copy the content to the given page. So it cannot provide this operation. The VM had to be changed seriously to achieve this. 3) Show the number of tmpfs RAM pages. (As shared?) Author: Christoph Rohland <cr@sap.com>, 1.12.01 ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: shmfs/tmpfs/vm-fs 2001-12-07 10:51 ` shmfs/tmpfs/vm-fs Christoph Rohland @ 2001-12-07 11:37 ` der erste Schuettler 2001-12-07 15:07 ` shmfs/tmpfs/vm-fs Christoph Rohland 0 siblings, 1 reply; 6+ messages in thread From: der erste Schuettler @ 2001-12-07 11:37 UTC (permalink / raw) To: Christoph Rohland; +Cc: linux-mm hi thanks for the paper but, with sysvipc, are msyncs still needed, to keep the shared pages in sync with the file on the tmpfs? You could use the same pages for all... tmpfs ist cool, is it possible to change the permissions on an shared object or istead of shmctl IPC_RMID just use rm /de/shm/SYSVblablub? -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: shmfs/tmpfs/vm-fs 2001-12-07 11:37 ` shmfs/tmpfs/vm-fs der erste Schuettler @ 2001-12-07 15:07 ` Christoph Rohland 2001-12-08 6:39 ` shmfs/tmpfs/vm-fs H. Peter Anvin 0 siblings, 1 reply; 6+ messages in thread From: Christoph Rohland @ 2001-12-07 15:07 UTC (permalink / raw) To: lothar.maerkle; +Cc: linux-mm Hi Lothar, On Fri, 7 Dec 2001, der erste Schuettler wrote: > thanks for the paper but, with sysvipc, are msyncs still needed, to > keep the shared pages in sync with the file on the tmpfs? Of course not. sync on tmpfs does nothing. > You could use the same pages for all... tmpfs ist cool, is it > possible to change the permissions on an shared object or istead of > shmctl IPC_RMID just use rm /de/shm/SYSVblablub? It was possible in some 2.3 kernels, but this had to be removed with the cleanup :-( Greetings Christoph -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: shmfs/tmpfs/vm-fs 2001-12-07 15:07 ` shmfs/tmpfs/vm-fs Christoph Rohland @ 2001-12-08 6:39 ` H. Peter Anvin 2001-12-08 9:54 ` shmfs/tmpfs/vm-fs Christoph Rohland 0 siblings, 1 reply; 6+ messages in thread From: H. Peter Anvin @ 2001-12-08 6:39 UTC (permalink / raw) To: Christoph Rohland; +Cc: lothar.maerkle, linux-mm Christoph Rohland wrote: > > It was possible in some 2.3 kernels, but this had to be removed with > the cleanup :-( > I guess I really still don't understand why. I certainly can understand that it would be highly undesirable if it had to be supported before /dev/shm is mounted, but I don't see any reason to allow SysV shared memory before mounting /dev/shm. -hpa -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: shmfs/tmpfs/vm-fs 2001-12-08 6:39 ` shmfs/tmpfs/vm-fs H. Peter Anvin @ 2001-12-08 9:54 ` Christoph Rohland 0 siblings, 0 replies; 6+ messages in thread From: Christoph Rohland @ 2001-12-08 9:54 UTC (permalink / raw) To: H. Peter Anvin; +Cc: lothar.maerkle, linux-mm Hi hpa, On Fri, 07 Dec 2001, H. Peter Anvin wrote: > Christoph Rohland wrote: > >> It was possible in some 2.3 kernels, but this had to be removed >> with the cleanup :-( > > I guess I really still don't understand why. It is mainly a matter of simplicity: Filesystem semantics differ considerably from the SYSV semantics and I can assure you that the old implementation was a nightmare to maintain and keep compatible with all the little oddities of SYSV shm. E.g. there is a creator id which you cannot change and which is always allowed to control the opject. Also the Linux feature, that you can SHM_RMID a segment but still access is with its id as long as there are references is pretty unusual for filesystems. So I had to realise that the SYSV shm API does _not_ correspond to files in a directory, but it more an open struct file without a linked directory entry. This struct file is managed by the SYSV ipc module and the user can access it via shmat. This model works out quite naturally. The whole interface between ipc/shm.c and mm/shmem.c is shmem_file_setup, shmem_nopage and shmem_lock! shmem does not know anything about SYSV and its weird semantics. > I certainly can understand that it would be highly undesirable if it > had to be supported before /dev/shm is mounted, but I don't see any > reason to allow SysV shared memory before mounting /dev/shm. I would like this behaviour as well, but it would mean to complicate the whole thing more than it's worth. Greetings Christoph -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2001-12-08 9:54 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2001-12-06 15:54 shmfs/tmpfs/vm-fs der erste Schuettler 2001-12-07 10:51 ` shmfs/tmpfs/vm-fs Christoph Rohland 2001-12-07 11:37 ` shmfs/tmpfs/vm-fs der erste Schuettler 2001-12-07 15:07 ` shmfs/tmpfs/vm-fs Christoph Rohland 2001-12-08 6:39 ` shmfs/tmpfs/vm-fs H. Peter Anvin 2001-12-08 9:54 ` shmfs/tmpfs/vm-fs Christoph Rohland
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox