Skip to content

Commit

Permalink
Added get_regvals() function that uses the new API for retrieving
Browse files Browse the repository at this point in the history
register values from processes belonging to the same user. Root
can retrieve register values from any running process.
Bumped version to 1.2.2, this is the VEOS version which introduced
the ve_get_regvals() function.
Changed setup.py to install only the veosinfo.so file into the
Python site_packages directory, not an entire package (directory).
  • Loading branch information
efocht committed Sep 4, 2018
1 parent 5f8f357 commit e774b7f
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 20 deletions.
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,8 @@ test:
clean:
rm -f *.so veosinfo.c

.PHONY: test clean
install:
CFLAGS="-I/opt/nec/ve/veos/include" LDFLAGS="-L/opt/nec/ve/veos/lib64" python setup.py install

.PHONY: test clean install

39 changes: 22 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,39 +5,41 @@ Python bindings to libveosinfo provided functionality as delivered to Aurora wit

## Functions

acct(int nodeid, char *filename):
`acct(int nodeid, char *filename)`:

arch_info(int nodeid):
`arch_info(int nodeid)`:

check_pid(int nodeid, int pid):
`check_pid(int nodeid, int pid)`:

core_info(int nodeid):
`core_info(int nodeid)`:

cpu_info(int nodeid):
`cpu_info(int nodeid)`:

cpufreq_info(int nodeid):
`cpufreq_info(int nodeid)`:

create_process(int nodeid, int pid, int flag):
`create_process(int nodeid, int pid, int flag)`:

loadavg_info(int nodeid):
`get_regvals(int nodeid, pid_t pid, list regid)`:

mem_info(int nodeid):
`loadavg_info(int nodeid)`:

node_info():
`mem_info(int nodeid)`:

pidstat_info(int nodeid, pid_t pid):
`node_info()`:

read_fan(int nodeid):
`pidstat_info(int nodeid, pid_t pid)`:

read_temp(int nodeid):
`read_fan(int nodeid)`:

read_voltage(int nodeid):
`read_temp(int nodeid)`:

stat_info(int nodeid):
`read_voltage(int nodeid)`:

uptime_info(int nodeid):
`stat_info(int nodeid)`:

vmstat_info(int nodeid):
`uptime_info(int nodeid)`:

`vmstat_info(int nodeid)`:



Expand All @@ -60,6 +62,9 @@ vmstat_info(int nodeid):
>>> cpufreq_info(0)
1400L

>>> get_regvals(0, 246283, [USRCC, PMC00, PMC01])
[37939912918L, 38751941050L, 15117305941L]

>>> loadavg_info(0)
{'av_5': 0.0, 'av_15': 0.0, 'total_proc': 0, 'av_1': 0.0, 'runnable': 0}

Expand Down
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@

setup(
name = "pyVeosInfo",
version = "1.0",
version = "1.2.2",
ext_modules = cythonize(ext_modules),
packages = ["veosinfo"],
author = "Erich Focht",
author_email = "efocht@gmail.com",
license = "GPLv2",
Expand Down
35 changes: 35 additions & 0 deletions veosinfo.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

from posix.time cimport timeval
from posix.resource cimport rlimit
from libc.stdint cimport *

ctypedef int pid_t

Expand All @@ -50,6 +51,7 @@ cdef extern from "<veosinfo/veosinfo.h>":
enum: VMFLAGS_LENGTH
enum: VE_MAX_CACHE
enum: VE_DATA_LEN
enum: VE_MAX_REGVALS
enum: MAX_DEVICE_LEN
enum: MAX_POWER_DEV
enum: VE_PAGE_SIZE
Expand Down Expand Up @@ -284,6 +286,7 @@ cdef extern from "<veosinfo/veosinfo.h>":
int ve_stat_info(int, ve_statinfo *)
int ve_uptime_info(int, double *)
int ve_vmstat_info(int, ve_vmstat *)
int ve_get_regvals(int, pid_t, int, int *, uint64_t *)

# functions below have no python equivalent, yet
int ve_get_rusage(int, pid_t, ve_get_rusage_info *)
Expand Down Expand Up @@ -412,3 +415,35 @@ def vmstat_info(int nodeid):
raise RuntimeError("ve_vmstat_info failed")
return s

#
# VE register IDs usable to retrieve registers with ve_get_regvals()
#
cpdef enum VERegIds:
USRCC = 0,
PMC00, PMC01, PMC02, PMC03, PMC04, PMC05, PMC06,
PMC07, PMC08, PMC09, PMC10, PMC11, PMC12, PMC13,
PMC14, PMC15,
PSW, EXS, IC, ICE, VIXR, VL, SAR,
PMMR, PMCR00, PMCR01, PMCR02, PMCR03, PMCR04,
SR00, SR01, SR02, SR03, SR04, SR05, SR06, SR07,
SR08, SR09, SR10, SR11, SR12, SR13, SR14, SR15,
SR16, SR17, SR18, SR19, SR20, SR21, SR22, SR23,
SR24, SR25, SR26, SR27, SR28, SR29, SR30, SR31,
SR32, SR33, SR34, SR35, SR36, SR37, SR38, SR39,
SR40, SR41, SR42, SR43, SR44, SR45, SR46, SR47,
SR48, SR49, SR50, SR51, SR52, SR53, SR54, SR55,
SR56, SR57, SR58, SR59, SR60, SR61, SR62, SR63

def get_regvals(int nodeid, pid_t pid, list regid):
cdef uint64_t ve_regval[VE_MAX_REGVALS]
cdef int ve_regid[VE_MAX_REGVALS], i = 0
regid = regid[:VE_MAX_REGVALS]
for rid in regid:
ve_regid[i] = regid[i]
i += 1
if ve_get_regvals(nodeid, pid, len(regid), ve_regid, &ve_regval[0]):
raise RuntimeError("ve_get_regvals failed")
cdef list regval = list()
for i in xrange(len(regid)):
regval.append(ve_regval[i])
return regval

0 comments on commit e774b7f

Please sign in to comment.