aboutsummaryrefslogtreecommitdiff
path: root/sys/sys
diff options
context:
space:
mode:
authorMateusz Guzik <mjg@FreeBSD.org>2015-06-10 10:48:12 +0000
committerMateusz Guzik <mjg@FreeBSD.org>2015-06-10 10:48:12 +0000
commitf6f6d24062224a443ecd5e3945cf25127ee819fe (patch)
treedbbb077ee034cbfe839c1ba19dbe5ce374a5c6a3 /sys/sys
parent4ea6a9a28fd7ae3cc6e8697bc93f9ce5ea6b6262 (diff)
downloadsrc-f6f6d24062224a443ecd5e3945cf25127ee819fe.tar.gz
src-f6f6d24062224a443ecd5e3945cf25127ee819fe.zip
Implement lockless resource limits.
Use the same scheme implemented to manage credentials. Code needing to look at process's credentials (as opposed to thred's) is provided with *_proc variants of relevant functions. Places which possibly had to take the proc lock anyway still use the proc pointer to access limits.
Notes
Notes: svn path=/head/; revision=284215
Diffstat (limited to 'sys/sys')
-rw-r--r--sys/sys/proc.h3
-rw-r--r--sys/sys/resourcevar.h11
-rw-r--r--sys/sys/vnode.h2
3 files changed, 11 insertions, 5 deletions
diff --git a/sys/sys/proc.h b/sys/sys/proc.h
index 3e694e122cfd..e6c83b43940b 100644
--- a/sys/sys/proc.h
+++ b/sys/sys/proc.h
@@ -246,6 +246,7 @@ struct thread {
int td_intr_nesting_level; /* (k) Interrupt recursion. */
int td_pinned; /* (k) Temporary cpu pin count. */
struct ucred *td_ucred; /* (k) Reference to credentials. */
+ struct plimit *td_limit; /* (k) Resource limits. */
u_int td_estcpu; /* (t) estimated cpu utilization */
int td_slptick; /* (t) Time at sleep. */
int td_blktick; /* (t) Time spent blocked. */
@@ -499,7 +500,7 @@ struct proc {
struct filedesc *p_fd; /* (b) Open files. */
struct filedesc_to_leader *p_fdtol; /* (b) Tracking node */
struct pstats *p_stats; /* (b) Accounting/statistics (CPU). */
- struct plimit *p_limit; /* (c) Process limits. */
+ struct plimit *p_limit; /* (c) Resource limits. */
struct callout p_limco; /* (c) Limit callout handle */
struct sigacts *p_sigacts; /* (x) Signal actions, state (CPU). */
diff --git a/sys/sys/resourcevar.h b/sys/sys/resourcevar.h
index a07fdf8d2427..b4c707d5e130 100644
--- a/sys/sys/resourcevar.h
+++ b/sys/sys/resourcevar.h
@@ -130,13 +130,16 @@ int kern_proc_setrlimit(struct thread *td, struct proc *p, u_int which,
struct plimit
*lim_alloc(void);
void lim_copy(struct plimit *dst, struct plimit *src);
-rlim_t lim_cur(struct proc *p, int which);
+rlim_t lim_cur(struct thread *td, int which);
+rlim_t lim_cur_proc(struct proc *p, int which);
void lim_fork(struct proc *p1, struct proc *p2);
void lim_free(struct plimit *limp);
struct plimit
*lim_hold(struct plimit *limp);
-rlim_t lim_max(struct proc *p, int which);
-void lim_rlimit(struct proc *p, int which, struct rlimit *rlp);
+rlim_t lim_max(struct thread *td, int which);
+rlim_t lim_max_proc(struct proc *p, int which);
+void lim_rlimit(struct thread *td, int which, struct rlimit *rlp);
+void lim_rlimit_proc(struct proc *p, int which, struct rlimit *rlp);
void ruadd(struct rusage *ru, struct rusage_ext *rux, struct rusage *ru2,
struct rusage_ext *rux2);
void rucollect(struct rusage *ru, struct rusage *ru2);
@@ -156,5 +159,7 @@ void ui_racct_foreach(void (*callback)(struct racct *racct,
void *arg2, void *arg3), void *arg2, void *arg3);
#endif
+void lim_update_thread(struct thread *td);
+
#endif /* _KERNEL */
#endif /* !_SYS_RESOURCEVAR_H_ */
diff --git a/sys/sys/vnode.h b/sys/sys/vnode.h
index a30130fe4b79..36ef8af08e89 100644
--- a/sys/sys/vnode.h
+++ b/sys/sys/vnode.h
@@ -692,7 +692,7 @@ int vn_rdwr_inchunks(enum uio_rw rw, struct vnode *vp, void *base,
struct ucred *active_cred, struct ucred *file_cred, size_t *aresid,
struct thread *td);
int vn_rlimit_fsize(const struct vnode *vn, const struct uio *uio,
- const struct thread *td);
+ struct thread *td);
int vn_stat(struct vnode *vp, struct stat *sb, struct ucred *active_cred,
struct ucred *file_cred, struct thread *td);
int vn_start_write(struct vnode *vp, struct mount **mpp, int flags);