Rename resource names to match these in login.conf.

This commit is contained in:
Edward Tomasz Napierala 2011-07-14 19:18:17 +00:00
parent 0a7d45d349
commit 85a2f1b4f2
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=224036
4 changed files with 44 additions and 45 deletions

View File

@ -103,7 +103,7 @@ SDT_PROBE_DEFINE2(racct, kernel, racct, leave, leave, "struct racct *",
int racct_types[] = { int racct_types[] = {
[RACCT_CPU] = [RACCT_CPU] =
RACCT_IN_THOUSANDS, RACCT_IN_MILLIONS,
[RACCT_DATA] = [RACCT_DATA] =
RACCT_RECLAIMABLE | RACCT_INHERITABLE | RACCT_DENIABLE, RACCT_RECLAIMABLE | RACCT_INHERITABLE | RACCT_DENIABLE,
[RACCT_STACK] = [RACCT_STACK] =
@ -141,7 +141,7 @@ int racct_types[] = {
[RACCT_SHMSIZE] = [RACCT_SHMSIZE] =
RACCT_RECLAIMABLE | RACCT_DENIABLE | RACCT_SLOPPY, RACCT_RECLAIMABLE | RACCT_DENIABLE | RACCT_SLOPPY,
[RACCT_WALLCLOCK] = [RACCT_WALLCLOCK] =
RACCT_IN_THOUSANDS }; RACCT_IN_MILLIONS };
static void static void
racct_add_racct(struct racct *dest, const struct racct *src) racct_add_racct(struct racct *dest, const struct racct *src)

View File

@ -99,17 +99,17 @@ static struct dict subjectnames[] = {
{ NULL, -1 }}; { NULL, -1 }};
static struct dict resourcenames[] = { static struct dict resourcenames[] = {
{ "cpu", RACCT_CPU }, { "cputime", RACCT_CPU },
{ "data", RACCT_DATA }, { "datasize", RACCT_DATA },
{ "stack", RACCT_STACK }, { "stacksize", RACCT_STACK },
{ "core", RACCT_CORE }, { "coredumpsize", RACCT_CORE },
{ "rss", RACCT_RSS }, { "memoryuse", RACCT_RSS },
{ "memlock", RACCT_MEMLOCK }, { "memorylocked", RACCT_MEMLOCK },
{ "nproc", RACCT_NPROC }, { "maxproc", RACCT_NPROC },
{ "nofile", RACCT_NOFILE }, { "openfiles", RACCT_NOFILE },
{ "vmem", RACCT_VMEM }, { "vmemoryuse", RACCT_VMEM },
{ "npts", RACCT_NPTS }, { "pseudoterminals", RACCT_NPTS },
{ "swap", RACCT_SWAP }, { "swapuse", RACCT_SWAP },
{ "nthr", RACCT_NTHR }, { "nthr", RACCT_NTHR },
{ "msgqqueued", RACCT_MSGQQUEUED }, { "msgqqueued", RACCT_MSGQQUEUED },
{ "msgqsize", RACCT_MSGQSIZE }, { "msgqsize", RACCT_MSGQSIZE },
@ -907,7 +907,7 @@ rctl_string_to_rule(char *rulestr, struct rctl_rule **rulep)
error = str2int64(amountstr, &rule->rr_amount); error = str2int64(amountstr, &rule->rr_amount);
if (error != 0) if (error != 0)
goto out; goto out;
if (RACCT_IS_IN_THOUSANDS(rule->rr_resource)) if (RACCT_IS_IN_MILLIONS(rule->rr_resource))
rule->rr_amount *= 1000; rule->rr_amount *= 1000;
} }
@ -1152,8 +1152,8 @@ rctl_rule_to_sbuf(struct sbuf *sb, const struct rctl_rule *rule)
amount = rule->rr_amount; amount = rule->rr_amount;
if (amount != RCTL_AMOUNT_UNDEFINED && if (amount != RCTL_AMOUNT_UNDEFINED &&
RACCT_IS_IN_THOUSANDS(rule->rr_resource)) RACCT_IS_IN_MILLIONS(rule->rr_resource))
amount /= 1000; amount /= 1000000;
sbuf_printf(sb, "%s:%s=%jd", sbuf_printf(sb, "%s:%s=%jd",
rctl_resource_name(rule->rr_resource), rctl_resource_name(rule->rr_resource),
@ -1222,7 +1222,7 @@ rctl_racct_to_sbuf(struct racct *racct, int sloppy)
if (sloppy == 0 && RACCT_IS_SLOPPY(i)) if (sloppy == 0 && RACCT_IS_SLOPPY(i))
continue; continue;
amount = racct->r_resources[i]; amount = racct->r_resources[i];
if (RACCT_IS_IN_THOUSANDS(i)) if (RACCT_IS_IN_MILLIONS(i))
amount /= 1000; amount /= 1000;
sbuf_printf(sb, "%s=%jd,", rctl_resource_name(i), amount); sbuf_printf(sb, "%s=%jd,", rctl_resource_name(i), amount);
} }

View File

@ -73,7 +73,7 @@ struct ucred;
/* /*
* Resource properties. * Resource properties.
*/ */
#define RACCT_IN_THOUSANDS 0x01 #define RACCT_IN_MILLIONS 0x01
#define RACCT_RECLAIMABLE 0x02 #define RACCT_RECLAIMABLE 0x02
#define RACCT_INHERITABLE 0x04 #define RACCT_INHERITABLE 0x04
#define RACCT_DENIABLE 0x08 #define RACCT_DENIABLE 0x08
@ -82,11 +82,11 @@ struct ucred;
extern int racct_types[]; extern int racct_types[];
/* /*
* Amount stored in c_resources[] is thousand times bigger than what's * Amount stored in c_resources[] is 10**6 times bigger than what's
* visible to the userland. It gets fixed up when retrieving resource * visible to the userland. It gets fixed up when retrieving resource
* usage or adding rules. * usage or adding rules.
*/ */
#define RACCT_IS_IN_THOUSANDS(X) (racct_types[X] & RACCT_IN_THOUSANDS) #define RACCT_IS_IN_MILLIONS(X) (racct_types[X] & RACCT_IN_MILLIONS)
/* /*
* Resource usage can drop, as opposed to only grow. * Resource usage can drop, as opposed to only grow.

View File

@ -25,7 +25,7 @@
.\" .\"
.\" $FreeBSD$ .\" $FreeBSD$
.\" .\"
.Dd May 26, 2011 .Dd July 14, 2011
.Dt RCTL 8 .Dt RCTL 8
.Os .Os
.Sh NAME .Sh NAME
@ -121,32 +121,31 @@ A filter that matches all defined rules for nproc resource would be
"::nproc". "::nproc".
.Pp .Pp
.Sh RESOURCES .Sh RESOURCES
.Bl -column -offset 3n "msgqqueued" .Bl -column -offset 3n "pseudoterminals"
.It cpu CPU time, in milliseconds .It cputime CPU time, in seconds
.It data data size, in bytes .It datasize data size, in bytes
.It stack stack size, in bytes .It stacksize stack size, in bytes
.It core core dump size, in bytes .It coredumpsize core dump size, in bytes
.It rss resident set size, in bytes .It memoryuse resident set size, in bytes
.It memlock locked memory, in bytes .It memorylocked locked memory, in bytes
.It nproc number of processes .It maxproc number of processes
.It nofile file descriptor table size .It openfiles file descriptor table size
.It vmem address space limit, in bytes .It vmemoryuse address space limit, in bytes
.It npts number of PTYs .It pseudoterminals number of PTYs
.It swap swap usage, in bytes .It swapuse swap usage, in bytes
.It nthr number of threads .It nthr number of threads
.It msgqqueued number of queued SysV messages .It msgqqueued number of queued SysV messages
.It msgqsize SysV message queue size, in bytes .It msgqsize SysV message queue size, in bytes
.It nmsgq number of SysV message queues .It nmsgq number of SysV message queues
.It nsem number of SysV semaphores .It nsem number of SysV semaphores
.It nsemop number of SysV semaphores modified in a single semop(2) call .It nsemop number of SysV semaphores modified in a single semop(2) call
.It nshm number of SysV shared memory segments .It nshm number of SysV shared memory segments
.It shmsize SysV shared memory size, in bytes .It shmsize SysV shared memory size, in bytes
.It wallclock wallclock time, in milliseconds .It wallclock wallclock time, in seconds
.It pctcpu %cpu time
.El .El
.Pp .Pp
.Sh ACTIONS .Sh ACTIONS
.Bl -column -offset 3n "msgqqueued" .Bl -column -offset 3n "pseudoterminals"
.It deny deny the allocation; not supported for cpu and wallclock .It deny deny the allocation; not supported for cpu and wallclock
.It log log a warning to the console .It log log a warning to the console
.It devctl send notification to .It devctl send notification to
@ -167,7 +166,7 @@ Note that limiting RSS may kill the machine due to thrashing.
.Sh EXIT STATUS .Sh EXIT STATUS
.Ex -std .Ex -std
.Sh EXAMPLES .Sh EXAMPLES
.Dl rctl -a user:joe:vmem:deny=1g .Dl rctl -a user:joe:vmemoryuse:deny=1g
.Pp .Pp
Prevent user "joe" from allocating more than 1GB of virtual memory. Prevent user "joe" from allocating more than 1GB of virtual memory.
.Pp .Pp