Determining rlimit (ulimit) values for a running process
Question
How can I find out what limits are set for a currently running process?
Answer
The easiest way is to download the pdump.sh script and run it against the process. The pdump tool can be downloaded from here:
ftp://ftp.software.ibm.com/aix/tools/debug/
There is no installation needed, only to change the permissions of the file so it can be executed:
$ chmod +x pdump.sh
Then run it against the process-id (PID) of the process you wish to examine. The pdump.sh script will create an output file containing information regarding that process.
# ./pdump.sh 3408030
The output file will contain the name of the process, the PID and the current date. For example:
pdump.tier1slp.3408030.13May2015-11.18.13.out
This is an ASCII text file and can be inspected with "more" or "view".
Determining the limit values
Limits in a process are kept in the user area or "uarea" of the process memory. This section in the pdump output starts with the title "Resource limits:"
Resource limits:
fsblimit....00000000001FFFFF
rlimit[CPU]........... cur 7FFFFFFF max 7FFFFFFF
saved_rlimit[CPU]..... cur 7FFFFFFFFFFFFFFF max 7FFFFFFFFFFFFFFF
rlimit_flag[CPU]...... cur INF max INF
rlimit[FSIZE]......... cur 3FFFFE00 max 3FFFFE00
saved_rlimit[FSIZE]... cur 000000003FFFFE00 max 000000003FFFFE00
rlimit_flag[FSIZE].... cur SML max SML
rlimit[DATA].......... cur 08000000 max 7FFFFFFF
saved_rlimit[DATA].... cur 0000000008000000 max 7FFFFFFFFFFFFFFF
rlimit_flag[DATA]..... cur SML max INF
rlimit[STACK]......... cur 02000000 max 7FFFFFFF
saved_rlimit[STACK]... cur 0000000002000000 max 0000000100000000
rlimit_flag[STACK].... cur SML max MAX
rlimit[CORE].......... cur 3FFFFE00 max 7FFFFFFF
saved_rlimit[CORE].... cur 000000003FFFFE00 max 7FFFFFFFFFFFFFFF
rlimit_flag[CORE]..... cur SML max INF
rlimit[RSS]........... cur 02000000 max 7FFFFFFF
saved_rlimit[RSS]..... cur 0000000002000000 max 7FFFFFFFFFFFFFFF
rlimit_flag[RSS]...... cur SML max INF
rlimit[AS]............ cur 7FFFFFFF max 7FFFFFFF
saved_rlimit[AS]...... cur 0000000000000000 max 0000000000000000
rlimit_flag[AS]....... cur INF max INF
rlimit[NOFILE]........ cur 000007D0 max 7FFFFFFF
saved_rlimit[NOFILE].. cur 00000000000007D0 max 7FFFFFFFFFFFFFFF
rlimit_flag[NOFILE]... cur SML max INF
rlimit[THREADS]....... cur 7FFFFFFF max 7FFFFFFF
saved_rlimit[THREADS]. cur 0000000000000000 max 0000000000000000
rlimit_flag[THREADS].. cur INF max INF
rlimit[NPROC]......... cur 7FFFFFFF max 7FFFFFFF
saved_rlimit[NPROC]... cur 0000000000000000 max 0000000000000000
rlimit_flag[NPROC].... cur INF max INF
The resource limit for each ulimit value is represented here. As values could be either 32-bit or 64-bit, the include file /usr/include/sys/user.h tells us how to read them:
/*
* To maximize compatibility with old kernel code, a 32-bit
* representation of each resource limit is maintained in U_rlimit.
* Should the limit require a 64-bit representation, the U_rlimit
* value is set to RLIM_INFINITY, with actual 64-bit limit being
* stored in U_saved_rlimit. These flags indicate what
* the real situation is:
*
* RLFLAG_SML => limit correctly represented in 32-bit U_rlimit
* RLFLAG_INF => limit is infinite
* RLFLAG_MAX => limit is in 64_bit U_saved_rlimit.rlim_max
* RLFLAG_CUR => limit is in 64_bit U_saved_rlimit.rlim_cur
So using this and our pdump output, we can view the value of NOFILE for example:
rlimit[NOFILE]........ cur 000007D0 max 7FFFFFFF
saved_rlimit[NOFILE].. cur 00000000000007D0 max 7FFFFFFFFFFFFFFF
rlimit_flag[NOFILE]... cur SML max INF
The rlimit_flag for NOFILE is set to SML, so the value is a 32-bit integer, and is stored in the rlimit.cur variable.
0x7d0 = 2000 decimal, so the limit for that user, picked up by the process when it started, is 2000.
Source : IBM Technote
Aucun trackbacks pour l'instant