BSD 4_2 development
[unix-history] / usr / doc / config / d.t
CommitLineData
c557cacd
C
1.ds LH "Building Systems With Config
2.ds RH "Data Structure Sizing Rules
3.ds CF July 27, 1983
4.LP
5.nr H1 1
6.ds CH "
7.bp
8.ds CH "\(hy \\n(PN \(hy
9.LG
10.B
11.ce
12APPENDIX D. VAX KERNEL DATA STRUCTURE SIZING RULES
13.sp 2
14.R
15.NL
16.PP
17Certain system data structures are sized at compile time
18according to the maximum number of simultaneous users expected,
19while others are calculated at boot time based on the
20physical resources present; e.g. memory. This appendix lists
21both sets of rules and also includes some hints on changing
22built-in limitations on certain data structures.
23.SH
24Compile time rules
25.PP
26The file \fI/sys/conf/param.c\fP contains the definitions of
27almost all data structures sized at compile time. This file
28is copied into the directory of each configured system to allow
29configuration-dependent rules and values to be maintained.
30The rules implied by its contents are summarized below (here
31MAXUSERS refers to the value defined in the configuration file
32in the ``maxusers'' rule).
33.IP \fBnproc\fP
34.br
35The maximum number of processes which may be running at
36any time. It is defined to be 20 + 8 * MAXUSERS and referred
37to in other calculations as NPROC.
38.IP \fBntext\fP
39.br
40The maximum number of active shared text segments. Defined as
4124 + MAXUSERS + NETSLOP, where NETSLOP is 20 when the Internet
42protocols are configured in the system and 0 otherwise. The
43added size for supporting the network is to take into account
44the numerous server processes which are likely to exist.
45.IP \fBninode\fP
46.br
47The maximum number of files in the file system which may be
48active at any time. This includes files in use by users, as
49well as directory files being read or written by the system
50and files associated with bound sockets in the UNIX ipc domain.
51This is defined as (NPROC + 16 + MAXUSERS) + 32.
52.IP \fBnfile\fP
53.br
54The number of ``file table'' structures. One file
55table structure is used for each open, unshared, file descriptor.
56Multiple file descriptors may reference a single file table
57entry when they are created through a \fIdup\fP call, or as the
58result of a \fIfork\fP. This is defined to be
59.DS
6016 * (NPROC + 16 + MAXUSERS) / 10 + 32 + 2 * NETSLOP
61.DE
62where NETSLOP is defined as for \fBntext\fP.
63.IP \fBncallout\fP
64.br
65The number of ``callout'' structures. One callout
66structure is used per internal system event handled with
67a timeout. Timeouts are used for terminal delays,
68watchdog routines in device drivers, protocol timeout processing, etc.
69This is defined as 16 + NPROC.
70.IP \fBnclist\fP
71.br
72The number of ``c-list'' structures. C-list structures are
73used in terminal i/o. This is defined as 100 + 16 * MAXUSERS.
74.IP \fBnmbclusters\fP
75.br
76The maximum number of pages which may be allocated by the network.
77This is defined as 256 (a quarter megabyte of memory) in /sys/h/mbuf.h.
78In practice, the network rarely uses this much memory. It starts off
79by allocating 64 kilobytes of memory, then requesting more as
80required. This value represents an upper bound.
81.IP \fBnquota\fP
82.br
83The number of ``quota'' structures allocated. Quota structures
84are present only when disc quotas are configured in the system. One
85quota structure is kept per user. This is defined to be
86(MAXUSERS * 9) / 7 + 3.
87.IP \fBndquot\fP
88.br
89The number of ``dquot'' structures allocated. Dquot structures
90are present only when disc quotas are configured in the system.
91One dquot structure is required per user, per active file system quota.
92That is, when a user manipulates a file on a file system on which
93quotas are enabled, the information regarding the user's quotas on
94that file system must be in-core. This information is cached, so
95that not all information must be present in-core all the time.
96This is defined as (MAXUSERS * NMOUNT) / 4 + NPROC, where NMOUNT
97is the maximum number of mountable file systems.
98.LP
99In addition to the above values, the system page tables (used to
100map virtual memory in the kernel's address space) are sized at
101compile time by the SYSPTSIZE definition in the file /sys/vax/param.h.
102This is defined to be 20 + MAXUSERS pages of page tables.
103Its definition affects
104the size of many data structures allocated at boot time because
105it constrains the amount of virtual memory which may be addressed
106by the running system. This is often the limiting factor
107in the size of the buffer cache.
108.SH
109Run-time calculations
110.PP
111The most important data structures sized at run-time are those used in
112the buffer cache. Allocation is done by swiping physical memory
113(and the associated virtual memory) immediately after the system
114has been started up; look in the file /sys/vax/machdep.c.
115The amount of physical memory which may be allocated to the buffer
116cache is constrained by the size of the system page tables, among
117other things. While the system may calculate
118a large amount of memory to be allocated to the buffer cache,
119if the system page
120table is too small to map this physical
121memory into the virtual address space
122of the system, only as much as can be mapped will be used.
123.PP
124The buffer cache is comprised of a number of ``buffer headers''
125and a pool of pages attached to these headers. Buffer headers
126are divided into two categories: those used for swapping and
127paging, and those used for normal file i/o. The system tries
128to allocate 10% of available physical memory for the buffer
129cache (where \fIavailable\fP does not count that space occupied by
130the system's text and data segments). If this results in fewer
131than 16 pages of memory allocated, then 16 pages are allocated.
132This value is kept in the initialized variable \fIbufpages\fP
133so that it may be patched in the binary image (to allow tuning
134without recompiling the system). A sufficient number of
135file i/o buffer headers are then allocated to allow each to hold
1362 pages each, and half as many swap i/o buffer headers are then
137allocated. The number of swap i/o buffer headers is constrained
138to be no more than 256.
139.SH
140System size limitations
141.PP
142As distributed, the sum of the virtual sizes of the core-resident
143processes is limited to 64M bytes. The size of the text, and data
144segments of a single process are currently limited to 6M bytes each, and
145the stack segment size is limited to 512K bytes as a soft, user-changeable
146limit, and may be increased to 6M with the \fIsetrlimit\fP\|(2) system call.
147If these are insufficient, they
148can be increased by changing the constants MAXTSIZ, MAXDSIZ and MAXSSIZ
149in the file
150/sys/vax/vmparam.h, while
151changing the definitions in
152/sys/h/dmap.h and /sys/h/text.h.
153You must be careful in doing this that you have adequate paging space.
154As normally configured , the system has only 16M bytes per paging area.
155The best way to get more space is to provide multiple, thereby
156interleaved, paging areas.
157.PP
158To increase the amount of resident virtual space possible,
159you can alter the constant USRPTSIZE (in
160/sys/vax/vmparam.h).
161To allow 128 megabytes of resident virtual space one would
162change the 8 to a 16.
163.PP
164Because the file system block numbers are stored in
165page table \fIpg_blkno\fP
166entries, the maximum size of a file system is limited to
1672^19 1024 byte blocks. Thus no file system can be larger than 512M bytes.
168.PP
169The count of mountable file systems is limited to 15. This should
170be sufficient. If you have many disks it makes sense to make some of
171them single file systems, and the paging areas don't count in this total.
172To increase this it will be necessary to change the core-map
173/sys/h/cmap.h since there is a 4 bit field used here. The size
174of the core-map will then expand to 16 bytes per 1024 byte page.
175(Don't forget to change MSWAPX and NMOUNT in /sys/h/param.h also.)
176.PP
177The maximum value NOFILE (open files per process limit)
178can be raised to
179is 30 because of a bit field in the page table entry in
180/sys/machine/pte.h.