Project

General

Profile

Bug #1996 » 0002-kernel-Replace-LW-P-HOLD-RELE-to-use-refcount-APIs.patch

y0n3t4n1, 04/25/2011 12:15 PM

View differences:

sys/kern/kern_exit.c
* Nobody actually wakes us when the lock
* count reaches zero, so just wait one tick.
*/
while (lp->lwp_lock > 0)
tsleep(lp, 0, "lwpexit", 1);
LWPLOCKWAIT(lp, "lwpexit", 1);
/* Hand down resource usage to our proc */
ruadd(&p->p_ru, &lp->lwp_ru);
......
KKASSERT(lwkt_preempted_proc() != lp);
while (lp->lwp_lock > 0)
tsleep(lp, 0, "lwpwait1", 1);
LWPLOCKWAIT(lp, "lwpwait1", 1);
lwkt_wait_free(td);
......
* put a hold on the process for short periods of
* time.
*/
while (p->p_lock)
tsleep(p, 0, "reap3", hz);
PLOCKWAIT(p, "reap3", hz);
/* Take care of our return values. */
*res = p->p_pid;
......
* inconsistent state for processes running down
* the zombie list.
*/
KKASSERT(p->p_lock == 0);
if (p->p_lock) {
kprintf("%s: pid %d is still held (%x)\n",
__func__, p->p_pid, p->p_lock);
}
proc_remove_zombie(p);
leavepgrp(p);
sys/kern/kern_proc.c
proc_move_allproc_zombie(struct proc *p)
{
lwkt_gettoken(&proc_token);
while (p->p_lock) {
tsleep(p, 0, "reap1", hz / 10);
}
PLOCKWAIT(p, "reap1", hz / 10);
LIST_REMOVE(p, p_list);
LIST_INSERT_HEAD(&zombproc, p, p_list);
LIST_REMOVE(p, p_hash);
......
proc_remove_zombie(struct proc *p)
{
lwkt_gettoken(&proc_token);
while (p->p_lock) {
tsleep(p, 0, "reap1", hz / 10);
}
PLOCKWAIT(p, "reap1", hz / 10);
LIST_REMOVE(p, p_list); /* off zombproc */
LIST_REMOVE(p, p_sibling);
lwkt_reltoken(&proc_token);
sys/platform/pc32/i386/pmap.c
void
pmap_dispose_proc(struct proc *p)
{
KASSERT(p->p_lock == 0, ("attempt to dispose referenced proc! %p", p));
KASSERT(p->p_lock == 0,
("attempt to dispose referenced or waited for proc! %p", p));
}
/***************************************************
sys/platform/pc64/x86_64/pmap.c
void
pmap_dispose_proc(struct proc *p)
{
KASSERT(p->p_lock == 0, ("attempt to dispose referenced proc! %p", p));
KASSERT(p->p_lock == 0,
("attempt to dispose referenced or waited for proc! %p", p));
}
/***************************************************
sys/platform/vkernel/platform/pmap.c
void
pmap_dispose_proc(struct proc *p)
{
KASSERT(p->p_lock == 0, ("attempt to dispose referenced proc! %p", p));
KASSERT(p->p_lock == 0,
("attempt to dispose referenced or waited for proc! %p", p));
}
/*
sys/platform/vkernel64/platform/pmap.c
void
pmap_dispose_proc(struct proc *p)
{
KASSERT(p->p_lock == 0, ("attempt to dispose referenced proc! %p", p));
KASSERT(p->p_lock == 0,
("attempt to dispose referenced or waited for proc! %p", p));
}
/***************************************************
sys/sys/proc.h
#include <sys/rtprio.h> /* For struct rtprio. */
#include <sys/signal.h>
#include <sys/lock.h>
#include <sys/refcount.h>
#ifndef _KERNEL
#include <sys/time.h> /* For structs itimerval, timeval. */
#endif
......
*
* MPSAFE
*/
#define PHOLD(p) atomic_add_int(&(p)->p_lock, 1)
#define PRELE(p) atomic_add_int(&(p)->p_lock, -1)
#define PHOLD(p) refcount_acquire(&(p)->p_lock)
#define PRELE(p) refcount_release_wakeup(&(p)->p_lock)
#define PLOCKWAIT(p, wmesg, timo) refcount_wait(&(p)->p_lock, wmesg)
/*
* Hold lwp in memory, don't destruct, normally for ptrace/procfs work
* atomic ops because they can occur from an IPI.
* MPSAFE
*/
#define LWPHOLD(lp) atomic_add_int(&(lp)->lwp_lock, 1)
#define LWPRELE(lp) atomic_add_int(&(lp)->lwp_lock, -1)
#define LWPHOLD(lp) refcount_acquire(&(lp)->lwp_lock)
#define LWPRELE(lp) refcount_release_wakeup(&(lp)->lwp_lock)
#define LWPLOCKWAIT(lp, wmesg, timo) refcount_wait(&(lp)->lwp_lock, wmesg)
#define PIDHASH(pid) (&pidhashtbl[(pid) & pidhash])
extern LIST_HEAD(pidhashhead, proc) *pidhashtbl;
(2-2/2)