Performance: calc_kernel_shm.sh

File calc_kernel_shm.sh, 901 bytes (added by Dimitar Misev, 11 years ago)
Line 
1#!/bin/bash
2# Output lines suitable for sysctl configuration based
3# on total amount of RAM on the system. The output
4# will allow up to 50% of physical memory to be allocated
5# into shared memory.
6
7# On Linux, you can use it as follows (as root):
8#
9# ./shmsetup >> /etc/sysctl.conf
10# sysctl -p
11
12# Early FreeBSD versions do not support the sysconf interface
13# used here. The exact version where this works hasn't
14# been confirmed yet.
15
16page_size=`getconf PAGE_SIZE`
17phys_pages=`getconf _PHYS_PAGES`
18
19if [ -z "$page_size" ]; then
20echo Error: cannot determine page size
21exit 1
22fi
23
24if [ -z "$phys_pages" ]; then
25echo Error: cannot determine number of memory pages
26exit 2
27fi
28
29shmall=`expr $phys_pages / 2`
30shmmax=`expr $shmall \* $page_size`
31
32echo \# Maximum shared segment size in bytes
33echo kernel.shmmax = $shmmax
34echo \# Maximum number of shared memory segments in pages
35echo kernel.shmall = $shmall
36