aboutsummaryrefslogtreecommitdiff
path: root/sys/sys
diff options
context:
space:
mode:
Diffstat (limited to 'sys/sys')
-rw-r--r--sys/sys/proc.h1
-rw-r--r--sys/sys/racct.h22
-rw-r--r--sys/sys/rctl.h1
-rw-r--r--sys/sys/sched.h5
4 files changed, 27 insertions, 2 deletions
diff --git a/sys/sys/proc.h b/sys/sys/proc.h
index 0aae0cefefb3..567cb63bf410 100644
--- a/sys/sys/proc.h
+++ b/sys/sys/proc.h
@@ -584,6 +584,7 @@ struct proc {
after fork. */
uint64_t p_prev_runtime; /* (c) Resource usage accounting. */
struct racct *p_racct; /* (b) Resource accounting. */
+ u_char p_throttled; /* (c) Flag for racct pcpu throttling */
/*
* An orphan is the child that has beed re-parented to the
* debugger as a result of attaching to it. Need to keep
diff --git a/sys/sys/racct.h b/sys/sys/racct.h
index b4aeee8d21f8..3b34891af14c 100644
--- a/sys/sys/racct.h
+++ b/sys/sys/racct.h
@@ -68,7 +68,8 @@ struct ucred;
#define RACCT_NSHM 17
#define RACCT_SHMSIZE 18
#define RACCT_WALLCLOCK 19
-#define RACCT_MAX RACCT_WALLCLOCK
+#define RACCT_PCTCPU 20
+#define RACCT_MAX RACCT_PCTCPU
/*
* Resource properties.
@@ -78,6 +79,7 @@ struct ucred;
#define RACCT_INHERITABLE 0x04
#define RACCT_DENIABLE 0x08
#define RACCT_SLOPPY 0x10
+#define RACCT_DECAYING 0x20
extern int racct_types[];
@@ -89,7 +91,9 @@ extern int racct_types[];
#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. When the process
+ * terminates, its resource usage is freed from the respective
+ * per-credential racct containers.
*/
#define RACCT_IS_RECLAIMABLE(X) (racct_types[X] & RACCT_RECLAIMABLE)
@@ -113,6 +117,20 @@ extern int racct_types[];
#define RACCT_IS_SLOPPY(X) (racct_types[X] & RACCT_SLOPPY)
/*
+ * When a process terminates, its resource usage is not automatically
+ * subtracted from per-credential racct containers. Instead, the resource
+ * usage of per-credential racct containers decays in time.
+ * Resource usage can olso drop for such resource.
+ * So far, the only such resource is RACCT_PCTCPU.
+ */
+#define RACCT_IS_DECAYING(X) (racct_types[X] & RACCT_DECAYING)
+
+/*
+ * Resource usage can drop, as opposed to only grow.
+ */
+#define RACCT_CAN_DROP(X) (RACCT_IS_RECLAIMABLE(X) | RACCT_IS_DECAYING(X))
+
+/*
* The 'racct' structure defines resource consumption for a particular
* subject, such as process or jail.
*
diff --git a/sys/sys/rctl.h b/sys/sys/rctl.h
index 1e0342732b80..e1a45a4949fa 100644
--- a/sys/sys/rctl.h
+++ b/sys/sys/rctl.h
@@ -140,6 +140,7 @@ void rctl_rule_release(struct rctl_rule *rule);
int rctl_rule_add(struct rctl_rule *rule);
int rctl_rule_remove(struct rctl_rule *filter);
int rctl_enforce(struct proc *p, int resource, uint64_t amount);
+int64_t rctl_pcpu_available(const struct proc *p);
uint64_t rctl_get_limit(struct proc *p, int resource);
uint64_t rctl_get_available(struct proc *p, int resource);
const char *rctl_resource_name(int resource);
diff --git a/sys/sys/sched.h b/sys/sys/sched.h
index 4b8387c1d26c..b15104eae032 100644
--- a/sys/sys/sched.h
+++ b/sys/sys/sched.h
@@ -103,6 +103,11 @@ void sched_user_prio(struct thread *td, u_char prio);
void sched_userret(struct thread *td);
void sched_wakeup(struct thread *td);
void sched_preempt(struct thread *td);
+#ifdef RACCT
+#ifdef SCHED_4BSD
+fixpt_t sched_pctcpu_delta(struct thread *td);
+#endif
+#endif
/*
* Threads are moved on and off of run queues