add a project fraud, and assign user to this project
# projadd -U user1 user.test
change user user1 default project:
add a line to the end of /etc/user_attr
=> user1::::project=user.test
# id -p user1
uid=109(user1) gid=201(users) projid=100(user.test)
==> project.cpu-cap
==> a value of 100 means 100% of one CPU
add a project attribute:
# projmod -aK "project.cpu-cap=(priv,800,deny)" user.test => 50%
(it's a 16 cpu system)
# prctl -n project.cpu-cap -i project user.test
project: 100: user.test
NAME PRIVILEGE VALUE FLAG ACTION RECIPIENT
project.cpu-cap
privileged 800 - deny -
system 4.29G inf deny -
# prstat -J
PROJID NPROC SWAP RSS MEMORY TIME CPU PROJECT
100 18 7040K 8000K 0.0% 1:08:50 49% user.test <=== 50% CPU
3 90 6880M 6910M 21% 168:18:24 8.5% default
1 25 144M 154M 0.5% 12:31:05 0.7% user.root
0 60 197M 203M 0.6% 41:03:22 0.0% system
move a process to a project task
# newtask -v -p user.test -c [pid]
.