PERFORCE change 101289 for review
John Baldwin
jhb at FreeBSD.org
Tue Jul 11 20:24:27 UTC 2006
http://perforce.freebsd.org/chv.cgi?CH=101289
Change 101289 by jhb at jhb_mutex on 2006/07/11 20:24:20
IFC @101287.
Affected files ...
.. //depot/projects/smpng/sys/arm/arm/pmap.c#30 integrate
.. //depot/projects/smpng/sys/compat/freebsd32/freebsd32_misc.c#42 integrate
.. //depot/projects/smpng/sys/compat/svr4/svr4_stream.c#35 integrate
.. //depot/projects/smpng/sys/compat/svr4/svr4_util.h#10 integrate
.. //depot/projects/smpng/sys/dev/isp/isp_freebsd.c#42 integrate
.. //depot/projects/smpng/sys/dev/isp/isp_target.c#18 integrate
.. //depot/projects/smpng/sys/geom/mirror/g_mirror.c#31 integrate
.. //depot/projects/smpng/sys/geom/raid3/g_raid3.c#32 integrate
.. //depot/projects/smpng/sys/kern/kern_thr.c#34 integrate
.. //depot/projects/smpng/sys/kern/uipc_syscalls.c#87 integrate
.. //depot/projects/smpng/sys/posix4/ksched.c#18 integrate
.. //depot/projects/smpng/sys/posix4/p1003_1b.c#13 integrate
.. //depot/projects/smpng/sys/posix4/posix4.h#7 integrate
.. //depot/projects/smpng/sys/sys/syscallsubr.h#47 integrate
.. //depot/projects/smpng/sys/sys/thr.h#8 integrate
.. //depot/projects/smpng/sys/ufs/ufs/ufs_lookup.c#25 integrate
Differences ...
==== //depot/projects/smpng/sys/arm/arm/pmap.c#30 (text+ko) ====
@@ -147,7 +147,7 @@
#include "opt_vm.h"
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/arm/arm/pmap.c,v 1.64 2006/06/15 01:01:05 ups Exp $");
+__FBSDID("$FreeBSD: src/sys/arm/arm/pmap.c,v 1.65 2006/07/11 11:22:06 cognet Exp $");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
@@ -199,7 +199,7 @@
static pv_entry_t pmap_get_pv_entry(void);
static void pmap_enter_locked(pmap_t, vm_offset_t, vm_page_t,
- vm_prot_t, boolean_t);
+ vm_prot_t, boolean_t, int);
static void pmap_vac_me_harder(struct vm_page *, pmap_t,
vm_offset_t);
static void pmap_vac_me_kpmap(struct vm_page *, pmap_t,
@@ -373,7 +373,7 @@
* L2 allocation.
*/
#define pmap_alloc_l2_dtable() \
- (void*)uma_zalloc(l2table_zone, M_NOWAIT)
+ (void*)uma_zalloc(l2table_zone, M_NOWAIT|M_USE_RESERVE)
#define pmap_free_l2_dtable(l2) \
uma_zfree(l2table_zone, l2)
@@ -952,7 +952,7 @@
again_ptep:
PMAP_UNLOCK(pm);
vm_page_unlock_queues();
- ptep = (void*)uma_zalloc(l2zone, M_NOWAIT);
+ ptep = (void*)uma_zalloc(l2zone, M_NOWAIT|M_USE_RESERVE);
vm_page_lock_queues();
PMAP_LOCK(pm);
if (l2b->l2b_kva != 0) {
@@ -3306,7 +3306,7 @@
vm_page_lock_queues();
PMAP_LOCK(pmap);
- pmap_enter_locked(pmap, va, m, prot, wired);
+ pmap_enter_locked(pmap, va, m, prot, wired, M_WAITOK);
vm_page_unlock_queues();
PMAP_UNLOCK(pmap);
}
@@ -3316,7 +3316,7 @@
*/
static void
pmap_enter_locked(pmap_t pmap, vm_offset_t va, vm_page_t m, vm_prot_t prot,
- boolean_t wired)
+ boolean_t wired, int flags)
{
struct l2_bucket *l2b = NULL;
struct vm_page *opg;
@@ -3347,10 +3347,22 @@
l2b = pmap_get_l2_bucket(pmap, va);
if (l2b == NULL)
l2b = pmap_grow_l2_bucket(pmap, va);
- } else
+ } else {
+do_l2b_alloc:
l2b = pmap_alloc_l2_bucket(pmap, va);
- KASSERT(l2b != NULL,
- ("pmap_enter: failed to allocate l2 bucket"));
+ if (l2b == NULL) {
+ if (flags & M_WAITOK) {
+ PMAP_UNLOCK(pmap);
+ vm_page_unlock_queues();
+ VM_WAIT;
+ vm_page_lock_queues();
+ PMAP_LOCK(pmap);
+ goto do_l2b_alloc;
+ }
+ return;
+ }
+ }
+
ptep = &l2b->l2b_kva[l2pte_index(va)];
opte = *ptep;
@@ -3557,7 +3569,7 @@
PMAP_LOCK(pmap);
while (m != NULL && (diff = m->pindex - m_start->pindex) < psize) {
pmap_enter_locked(pmap, start + ptoa(diff), m, prot &
- (VM_PROT_READ | VM_PROT_EXECUTE), FALSE);
+ (VM_PROT_READ | VM_PROT_EXECUTE), FALSE, M_NOWAIT);
m = TAILQ_NEXT(m, listq);
}
PMAP_UNLOCK(pmap);
@@ -3578,7 +3590,7 @@
PMAP_LOCK(pmap);
pmap_enter_locked(pmap, va, m, prot & (VM_PROT_READ | VM_PROT_EXECUTE),
- FALSE);
+ FALSE, M_NOWAIT);
PMAP_UNLOCK(pmap);
}
==== //depot/projects/smpng/sys/compat/freebsd32/freebsd32_misc.c#42 (text+ko) ====
@@ -25,7 +25,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/compat/freebsd32/freebsd32_misc.c,v 1.56 2006/07/10 19:37:43 jhb Exp $");
+__FBSDID("$FreeBSD: src/sys/compat/freebsd32/freebsd32_misc.c,v 1.57 2006/07/10 21:38:16 jhb Exp $");
#include "opt_compat.h"
==== //depot/projects/smpng/sys/compat/svr4/svr4_stream.c#35 (text+ko) ====
@@ -36,7 +36,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/compat/svr4/svr4_stream.c,v 1.57 2006/04/01 15:25:01 rwatson Exp $");
+__FBSDID("$FreeBSD: src/sys/compat/svr4/svr4_stream.c,v 1.58 2006/07/10 21:38:17 jhb Exp $");
#include "opt_compat.h"
#include "opt_ktrace.h"
==== //depot/projects/smpng/sys/compat/svr4/svr4_util.h#10 (text+ko) ====
@@ -25,7 +25,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $FreeBSD: src/sys/compat/svr4/svr4_util.h,v 1.11 2005/09/28 07:03:02 rwatson Exp $
+ * $FreeBSD: src/sys/compat/svr4/svr4_util.h,v 1.12 2006/07/10 21:38:17 jhb Exp $
*/
#ifndef _SVR4_UTIL_H_
==== //depot/projects/smpng/sys/dev/isp/isp_freebsd.c#42 (text+ko) ====
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/isp/isp_freebsd.c,v 1.118 2006/07/09 17:50:17 mjacob Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/isp/isp_freebsd.c,v 1.119 2006/07/10 22:39:32 mjacob Exp $");
#include <dev/isp/isp_freebsd.h>
#include <sys/unistd.h>
@@ -290,37 +290,40 @@
switch (c) {
#ifdef ISP_FW_CRASH_DUMP
case ISP_GET_FW_CRASH_DUMP:
- {
- uint16_t *ptr = FCPARAM(isp)->isp_dump_data;
- size_t sz;
+ if (IS_FC(isp)) {
+ uint16_t *ptr = FCPARAM(isp)->isp_dump_data;
+ size_t sz;
- retval = 0;
- if (IS_2200(isp))
- sz = QLA2200_RISC_IMAGE_DUMP_SIZE;
- else
- sz = QLA2300_RISC_IMAGE_DUMP_SIZE;
- ISP_LOCK(isp);
- if (ptr && *ptr) {
- void *uaddr = *((void **) addr);
- if (copyout(ptr, uaddr, sz)) {
- retval = EFAULT;
+ retval = 0;
+ if (IS_2200(isp)) {
+ sz = QLA2200_RISC_IMAGE_DUMP_SIZE;
+ } else {
+ sz = QLA2300_RISC_IMAGE_DUMP_SIZE;
+ }
+ ISP_LOCK(isp);
+ if (ptr && *ptr) {
+ void *uaddr = *((void **) addr);
+ if (copyout(ptr, uaddr, sz)) {
+ retval = EFAULT;
+ } else {
+ *ptr = 0;
+ }
} else {
- *ptr = 0;
+ retval = ENXIO;
}
- } else {
- retval = ENXIO;
+ ISP_UNLOCK(isp);
}
- ISP_UNLOCK(isp);
break;
- }
-
case ISP_FORCE_CRASH_DUMP:
- ISP_LOCK(isp);
- isp_freeze_loopdown(isp, "ispioctl(ISP_FORCE_CRASH_DUMP)");
- isp_fw_dump(isp);
- isp_reinit(isp);
- ISP_UNLOCK(isp);
- retval = 0;
+ if (IS_FC(isp)) {
+ ISP_LOCK(isp);
+ isp_freeze_loopdown(isp,
+ "ispioctl(ISP_FORCE_CRASH_DUMP)");
+ isp_fw_dump(isp);
+ isp_reinit(isp);
+ ISP_UNLOCK(isp);
+ retval = 0;
+ }
break;
#endif
case ISP_SDBLEV:
@@ -377,6 +380,9 @@
struct isp_fc_device *ifc = (struct isp_fc_device *) addr;
struct lportdb *lp;
+ if (IS_SCSI(isp)) {
+ break;
+ }
if (ifc->loopid < 0 || ifc->loopid >= MAX_FC_TARG) {
retval = EINVAL;
break;
@@ -434,19 +440,20 @@
{
struct isp_hba_device *hba = (struct isp_hba_device *) addr;
MEMZERO(hba, sizeof (*hba));
- ISP_LOCK(isp);
+
hba->fc_fw_major = ISP_FW_MAJORX(isp->isp_fwrev);
hba->fc_fw_minor = ISP_FW_MINORX(isp->isp_fwrev);
hba->fc_fw_micro = ISP_FW_MICROX(isp->isp_fwrev);
- hba->fc_speed = FCPARAM(isp)->isp_gbspeed;
- hba->fc_scsi_supported = 1;
- hba->fc_topology = FCPARAM(isp)->isp_topo + 1;
- hba->fc_loopid = FCPARAM(isp)->isp_loopid;
- hba->nvram_node_wwn = FCPARAM(isp)->isp_nodewwn;
- hba->nvram_port_wwn = FCPARAM(isp)->isp_portwwn;
- hba->active_node_wwn = ISP_NODEWWN(isp);
- hba->active_port_wwn = ISP_PORTWWN(isp);
- ISP_UNLOCK(isp);
+ if (IS_FC(isp)) {
+ hba->fc_speed = FCPARAM(isp)->isp_gbspeed;
+ hba->fc_scsi_supported = 1;
+ hba->fc_topology = FCPARAM(isp)->isp_topo + 1;
+ hba->fc_loopid = FCPARAM(isp)->isp_loopid;
+ hba->nvram_node_wwn = FCPARAM(isp)->isp_nodewwn;
+ hba->nvram_port_wwn = FCPARAM(isp)->isp_portwwn;
+ hba->active_node_wwn = ISP_NODEWWN(isp);
+ hba->active_port_wwn = ISP_PORTWWN(isp);
+ }
retval = 0;
break;
}
@@ -454,8 +461,7 @@
{
struct isp_fc_param *f = (struct isp_fc_param *) addr;
- if (!IS_FC(isp)) {
- retval = EINVAL;
+ if (IS_SCSI(isp)) {
break;
}
f->parameter = 0;
@@ -488,8 +494,7 @@
struct isp_fc_param *f = (struct isp_fc_param *) addr;
uint32_t param = f->parameter;
- if (!IS_FC(isp)) {
- retval = EINVAL;
+ if (IS_SCSI(isp)) {
break;
}
f->parameter = 0;
@@ -546,7 +551,6 @@
mbreg_t mbs;
if (IS_SCSI(isp)) {
- retval = EINVAL;
break;
}
==== //depot/projects/smpng/sys/dev/isp/isp_target.c#18 (text+ko) ====
@@ -27,7 +27,7 @@
*/
#ifdef __FreeBSD__
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/isp/isp_target.c,v 1.36 2006/04/21 18:46:35 mjacob Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/isp/isp_target.c,v 1.37 2006/07/10 22:40:21 mjacob Exp $");
#endif
/*
@@ -165,18 +165,20 @@
isp_handle_ctio(isp, (ct_entry_t *) local);
break;
case RQSTYPE_ATIO2:
- if (IS_2KLOGIN(isp))
+ if (IS_2KLOGIN(isp)) {
isp_get_atio2e(isp, at2eiop, (at2e_entry_t *) local);
- else
+ } else {
isp_get_atio2(isp, at2iop, (at2_entry_t *) local);
+ }
isp_handle_atio2(isp, (at2_entry_t *) local);
break;
case RQSTYPE_CTIO3:
case RQSTYPE_CTIO2:
- if (IS_2KLOGIN(isp))
+ if (IS_2KLOGIN(isp)) {
isp_get_ctio2e(isp, ct2eiop, (ct2e_entry_t *) local);
- else
+ } else {
isp_get_ctio2(isp, ct2iop, (ct2_entry_t *) local);
+ }
isp_handle_ctio2(isp, (ct2_entry_t *) local);
break;
case RQSTYPE_ENABLE_LUN:
@@ -195,9 +197,11 @@
*/
bus = 0;
if (IS_FC(isp)) {
- if (IS_2KLOGIN(isp))
+ if (IS_2KLOGIN(isp)) {
isp_get_notify_fc_e(isp, inote_fcp, (in_fcentry_e_t *)local);
- isp_get_notify_fc(isp, inot_fcp, (in_fcentry_t *)local);
+ } else {
+ isp_get_notify_fc(isp, inot_fcp, (in_fcentry_t *)local);
+ }
inot_fcp = (in_fcentry_t *) local;
status = inot_fcp->in_status;
seqid = inot_fcp->in_seqid;
@@ -251,12 +255,13 @@
* Immediate Notify entry for some asynchronous event.
*/
if (IS_FC(isp)) {
- if (IS_2KLOGIN(isp))
+ if (IS_2KLOGIN(isp)) {
isp_get_notify_ack_fc_e(isp, nacke_fcp,
(na_fcentry_e_t *)local);
- else
+ } else {
isp_get_notify_ack_fc(isp, nack_fcp,
(na_fcentry_t *)local);
+ }
nack_fcp = (na_fcentry_t *)local;
isp_prt(isp, ISP_LOGTDEBUG1,
"Notify Ack status=0x%x seqid 0x%x",
@@ -372,13 +377,21 @@
isp_put_atio(isp, (at_entry_t *) ap, (at_entry_t *) outp);
break;
case RQSTYPE_ATIO2:
- isp_put_atio2(isp, (at2_entry_t *) ap, (at2_entry_t *) outp);
+ if (IS_2KLOGIN(isp)) {
+ isp_put_atio2e(isp, (at2e_entry_t *) ap, (at2e_entry_t *) outp);
+ } else {
+ isp_put_atio2(isp, (at2_entry_t *) ap, (at2_entry_t *) outp);
+ }
break;
case RQSTYPE_CTIO:
isp_put_ctio(isp, (ct_entry_t *) ap, (ct_entry_t *) outp);
break;
case RQSTYPE_CTIO2:
- isp_put_ctio2(isp, (ct2_entry_t *) ap, (ct2_entry_t *) outp);
+ if (IS_2KLOGIN(isp)) {
+ isp_put_ctio2e(isp, (ct2e_entry_t *) ap, (ct2e_entry_t *) outp);
+ } else {
+ isp_put_ctio2(isp, (ct2_entry_t *) ap, (ct2_entry_t *) outp);
+ }
break;
default:
isp_prt(isp, ISP_LOGERR,
@@ -572,6 +585,7 @@
uint8_t storage[QENTRY_LEN];
memset(storage, 0, QENTRY_LEN);
if (IS_FC(isp)) {
+ /* This should also suffice for 2K login code */
ct2_entry_t *ct = (ct2_entry_t *) storage;
ct->ct_header.rqs_entry_type = RQSTYPE_CTIO2;
ct->ct_status = CT_OK;
==== //depot/projects/smpng/sys/geom/mirror/g_mirror.c#31 (text+ko) ====
@@ -25,7 +25,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/geom/mirror/g_mirror.c,v 1.84 2006/07/03 10:32:37 pjd Exp $");
+__FBSDID("$FreeBSD: src/sys/geom/mirror/g_mirror.c,v 1.85 2006/07/10 21:18:00 pjd Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -3003,7 +3003,7 @@
pp->name, gp->name, error);
if (LIST_EMPTY(&sc->sc_disks)) {
g_cancel_event(sc);
- g_mirror_destroy(sc, 1);
+ g_mirror_destroy(sc, G_MIRROR_DESTROY_HARD);
g_topology_lock();
return (NULL);
}
@@ -3025,7 +3025,7 @@
sc = gp->softc;
sx_xlock(&sc->sc_lock);
g_cancel_event(sc);
- error = g_mirror_destroy(gp->softc, 0);
+ error = g_mirror_destroy(gp->softc, G_MIRROR_DESTROY_SOFT);
if (error != 0)
sx_xunlock(&sc->sc_lock);
g_topology_lock();
==== //depot/projects/smpng/sys/geom/raid3/g_raid3.c#32 (text+ko) ====
@@ -25,7 +25,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/geom/raid3/g_raid3.c,v 1.68 2006/07/09 12:25:56 pjd Exp $");
+__FBSDID("$FreeBSD: src/sys/geom/raid3/g_raid3.c,v 1.69 2006/07/10 21:18:00 pjd Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -3273,7 +3273,7 @@
if (g_raid3_ndisks(sc, G_RAID3_DISK_STATE_NODISK) ==
sc->sc_ndisks) {
g_cancel_event(sc);
- g_raid3_destroy(sc, 1);
+ g_raid3_destroy(sc, G_RAID3_DESTROY_HARD);
g_topology_lock();
return (NULL);
}
@@ -3295,7 +3295,7 @@
sc = gp->softc;
sx_xlock(&sc->sc_lock);
g_cancel_event(sc);
- error = g_raid3_destroy(gp->softc, 0);
+ error = g_raid3_destroy(gp->softc, G_RAID3_DESTROY_SOFT);
if (error != 0)
sx_xunlock(&sc->sc_lock);
g_topology_lock();
==== //depot/projects/smpng/sys/kern/kern_thr.c#34 (text+ko) ====
@@ -25,7 +25,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/kern/kern_thr.c,v 1.43 2006/04/17 18:20:37 jhb Exp $");
+__FBSDID("$FreeBSD: src/sys/kern/kern_thr.c,v 1.47 2006/07/11 08:19:57 davidxu Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@@ -42,29 +42,21 @@
#include <sys/signalvar.h>
#include <sys/ucontext.h>
#include <sys/thr.h>
+#include <sys/rtprio.h>
+#include <posix4/sched.h>
#include <sys/umtx.h>
#include <sys/limits.h>
#include <machine/frame.h>
extern int max_threads_per_proc;
-extern int max_groups_per_proc;
-
-SYSCTL_DECL(_kern_threads);
-static int thr_scope = 0;
-SYSCTL_INT(_kern_threads, OID_AUTO, thr_scope, CTLFLAG_RW,
- &thr_scope, 0, "sys or proc scope scheduling");
-static int thr_concurrency = 0;
-SYSCTL_INT(_kern_threads, OID_AUTO, thr_concurrency, CTLFLAG_RW,
- &thr_concurrency, 0, "a concurrency value if not default");
-
static int create_thread(struct thread *td, mcontext_t *ctx,
void (*start_func)(void *), void *arg,
char *stack_base, size_t stack_size,
char *tls_base,
long *child_tid, long *parent_tid,
- int flags);
+ int flags, struct thr_sched_param *sched);
/*
* System call interface.
@@ -80,7 +72,7 @@
return (error);
error = create_thread(td, &ctx.uc_mcontext, NULL, NULL,
- NULL, 0, NULL, uap->id, NULL, uap->flags);
+ NULL, 0, NULL, uap->id, NULL, uap->flags, NULL);
return (error);
}
@@ -89,15 +81,26 @@
/* struct thr_param * */
{
struct thr_param param;
+ struct thr_sched_param sched_param, *sched;
int error;
if (uap->param_size < sizeof(param))
return (EINVAL);
if ((error = copyin(uap->param, ¶m, sizeof(param))))
return (error);
+ sched = NULL;
+ if (param.sched != NULL) {
+ error = copyin(param.sched, &sched_param,
+ sizeof(sched_param));
+ if (error)
+ return (error);
+ sched = &sched_param;
+ }
+
error = create_thread(td, NULL, param.start_func, param.arg,
param.stack_base, param.stack_size, param.tls_base,
- param.child_tid, param.parent_tid, param.flags);
+ param.child_tid, param.parent_tid, param.flags,
+ sched);
return (error);
}
@@ -107,34 +110,41 @@
char *stack_base, size_t stack_size,
char *tls_base,
long *child_tid, long *parent_tid,
- int flags)
+ int flags, struct thr_sched_param *sched)
{
stack_t stack;
struct thread *newtd;
struct ksegrp *kg, *newkg;
struct proc *p;
long id;
- int error, scope_sys, linkkg;
+ int error;
error = 0;
p = td->td_proc;
kg = td->td_ksegrp;
/* Have race condition but it is cheap. */
- if ((p->p_numksegrps >= max_groups_per_proc) ||
- (p->p_numthreads >= max_threads_per_proc)) {
+ if (p->p_numthreads >= max_threads_per_proc)
return (EPROCLIM);
+
+ if (sched != NULL) {
+ switch(sched->policy) {
+ case SCHED_FIFO:
+ case SCHED_RR:
+ /* Only root can set scheduler policy */
+ if (suser(td) != 0)
+ return (EPERM);
+ if (sched->param.sched_priority < RTP_PRIO_MIN ||
+ sched->param.sched_priority > RTP_PRIO_MAX)
+ return (EINVAL);
+ break;
+ case SCHED_OTHER:
+ break;
+ default:
+ return (EINVAL);
+ }
}
- /* Check PTHREAD_SCOPE_SYSTEM */
- scope_sys = (flags & THR_SYSTEM_SCOPE) != 0;
-
- /* sysctl overrides user's flag */
- if (thr_scope == 1)
- scope_sys = 0;
- else if (thr_scope == 2)
- scope_sys = 1;
-
/* Initialize our td and new ksegrp.. */
newtd = thread_alloc();
@@ -186,66 +196,51 @@
}
}
- if ((td->td_proc->p_flag & P_HADTHREADS) == 0) {
- /* Treat initial thread as it has PTHREAD_SCOPE_PROCESS. */
- p->p_procscopegrp = kg;
- mtx_lock_spin(&sched_lock);
- sched_set_concurrency(kg,
- thr_concurrency ? thr_concurrency : (2*mp_ncpus));
- mtx_unlock_spin(&sched_lock);
- }
-
- linkkg = 0;
- if (scope_sys) {
- linkkg = 1;
- newkg = ksegrp_alloc();
- bzero(&newkg->kg_startzero,
- __rangeof(struct ksegrp, kg_startzero, kg_endzero));
- bcopy(&kg->kg_startcopy, &newkg->kg_startcopy,
- __rangeof(struct ksegrp, kg_startcopy, kg_endcopy));
- sched_init_concurrency(newkg);
- PROC_LOCK(td->td_proc);
- } else {
- /*
- * Try to create a KSE group which will be shared
- * by all PTHREAD_SCOPE_PROCESS threads.
- */
-retry:
- PROC_LOCK(td->td_proc);
- if ((newkg = p->p_procscopegrp) == NULL) {
- PROC_UNLOCK(p);
- newkg = ksegrp_alloc();
- bzero(&newkg->kg_startzero,
- __rangeof(struct ksegrp, kg_startzero, kg_endzero));
- bcopy(&kg->kg_startcopy, &newkg->kg_startcopy,
- __rangeof(struct ksegrp, kg_startcopy, kg_endcopy));
- PROC_LOCK(p);
- if (p->p_procscopegrp == NULL) {
- p->p_procscopegrp = newkg;
- sched_init_concurrency(newkg);
- sched_set_concurrency(newkg,
- thr_concurrency ? thr_concurrency : (2*mp_ncpus));
- linkkg = 1;
- } else {
- PROC_UNLOCK(p);
- ksegrp_free(newkg);
- goto retry;
- }
- }
- }
-
+ newkg = ksegrp_alloc();
+ bzero(&newkg->kg_startzero,
+ __rangeof(struct ksegrp, kg_startzero, kg_endzero));
+ bcopy(&kg->kg_startcopy, &newkg->kg_startcopy,
+ __rangeof(struct ksegrp, kg_startcopy, kg_endcopy));
+ sched_init_concurrency(newkg);
+ PROC_LOCK(td->td_proc);
td->td_proc->p_flag |= P_HADTHREADS;
newtd->td_sigmask = td->td_sigmask;
mtx_lock_spin(&sched_lock);
- if (linkkg)
- ksegrp_link(newkg, p);
+ ksegrp_link(newkg, p);
thread_link(newtd, newkg);
PROC_UNLOCK(p);
/* let the scheduler know about these things. */
- if (linkkg)
- sched_fork_ksegrp(td, newkg);
+ sched_fork_ksegrp(td, newkg);
sched_fork_thread(td, newtd);
+ if (sched != NULL) {
+ struct rtprio rtp;
+ switch (sched->policy) {
+ case SCHED_FIFO:
+ rtp.type = PRI_FIFO;
+ rtp.prio = sched->param.sched_priority;
+ rtp_to_pri(&rtp, newkg);
+ sched_prio(newtd, newkg->kg_user_pri);
+ break;
+ case SCHED_RR:
+ rtp.type = PRI_REALTIME;
+ rtp.prio = sched->param.sched_priority;
+ rtp_to_pri(&rtp, newkg);
+ sched_prio(newtd, newkg->kg_user_pri);
+ break;
+ case SCHED_OTHER:
+ if (curthread->td_ksegrp->kg_pri_class !=
+ PRI_TIMESHARE) {
+ rtp.type = PRI_TIMESHARE;
+ rtp.prio = 0;
+ rtp_to_pri(&rtp, newkg);
+ sched_prio(newtd, newkg->kg_user_pri);
+ }
+ break;
+ default:
+ panic("sched policy");
+ }
+ }
TD_SET_CAN_RUN(newtd);
/* if ((flags & THR_SUSPENDED) == 0) */
setrunqueue(newtd, SRQ_BORING);
==== //depot/projects/smpng/sys/kern/uipc_syscalls.c#87 (text+ko) ====
@@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/kern/uipc_syscalls.c,v 1.230 2006/06/20 12:36:40 gnn Exp $");
+__FBSDID("$FreeBSD: src/sys/kern/uipc_syscalls.c,v 1.231 2006/07/10 21:38:17 jhb Exp $");
#include "opt_compat.h"
#include "opt_ktrace.h"
==== //depot/projects/smpng/sys/posix4/ksched.c#18 (text+ko) ====
@@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/posix4/ksched.c,v 1.29 2006/06/15 06:37:39 davidxu Exp $");
+__FBSDID("$FreeBSD: src/sys/posix4/ksched.c,v 1.30 2006/07/11 06:11:34 davidxu Exp $");
#include "opt_posix.h"
@@ -100,7 +100,7 @@
#define P1B_PRIO_MAX rtpprio_to_p4prio(RTP_PRIO_MIN)
static __inline int
-getscheduler(register_t *ret, struct ksched *ksched, struct thread *td)
+getscheduler(struct ksched *ksched, struct thread *td, int *policy)
{
struct rtprio rtp;
int e = 0;
@@ -111,15 +111,15 @@
switch (rtp.type)
{
case RTP_PRIO_FIFO:
- *ret = SCHED_FIFO;
+ *policy = SCHED_FIFO;
break;
case RTP_PRIO_REALTIME:
- *ret = SCHED_RR;
+ *policy = SCHED_RR;
break;
default:
- *ret = SCHED_OTHER;
+ *policy = SCHED_OTHER;
break;
}
@@ -127,27 +127,27 @@
}
int
-ksched_setparam(register_t *ret, struct ksched *ksched,
+ksched_setparam(struct ksched *ksched,
struct thread *td, const struct sched_param *param)
{
- register_t policy;
+ int policy;
int e;
- e = getscheduler(&policy, ksched, td);
+ e = getscheduler(ksched, td, &policy);
if (e == 0)
{
if (policy == SCHED_OTHER)
e = EINVAL;
else
- e = ksched_setscheduler(ret, ksched, td, policy, param);
+ e = ksched_setscheduler(ksched, td, policy, param);
}
return e;
}
int
-ksched_getparam(register_t *ret, struct ksched *ksched,
+ksched_getparam(struct ksched *ksched,
struct thread *td, struct sched_param *param)
{
struct rtprio rtp;
@@ -169,7 +169,7 @@
*
*/
int
-ksched_setscheduler(register_t *ret, struct ksched *ksched,
+ksched_setscheduler(struct ksched *ksched,
struct thread *td, int policy, const struct sched_param *param)
{
int e = 0;
@@ -243,22 +243,22 @@
}
int
-ksched_getscheduler(register_t *ret, struct ksched *ksched, struct thread *td)
+ksched_getscheduler(struct ksched *ksched, struct thread *td, int *policy)
{
- return getscheduler(ret, ksched, td);
+ return getscheduler(ksched, td, policy);
}
/* ksched_yield: Yield the CPU.
*/
int
-ksched_yield(register_t *ret, struct ksched *ksched)
+ksched_yield(struct ksched *ksched)
{
sched_relinquish(curthread);
return 0;
}
int
-ksched_get_priority_max(register_t*ret, struct ksched *ksched, int policy)
+ksched_get_priority_max(struct ksched *ksched, int policy, int *prio)
{
int e = 0;
@@ -266,11 +266,11 @@
{
case SCHED_FIFO:
case SCHED_RR:
- *ret = RTP_PRIO_MAX;
+ *prio = RTP_PRIO_MAX;
break;
case SCHED_OTHER:
- *ret = PRIO_MAX;
+ *prio = PRIO_MAX;
break;
default:
@@ -281,7 +281,7 @@
}
int
-ksched_get_priority_min(register_t *ret, struct ksched *ksched, int policy)
+ksched_get_priority_min(struct ksched *ksched, int policy, int *prio)
{
int e = 0;
@@ -289,11 +289,11 @@
{
case SCHED_FIFO:
case SCHED_RR:
- *ret = P1B_PRIO_MIN;
+ *prio = P1B_PRIO_MIN;
break;
case SCHED_OTHER:
- *ret = PRIO_MIN;
+ *prio = PRIO_MIN;
break;
default:
@@ -304,8 +304,8 @@
}
int
-ksched_rr_get_interval(register_t *ret, struct ksched *ksched,
- struct thread *td, struct timespec *timespec)
+ksched_rr_get_interval(struct ksched *ksched,
+ struct thread *td, struct timespec *timespec)
{
*timespec = ksched->rr_interval;
==== //depot/projects/smpng/sys/posix4/p1003_1b.c#13 (text+ko) ====
@@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/posix4/p1003_1b.c,v 1.27 2006/05/21 00:40:38 davidxu Exp $");
+__FBSDID("$FreeBSD: src/sys/posix4/p1003_1b.c,v 1.29 2006/07/11 06:15:46 davidxu Exp $");
#include "opt_posix.h"
@@ -90,7 +90,6 @@
SYSCALL_NOT_PRESENT_GEN(sched_get_priority_max)
SYSCALL_NOT_PRESENT_GEN(sched_get_priority_min)
SYSCALL_NOT_PRESENT_GEN(sched_rr_get_interval)
-
#else
/* Configured in kernel version:
@@ -127,22 +126,27 @@
targetp = td->td_proc;
targettd = td;
PROC_LOCK(targetp);
+ } else if (uap->pid <= PID_MAX) {
+ targetp = pfind(uap->pid);
+ if (targetp == NULL)
+ return (ESRCH);
+ targettd = FIRST_THREAD_IN_PROC(targetp);
} else {
- targetp = pfind(uap->pid);
+ targetp = td->td_proc;
+ PROC_LOCK(targetp);
+ targettd = thread_find(targetp, uap->pid);
if (targetp == NULL) {
- e = ESRCH;
- goto done2;
+ PROC_UNLOCK(targetp);
+ return (ESRCH);
}
- targettd = FIRST_THREAD_IN_PROC(targetp); /* XXXKSE */
}
e = p_cansched(td, targetp);
if (e == 0) {
- e = ksched_setparam(&td->td_retval[0], ksched, targettd,
+ e = ksched_setparam(ksched, targettd,
(const struct sched_param *)&sched_param);
}
PROC_UNLOCK(targetp);
-done2:
return (e);
}
@@ -161,24 +165,29 @@
targetp = td->td_proc;
targettd = td;
PROC_LOCK(targetp);
- } else {
+ } else if (uap->pid <= PID_MAX) {
targetp = pfind(uap->pid);
if (targetp == NULL) {
- e = ESRCH;
- goto done2;
+ return (ESRCH);
}
targettd = FIRST_THREAD_IN_PROC(targetp); /* XXXKSE */
+ } else {
+ targetp = td->td_proc;
+ PROC_LOCK(targetp);
+ targettd = thread_find(targetp, uap->pid);
+ if (targettd == NULL) {
+ PROC_UNLOCK(targetp);
+ return (ESRCH);
+ }
}
e = p_cansee(td, targetp);
if (e == 0) {
- e = ksched_getparam(&td->td_retval[0], ksched, targettd,
- &sched_param);
+ e = ksched_getparam(ksched, targettd, &sched_param);
}
PROC_UNLOCK(targetp);
if (e == 0)
e = copyout(&sched_param, uap->param, sizeof(sched_param));
-done2:
return (e);
}
@@ -205,22 +214,27 @@
targetp = td->td_proc;
targettd = td;
PROC_LOCK(targetp);
+ } else if (uap->pid <= PID_MAX) {
+ targetp = pfind(uap->pid);
+ if (targetp == NULL)
+ return (ESRCH);
+ targettd = FIRST_THREAD_IN_PROC(targetp);
} else {
- targetp = pfind(uap->pid);
- if (targetp == NULL) {
- e = ESRCH;
- goto done2;
+ targetp = td->td_proc;
+ PROC_LOCK(targetp);
+ targettd = thread_find(targetp, uap->pid);
+ if (targettd == NULL) {
+ PROC_UNLOCK(targetp);
+ return (ESRCH);
}
- targettd = FIRST_THREAD_IN_PROC(targetp); /* XXXKSE */
}
e = p_cansched(td, targetp);
if (e == 0) {
- e = ksched_setscheduler(&td->td_retval[0], ksched, targettd,
+ e = ksched_setscheduler(ksched, targettd,
uap->policy, (const struct sched_param *)&sched_param);
}
PROC_UNLOCK(targetp);
-done2:
return (e);
>>> TRUNCATED FOR MAIL (1000 lines) <<<
More information about the p4-projects
mailing list