Adjust to separate kcpuset_t and cpuset_t.
This commit is contained in:
parent
dfeefcdcb8
commit
1d875fc75f
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: kern_runq.c,v 1.18 2008/06/16 01:41:20 rmind Exp $ */
|
||||
/* $NetBSD: kern_runq.c,v 1.19 2008/06/22 00:06:36 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007, 2008 Mindaugas Rasiukevicius <rmind at NetBSD org>
|
||||
@ -27,7 +27,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: kern_runq.c,v 1.18 2008/06/16 01:41:20 rmind Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: kern_runq.c,v 1.19 2008/06/22 00:06:36 christos Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/kernel.h>
|
||||
@ -351,7 +351,7 @@ sched_migratable(const struct lwp *l, struct cpu_info *ci)
|
||||
|
||||
/* Affinity bind */
|
||||
if (__predict_false(l->l_flag & LW_AFFINITY))
|
||||
return cpuset_isset(cpu_index(ci), l->l_affinity);
|
||||
return kcpuset_isset(cpu_index(ci), l->l_affinity);
|
||||
|
||||
/* Processor-set */
|
||||
return (spc->spc_psid == l->l_psid);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: sys_sched.c,v 1.25 2008/06/16 01:41:20 rmind Exp $ */
|
||||
/* $NetBSD: sys_sched.c,v 1.26 2008/06/22 00:06:36 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008, Mindaugas Rasiukevicius <rmind at NetBSD org>
|
||||
@ -35,7 +35,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: sys_sched.c,v 1.25 2008/06/16 01:41:20 rmind Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: sys_sched.c,v 1.26 2008/06/22 00:06:36 christos Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
|
||||
@ -293,28 +293,14 @@ sys__sched_getparam(struct lwp *l, const struct sys__sched_getparam_args *uap,
|
||||
|
||||
/* Allocate the CPU set, and get it from userspace */
|
||||
static int
|
||||
gencpuset(cpuset_t **dset, const cpuset_t *sset, size_t size)
|
||||
genkcpuset(kcpuset_t **dset, const cpuset_t *sset, size_t size)
|
||||
{
|
||||
int error;
|
||||
|
||||
*dset = cpuset_create();
|
||||
if (size != cpuset_size(*dset)) {
|
||||
error = EINVAL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
error = copyin(sset, *dset, size);
|
||||
if (error)
|
||||
goto out;
|
||||
|
||||
if (kcpuset_nused(*dset) != 1) {
|
||||
error = EINVAL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
return 0;
|
||||
out:
|
||||
kcpuset_unuse(*dset, NULL);
|
||||
*dset = kcpuset_create();
|
||||
error = kcpuset_copyin(sset, *dset, size);
|
||||
if (error != 0)
|
||||
kcpuset_unuse(*dset, NULL);
|
||||
return error;
|
||||
}
|
||||
|
||||
@ -331,7 +317,7 @@ sys__sched_setaffinity(struct lwp *l,
|
||||
syscallarg(size_t) size;
|
||||
syscallarg(const cpuset_t *) cpuset;
|
||||
} */
|
||||
cpuset_t *cpuset, *cpulst = NULL;
|
||||
kcpuset_t *cpuset, *cpulst = NULL;
|
||||
struct cpu_info *ci = NULL;
|
||||
struct proc *p;
|
||||
struct lwp *t;
|
||||
@ -340,12 +326,12 @@ sys__sched_setaffinity(struct lwp *l,
|
||||
u_int lcnt;
|
||||
int error;
|
||||
|
||||
if ((error = gencpuset(&cpuset, SCARG(uap, cpuset), SCARG(uap, size))))
|
||||
if ((error = genkcpuset(&cpuset, SCARG(uap, cpuset), SCARG(uap, size))))
|
||||
return error;
|
||||
|
||||
/* Look for a CPU in the set */
|
||||
for (CPU_INFO_FOREACH(cii, ci)) {
|
||||
error = cpuset_isset(cpu_index(ci), cpuset);
|
||||
error = kcpuset_isset(cpu_index(ci), cpuset);
|
||||
if (error) {
|
||||
if (error == -1) {
|
||||
error = E2BIG;
|
||||
@ -426,7 +412,7 @@ sys__sched_setaffinity(struct lwp *l,
|
||||
out:
|
||||
if (cpuset != NULL)
|
||||
kcpuset_unuse(cpuset, &cpulst);
|
||||
cpuset_destroy(cpulst);
|
||||
kcpuset_destroy(cpulst);
|
||||
return error;
|
||||
}
|
||||
|
||||
@ -444,10 +430,10 @@ sys__sched_getaffinity(struct lwp *l,
|
||||
syscallarg(cpuset_t *) cpuset;
|
||||
} */
|
||||
struct lwp *t;
|
||||
cpuset_t *cpuset;
|
||||
kcpuset_t *cpuset;
|
||||
int error;
|
||||
|
||||
if ((error = gencpuset(&cpuset, SCARG(uap, cpuset), SCARG(uap, size))))
|
||||
if ((error = genkcpuset(&cpuset, SCARG(uap, cpuset), SCARG(uap, size))))
|
||||
return error;
|
||||
|
||||
/* Locks the LWP */
|
||||
@ -468,11 +454,11 @@ sys__sched_getaffinity(struct lwp *l,
|
||||
KASSERT(t->l_affinity != NULL);
|
||||
kcpuset_copy(cpuset, t->l_affinity);
|
||||
} else
|
||||
cpuset_zero(cpuset);
|
||||
kcpuset_zero(cpuset);
|
||||
lwp_unlock(t);
|
||||
mutex_exit(t->l_proc->p_lock);
|
||||
|
||||
error = copyout(cpuset, SCARG(uap, cpuset), cpuset_size(cpuset));
|
||||
error = kcpuset_copyout(cpuset, SCARG(uap, cpuset), SCARG(uap, size));
|
||||
out:
|
||||
kcpuset_unuse(cpuset, NULL);
|
||||
return error;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: lwp.h,v 1.101 2008/06/17 09:08:52 ad Exp $ */
|
||||
/* $NetBSD: lwp.h,v 1.102 2008/06/22 00:06:36 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001, 2006, 2007, 2008 The NetBSD Foundation, Inc.
|
||||
@ -104,7 +104,7 @@ struct lwp {
|
||||
kmutex_t l_swaplock; /* l: lock to prevent swapping */
|
||||
struct lwpctl *l_lwpctl; /* p: lwpctl block kernel address */
|
||||
struct lcpage *l_lcpage; /* p: lwpctl containing page */
|
||||
cpuset_t *l_affinity; /* l: CPU set for affinity */
|
||||
kcpuset_t *l_affinity; /* l: CPU set for affinity */
|
||||
|
||||
/* Synchronisation */
|
||||
struct turnstile *l_ts; /* l: current turnstile */
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: sched.h,v 1.60 2008/06/16 01:41:21 rmind Exp $ */
|
||||
/* $NetBSD: sched.h,v 1.61 2008/06/22 00:06:36 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1999, 2000, 2001, 2002, 2007, 2008 The NetBSD Foundation, Inc.
|
||||
@ -89,32 +89,44 @@ struct sched_param {
|
||||
#define SCHED_FIFO 1
|
||||
#define SCHED_RR 2
|
||||
|
||||
__BEGIN_DECLS
|
||||
#if defined(_NETBSD_SOURCE)
|
||||
/*
|
||||
* Interface of CPU-sets.
|
||||
*/
|
||||
typedef struct _cpuset cpuset_t;
|
||||
typedef struct _kcpuset kcpuset_t; /* XXX: lwp.h included from userland */
|
||||
|
||||
#ifdef _KERNEL
|
||||
|
||||
|
||||
kcpuset_t *kcpuset_create(void);
|
||||
void kcpuset_destroy(kcpuset_t *);
|
||||
void kcpuset_copy(kcpuset_t *, const kcpuset_t *);
|
||||
void kcpuset_use(kcpuset_t *);
|
||||
void kcpuset_unuse(kcpuset_t *, kcpuset_t **);
|
||||
int kcpuset_copyin(const cpuset_t *, kcpuset_t *, size_t);
|
||||
int kcpuset_copyout(const kcpuset_t *, cpuset_t *, size_t);
|
||||
void kcpuset_zero(kcpuset_t *);
|
||||
int kcpuset_isset(cpuid_t, const kcpuset_t *);
|
||||
|
||||
#else
|
||||
|
||||
#define cpuset_create() _cpuset_create()
|
||||
#define cpuset_destroy(c) _cpuset_destroy(c)
|
||||
#define cpuset_size(c) _cpuset_size(c)
|
||||
#define cpuset_zero(c) _cpuset_zero(c)
|
||||
#define cpuset_isset(i, c) _cpuset_isset(c, i)
|
||||
#define cpuset_set(i, c) _cpuset_set(c, i)
|
||||
#define cpuset_clr(i, c) _cpuset_clr(c, i)
|
||||
#define cpuset_isset(i, c) _cpuset_isset(i, c)
|
||||
#define cpuset_set(i, c) _cpuset_set(i, c)
|
||||
#define cpuset_clr(i, c) _cpuset_clr(i, c)
|
||||
|
||||
cpuset_t *_cpuset_create(void);
|
||||
void _cpuset_destroy(cpuset_t *);
|
||||
void _cpuset_zero(cpuset_t *);
|
||||
int _cpuset_set(cpuset_t *, cpuid_t);
|
||||
int _cpuset_clr(cpuset_t *, cpuid_t);
|
||||
int _cpuset_isset(const cpuset_t *, cpuid_t);
|
||||
int _cpuset_set(cpuid_t, cpuset_t *);
|
||||
int _cpuset_clr(cpuid_t, cpuset_t *);
|
||||
int _cpuset_isset(cpuid_t, const cpuset_t *);
|
||||
size_t _cpuset_size(const cpuset_t *);
|
||||
#ifdef _KERNEL
|
||||
void kcpuset_copy(cpuset_t *, const cpuset_t *);
|
||||
void kcpuset_use(cpuset_t *);
|
||||
void kcpuset_unuse(cpuset_t *, cpuset_t **);
|
||||
size_t kcpuset_nused(const cpuset_t *);
|
||||
#endif
|
||||
|
||||
/*
|
||||
@ -124,6 +136,7 @@ int _sched_getaffinity(pid_t, lwpid_t, size_t, cpuset_t *);
|
||||
int _sched_setaffinity(pid_t, lwpid_t, size_t, const cpuset_t *);
|
||||
int _sched_getparam(pid_t, lwpid_t, int *, struct sched_param *);
|
||||
int _sched_setparam(pid_t, lwpid_t, int, const struct sched_param *);
|
||||
__END_DECLS
|
||||
|
||||
/*
|
||||
* CPU states.
|
||||
|
Loading…
Reference in New Issue
Block a user