Commit Graph

31 Commits

Author SHA1 Message Date
rmind 8f1873ea3b - Avoid the race with CPU online/offline state changes, when setting the
affinity (cpu_lock protects these operations now).
- Disallow setting of state of CPU to to offline, if there are bound LWPs,
  which have no CPU to migrate.
- Disallow setting of affinity for the LWP(s), if all CPUs in the dynamic
  CPU-set are offline.
- sched_setaffinity: fix invalid check of kcpuset_isset().
- Rename cpu_setonline() to cpu_setstate().

Should fix PR/39349.
2008-10-31 00:36:22 +00:00
rmind a8552a3a74 Obviously intention was to check for SCHED_OTHER, not SCHED_FIFO. 2008-10-18 19:24:04 +00:00
rmind d5ea013e1d Disallow user priority adjustments for SCHED_OTHER policy, simplify
convert_pri().  Sync schedctl(8) with the change.  Closes PR/38009.
2008-10-18 03:40:18 +00:00
wrstuden fc7511b00e Merge wrstuden-revivesa into HEAD. 2008-10-15 06:51:17 +00:00
rmind 4f91cff093 - Disallow setting of affinity for zombie LWPs.
- Fix the possible NULL dereference when LWP exiting.
- Fix the inhertance of affinity.
2008-07-14 01:19:37 +00:00
christos 1d875fc75f Adjust to separate kcpuset_t and cpuset_t. 2008-06-22 00:06:36 +00:00
rmind 481ae1556f - Add general cpuset macros.
- Use kcpuset name for kernel-only functions.
- Use cpuid_t to specify CPU ID.
- Unify all cpuset users.

API is expected to be stable now.
2008-06-16 01:41:20 +00:00
rmind a6092d3c4a gencpuset: avoid returning of unitialized error.
sched_setaffinity: instead of E2BIG, return EINVAL in a case of invalid
CPU, which is more consistent.
2008-06-15 23:29:09 +00:00
christos f30b5785d5 Don't expose struct cpuset, share the l_affinity flag and only allocate it
if we need to. This is not a compatible change, but the syscalls are new
enough and they don't need to be versioned. Approved by rmind.
2008-06-15 20:32:57 +00:00
ad 1cc9a3ae7e If converting a process/thread from SCHED_OTHER to a realtime thread,
ignore the existing priority. If no priority is specified, give threads
the minimum user RT priority.
2008-05-25 23:34:24 +00:00
ad 284c2b9aef Merge proc::p_mutex and proc::p_smutex into a single adaptive mutex, since
we no longer need to guard against access from hardware interrupt handlers.

Additionally, if cloning a process with CLONE_SIGHAND, arrange to have the
child process share the parent's lock so that signal state may be kept in
sync. Partially addresses PR kern/37437.
2008-04-24 18:39:20 +00:00
ad 6d70f903e6 Network protocol interrupts can now block on locks, so merge the globals
proclist_mutex and proclist_lock into a single adaptive mutex (proc_lock).
Implications:

- Inspecting process state requires thread context, so signals can no longer
  be sent from a hardware interrupt handler. Signal activity must be
  deferred to a soft interrupt or kthread.

- As the proc state locking is simplified, it's now safe to take exit()
  and wait() out from under kernel_lock.

- The system spends less time at IPL_SCHED, and there is less lock activity.
2008-04-24 15:35:27 +00:00
njoly 425fc32da6 s/Minimal/Maximal/ in kern.sched.pri_max sysctl node description. 2008-03-05 12:47:13 +00:00
elad 67470a76a1 Factor out the guts of get/setparam so it can be used from the compat code.
Make the FreeBSD and Linux compat code convert the parameters to their
native representation and call the native routines.

Remove KAUTH_PROCESS_SCHEDULER_GET/SET.

Update documentation and examples.

XXX: For now, only the Linux compat code does the priority conversion
XXX: right.

Linux priority conversion code from yamt@, thanks!

Okay yamt@.
2008-02-28 16:09:18 +00:00
ad 9a0b455f25 - Add a one line comment indicating what this file does.
- Move the check for PK_SYSTEM to a more sane place.
2008-02-22 23:10:12 +00:00
rmind 9850c0557d sys__sched_getparam and sys__sched_getaffinity: Do not assume that LWP
with LID=1 exists, use LIST_FIRST(&p->p_lwps) instead.
Fixes PR/37987 by <yamt>.

While here, adjust license.
2008-02-22 22:32:49 +00:00
drochner cc0caabca7 fix sched_setparam() error reporting (broken by recent kauth changes) 2008-02-19 19:38:18 +00:00
yamt aa57485fe2 sys__sched_setparam: fix a lock leak. 2008-02-19 09:44:26 +00:00
yamt 146e2f8297 sys__sched_setparam: use a correct lwp. 2008-02-18 02:00:08 +00:00
elad 0bb7f5ccb3 PR/37986: YAMAMOTO Takashi: any user can hog the all cpu with
_sched_setparam.

Pass proper context to kauth(9) for a decision to made based on the
scheduling policy and priority.
2008-02-17 19:22:35 +00:00
elad e99760e7e4 Fold KAUTH_REQ_PROCESS_SCHEDULER_* to KAUTH_PROCESS_SCHEDULER_*. In other
words, don't pass an action and a request, and just use a single action to
indicate what is the operation in question.

This is the first step in fixing PR/37986, which calls for policy/priority
checking in the secmodel code. Right now we're lacking room for another
parameter required to make a decision, and this change makes room for such.
2008-02-16 16:39:34 +00:00
yamt 16b042cbdb from rmind@,
- revert struct sched_param changes to restore ABI.
- instead, add 'policy' arguments to _sched_{get,set}param syscalls.
  (this is an API/ABI change.)
- correct kauth_authorize_process arguments.

while i'm here,
- don't bother to kmem_alloc for 4-byte structure.
2008-02-09 16:58:01 +00:00
elad 17bc624c06 EACCES -> EPERM. 2008-01-31 01:21:17 +00:00
elad fb37bad459 Use proper kauth(9) actions/requests for native scheduler stuff and the
recently introduced processor-sets.

Discussed with and okay rmind@, yamt@, and christos@.
2008-01-30 17:54:55 +00:00
rmind b5e9addd22 sched_setparam: fix the case when incorrect (according to the class)
in-kernel priority is used.  Reported by <drochner>.

Minor fixes for scheduling calls to conform the POSIX:
- If pid is equal to zero, use the calling process;
- In case of permission problem, return EPERM instead of EACESS;
- sched_setscheduler() should return previously used policy;
- pthread_* calls should return the error code or zero;

Should fix the namespace problems (and builds of some packages):
- Move cpuset_t defintion from pset.h to sched.h;
- Remove the #include of pset.h in pthread.h;
2008-01-26 17:55:29 +00:00
rmind aa633f0365 Fix the return values to conform the standard and/or be compatible with
other systems.  Reported by <drochner>.
2008-01-24 14:41:12 +00:00
rmind 5c71a4d49f Implementation of processor-sets, affinity and POSIX real-time extensions.
Add schedctl(8) - a program to control scheduling of processes and threads.

Notes:
- This is supported only by SCHED_M2;
- Migration of LWP mechanism will be revisited;

Proposed on: <tech-kern>. Reviewed by: <ad>.
2008-01-15 03:37:10 +00:00
dsl 7e2790cf6f Convert all the system call entry points from:
int foo(struct lwp *l, void *v, register_t *retval)
to:
    int foo(struct lwp *l, const struct foo_args *uap, register_t *retval)
Fixup compat code to not write into 'uap' and (in some cases) to actually
pass a correctly formatted 'uap' structure with the right name to the
next routine.
A few 'compat' routines that just call standard ones have been deleted.
All the 'compat' code compiles (along with the kernels required to test
build it).
98% done by automated scripts.
2007-12-20 23:02:38 +00:00
ad b07ec3fc38 Merge newlock2 to head. 2007-02-09 21:55:00 +00:00
dogcow 8f871f1a8d #include <sys/sa.h> to get sys_upcall_t def. 2007-01-16 20:12:40 +00:00
ad 606e323b3e Add sched_yield(). 2007-01-16 05:28:45 +00:00