Commit | Line | Data |
---|---|---|
4d554349 NW |
1 | swapinfo |
2 | ======== | |
3 | ||
4 | Swapinfo is designed to provide some information to the user about the | |
5 | state of the swap space on the system. I've written it based on a | |
6 | brief (!) perusal of the VM code in 386BSD. I could be pretty confused | |
7 | about how it all fits together, and perhaps this is totally bogus. | |
8 | It seems to work for me, though. | |
9 | ||
10 | How it works: | |
11 | ||
12 | During startup, the system traverses the list of configured swap partitions, | |
13 | and determines the size of the various partitions. As each new partition | |
14 | is added for swapping (via swapon), the free space on that disk is added | |
15 | to a linked list of free space. Adjacent areas are coalesced to form | |
16 | larger areas. The swapping algorithm seems to take the first free section | |
17 | that it finds [?]. | |
18 | ||
19 | Swapinfo reads in the list of configured swap partitions from the /dev/kmem, | |
20 | to determine the size of the partitions. It then traverses the list | |
21 | of free space, figuring up how much is still available and how much | |
22 | has therefore been used. Things get a little hairy in that the swap space | |
23 | is divided amongst the configured swap partitions so that the first | |
24 | 4096 blocks of swap go on the first swap partition, the second 4096 on | |
25 | the second swap partition, and so on. This works out to be a fairly | |
26 | simple bit of code, though. | |
27 | ||
28 | More caveats: | |
29 | ||
30 | This works on my system. Your milage may vary. Since I'm reading /dev/kmem | |
31 | to follow a linked list, the program could easily get lost looking for | |
32 | some free space if anything got changed between reads of /dev/kmem. | |
33 | If you get occasional inconsistant results, ignore 'em. | |
34 | ||
35 | Feel free to send bug reports, flames, etc., to: | |
36 | ||
37 | Kevin Lahey | |
38 | kml@rokkaku.atl.ga.us |