Old Linux tuning notes
Published (last updated )
pam_limits domains:
- user — limit an individual user
- group — limit a group
- wildcard — limit in general
pam_limits types:
- hard — user cannot raise his requirement of system resources above this
- soft — the user can move up or down within the permitted range
- both — for enforcing both soft and hard resource limits together (-)
pam_limits items:
- core — limits the core file size (KB)
- data — maximum data size (KB)
- fsize — maximum filesize (KB)
- memlock — maximum locked-in-memory address space (KB)
- nofile — maximum number of open files
- rss — maximum resident set size (KB) (Ignored in 2.4.30 and higher)
- stack — maximum stack size (KB)
- cpu — maximum CPU time (minutes)
- nproc — maximum number of processes
- as — address space limit
- maxlogins — maximum number of logins for this user
- maxsyslogins — maximum number of logins on system
- priority — priority for user process (negative = boost process priority)
- locks — maximum locked files (Linux 2.4 and higher)
- sigpending — maximum number of pending signals (Linux 2.6 and higher)
- msqqueue — maximum memory used by POSIX message queues (bytes)
- nice — maximum nice priority allowed to raise to
- rtprio — maximum realtime priority allowed for non-privileged processes
util-linux:
- taskset — set cpu affinity for a given process to run only on n cpus
- chrt — change scheduling type (sched_setscheduler) for given process
- ionice — set scheduler class (see below) of given process (cfq ONLY!)
- (re)nice — set a groups’, users’ or processes’ scheduling priority (-20-+20)
cfq io scheduler classes:
- IDLE — will only get disk time when no other program has asked for io: 3
- BEST_EFFORT — default scheduling class for any process: 2
- REAL_TIME — given first access to the disk regardless of what else’s goin on: 1
io scheduler types:
- cfq — attempts to distribute available IO equally among all IO requests
- deadline — tries to minimize IO latency for any given IO request, aggr reorder
- noop — fifo, minimal amount of CPU/instructions per IO (request merging)
- as — tries to aggregate and reorder requests using controlled delay
process sched_setscheduler types:
- SCHED_FIFO — will always immediately preempt any currently running process: 1-99
- SCHED_RR — like above, but with time-slicing, if longer than t, resched: 1-99
- SCHED_OTHER — the default universal time-sharing scheduler policy used by most: 0
- SCHED_BATCH — intended for “batch” style execution of processes: 0
notes:
All limit settings are set per login. They are not global, nor are they permanent; existing only for the duration of a session.
A static priority value sched_priority is assigned to each process and this value can be changed only via system calls. Conceptually, the scheduler maintains a list of runnable processes for each possible sched_priority value, and sched_priority can have a value in the range 0 to 99. In order to determine the process that runs next, the Linux scheduler looks for the non-empty list with the highest static priority and takes the process at the head of this list. The scheduling policy determines for each process, where it will be inserted into the list of processes with equal static priority and how it will move inside this list.
A blocked high priority process waiting for the I/O has a certain response time before it is scheduled again.
Child processes inherit the scheduling algorithm and parameters across a fork(). The scheduling algorithm and parameters are preserved across execve(2).
As a non-blocking end-less loop in a process scheduled under SCHED_FIFO or SCHED_RR will block all processes with lower priority forever, a software developer should always keep available on the console a shell scheduled under a higher static priority than the tested application. This will allow an emergency kill of tested real-time applications that do not block or terminate as expected.
Standard Linux is not designed to support hard real-time applications, that is, applications in which deadlines (often much shorter than a second) must be guaranteed or the system will fail catastrophically. Like all general-purpose operating systems, Linux is designed to maxi- mize average case performance instead of worst case performance. Linux’s worst case performance for interrupt handling is much poorer than its average case, its various kernel locks (such as for SMP) pro- duce long maximum wait times, and many of its performance improvement techniques decrease average time by increasing worst-case time. For most situations, that’s what you want, but if you truly are developing a hard real-time application, consider using hard real-time extensions to Linux such as RTLinux or RTAI or use a different operating system designed specifically for hard real-time applications.
links: