4 # Copyright (C) 2007 Karel Zak <kzak@redhat.com>
6 # This file is part of util-linux-ng.
8 # This file is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 2 of the License, or
11 # (at your option) any later version.
13 # This file is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
19 PAGE_SIZE=$($TS_HELPER_SYSINFO pagesize)
23 /proc/sys/kernel/shmmni
24 /proc/sys/kernel/shmall
25 /proc/sys/kernel/shmmax
28 # raw data converted to ipcs-like format
30 # shmall = from pages to KBytes
31 # shmmax = from bytes to KBytes
34 "cat /proc/sys/kernel/shmmni"
35 "echo \$(cat /proc/sys/kernel/shmall) / 1024 \* $PAGE_SIZE | bc -l | sed 's/\..*//'"
36 "echo \$(cat /proc/sys/kernel/shmmax) / 1024 | bc -l | sed 's/\..*//'"
39 # data from the ipcs command
41 "$TS_CMD_IPCS -m -l | awk '/max number of segments/ { print \$6 }'"
42 "$TS_CMD_IPCS -m -l | awk '/max total shared memory/ { print \$7 }'"
43 "$TS_CMD_IPCS -m -l | awk '/max seg size/ { print \$6 }'"
47 # The linux kernel accepts ULONG_MAX, but this value is same like ULLONG_MAX on
48 # 64-bit archs. So the ipcs command has to always overflow on 64-bit archs when
49 # shmall (=num of pages!) is same or almost same like ULONG_MAX. This is reason
50 # why we for the test uses 32-bit limits on all archs.
52 # (Don't worry that 64-bit ULONG_MAX makes ipcs useless ...
53 # ... it's a problem for admins who want to use 75557863725TB of RAM for shm)
56 $($TS_HELPER_SYSINFO INT_MAX)
57 $($TS_HELPER_SYSINFO ULONG_MAX32)
58 $($TS_HELPER_SYSINFO ULONG_MAX32)
61 # list of indexes = 0..(sizeof Array - 1)
62 IPCS_IDX=$(seq 0 $(( ${#IPCS_PROCFILES[*]} - 1 )))
65 function ipcs_limits_check {
66 for i in $IPCS_IDX; do
67 echo -n ${IPCS_PROCFILES[$i]}
69 a=$(eval ${IPCS_KERNEL_CMD[$i]})
70 b=$(eval ${IPCS_CMD[$i]})
73 #cat ${IPCS_PROCFILES[$i]}
74 #echo "CMD: ${ICPS_KERNEL_CMD[$i]}"
76 if [ x"$a" == x"$b" ]; then
79 echo " kernel=$a, ipcs=$b"