Skip to content

Commit

Permalink
Add notes for section 12.7.
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo-stoakes committed May 9, 2016
1 parent 43f53eb commit 82863e1
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions 12.md
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,26 @@ ENTRIES_PER_PAGE/2 | |-- - -- - -- - -- - | | --------------- | | -------
function then decrements the parent directory `struct inode->i_nlink` count
and calls [shmem_unlink()][shmem_unlink] to remove it.

## 12.7 Setting Up Shared Regions

* A shared region is backed by a file created in `shm`.

* There are two cases where a new file will be created - during the setup of a
shared region via (userland) [shmget()][shmget] or when an anonymous region is
set up via (userland) [mmap()][mmap] with the `MAP_SHARED` flag specified.

* Both approaches ultimately use [shmem_file_setup()][shmem_file_setup] to
create a file, which simply creates a new [struct dentry][dentry] and
[struct inode][inode], fills in the relevant details and instantiates them.

* Because the file system is internal, the names of the files created do _not_
have to be unique as the files are always located by inode, not name. As a
result, [shmem_zero_setup()][shmem_zero_setup] always creates a file
`"dev/zero"` which is how it shows up in `/proc/<pid>/maps`.

* Files created by `shmget()` are named `SYSV<NN>` where `<NN>` is the key that
is passed as a parameter to `shmget()`.

[mmap]:http://man7.org/linux/man-pages/man2/mmap.2.html
[fork]:http://man7.org/linux/man-pages/man2/fork.2.html
[shmget]:http://man7.org/linux/man-pages/man2/shmget.2.html
Expand Down Expand Up @@ -567,3 +587,6 @@ ENTRIES_PER_PAGE/2 | |-- - -- - -- - -- - | | --------------- | | -------
[shmem_rmdir]:https://github.com/lorenzo-stoakes/linux-historical/blob/v2.4.22/mm/shmem.c#L1232
[shmem_empty]:https://github.com/lorenzo-stoakes/linux-historical/blob/v2.4.22/mm/shmem.c#L1201
[shmem_unlink]:https://github.com/lorenzo-stoakes/linux-historical/blob/v2.4.22/mm/shmem.c#L1221

[shmem_file_setup]:https://github.com/lorenzo-stoakes/linux-historical/blob/v2.4.22/mm/shmem.c#L1607
[shmem_zero_setup]:https://github.com/lorenzo-stoakes/linux-historical/blob/v2.4.22/mm/shmem.c#L1664

0 comments on commit 82863e1

Please sign in to comment.