diff options
author | attilio <attilio@FreeBSD.org> | 2007-06-09 21:48:44 +0000 |
---|---|---|
committer | attilio <attilio@FreeBSD.org> | 2007-06-09 21:48:44 +0000 |
commit | 12d804e413f2c44d9e10f25ee1b546f2b48c598b (patch) | |
tree | 7fca182049d1ed6ecc1c3b117e1d77c681c922c3 /sys/compat | |
parent | 82a09af23776643f85a5e710a09bef3be83823d9 (diff) | |
download | FreeBSD-src-12d804e413f2c44d9e10f25ee1b546f2b48c598b.zip FreeBSD-src-12d804e413f2c44d9e10f25ee1b546f2b48c598b.tar.gz |
rufetch and calcru sometimes should be called atomically together.
This patch fixes places where they should be called atomically changing
their locking requirements (both assume per-proc spinlock held) and
introducing rufetchcalc which wrappers both calls to be performed in
atomic way.
Reviewed by: jeff
Approved by: jeff (mentor)
Diffstat (limited to 'sys/compat')
-rw-r--r-- | sys/compat/linux/linux_misc.c | 2 | ||||
-rw-r--r-- | sys/compat/svr4/svr4_misc.c | 8 |
2 files changed, 10 insertions, 0 deletions
diff --git a/sys/compat/linux/linux_misc.c b/sys/compat/linux/linux_misc.c index e09310c..926efbc 100644 --- a/sys/compat/linux/linux_misc.c +++ b/sys/compat/linux/linux_misc.c @@ -670,7 +670,9 @@ linux_times(struct thread *td, struct linux_times_args *args) if (args->buf != NULL) { p = td->td_proc; PROC_LOCK(p); + PROC_SLOCK(p); calcru(p, &utime, &stime); + PROC_SUNLOCK(p); calccru(p, &cutime, &cstime); PROC_UNLOCK(p); diff --git a/sys/compat/svr4/svr4_misc.c b/sys/compat/svr4/svr4_misc.c index 7277622..a158fd7 100644 --- a/sys/compat/svr4/svr4_misc.c +++ b/sys/compat/svr4/svr4_misc.c @@ -828,7 +828,9 @@ svr4_sys_times(td, uap) p = td->td_proc; PROC_LOCK(p); + PROC_SLOCK(p); calcru(p, &utime, &stime); + PROC_SUNLOCK(p); calccru(p, &cutime, &cstime); PROC_UNLOCK(p); @@ -1241,7 +1243,9 @@ loop: pid = p->p_pid; status = p->p_xstat; ru = p->p_ru; + PROC_SLOCK(p); calcru(p, &ru.ru_utime, &ru.ru_stime); + PROC_SUNLOCK(p); PROC_UNLOCK(p); sx_sunlock(&proctree_lock); @@ -1266,7 +1270,9 @@ loop: pid = p->p_pid; status = W_STOPCODE(p->p_xstat); ru = p->p_ru; + PROC_SLOCK(p); calcru(p, &ru.ru_utime, &ru.ru_stime); + PROC_SUNLOCK(p); PROC_UNLOCK(p); if (((uap->options & SVR4_WNOWAIT)) == 0) { @@ -1288,7 +1294,9 @@ loop: pid = p->p_pid; ru = p->p_ru; status = SIGCONT; + PROC_SLOCK(p); calcru(p, &ru.ru_utime, &ru.ru_stime); + PROC_SUNLOCK(p); PROC_UNLOCK(p); if (((uap->options & SVR4_WNOWAIT)) == 0) { |