svn commit: r254504 - in projects/umtx: include sys/conf sys/kern sys/sys
Davide Italiano
davide at FreeBSD.org
Sun Aug 18 23:12:18 UTC 2013
Author: davide
Date: Sun Aug 18 23:12:16 2013
New Revision: 254504
URL: http://svnweb.freebsd.org/changeset/base/254504
Log:
Introduce a facility to share the thread state between kernel and userland.
The API is the same of Solaris' schedctl(), even though the implementation
is probably different. There are still some rough edges (e.g. structures
are not cleaned up upon thread exit/proc exit) but I'll have some patches
to address them and I'm going to fix in the next days after some testing.
Discussed with: kib, attilio
Modified:
projects/umtx/include/unistd.h
projects/umtx/sys/conf/files
projects/umtx/sys/kern/init_sysent.c
projects/umtx/sys/kern/sched_ule.c
projects/umtx/sys/kern/syscalls.c
projects/umtx/sys/kern/syscalls.master
projects/umtx/sys/kern/systrace_args.c
projects/umtx/sys/sys/proc.h
projects/umtx/sys/sys/syscall.h
projects/umtx/sys/sys/syscall.mk
projects/umtx/sys/sys/sysproto.h
Modified: projects/umtx/include/unistd.h
==============================================================================
--- projects/umtx/include/unistd.h Sun Aug 18 22:20:53 2013 (r254503)
+++ projects/umtx/include/unistd.h Sun Aug 18 23:12:16 2013 (r254504)
@@ -534,6 +534,7 @@ char *mktemp(char *);
#endif
int nfssvc(int, void *);
int nlm_syscall(int, int, int, char **);
+caddr_t schedctl(void);
int pipe2(int *, int);
int profil(char *, size_t, vm_offset_t, int);
int rcmd(char **, int, const char *, const char *, const char *, int *);
Modified: projects/umtx/sys/conf/files
==============================================================================
--- projects/umtx/sys/conf/files Sun Aug 18 22:20:53 2013 (r254503)
+++ projects/umtx/sys/conf/files Sun Aug 18 23:12:16 2013 (r254504)
@@ -2811,6 +2811,7 @@ kern/kern_rctl.c standard
kern/kern_resource.c standard
kern/kern_rmlock.c standard
kern/kern_rwlock.c standard
+kern/kern_schedctl.c standard
kern/kern_sdt.c optional kdtrace_hooks
kern/kern_sema.c standard
kern/kern_sharedpage.c standard
Modified: projects/umtx/sys/kern/init_sysent.c
==============================================================================
--- projects/umtx/sys/kern/init_sysent.c Sun Aug 18 22:20:53 2013 (r254503)
+++ projects/umtx/sys/kern/init_sysent.c Sun Aug 18 23:12:16 2013 (r254504)
@@ -578,4 +578,5 @@ struct sysent sysent[] = {
{ AS(accept4_args), (sy_call_t *)sys_accept4, AUE_ACCEPT, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 541 = accept4 */
{ AS(pipe2_args), (sy_call_t *)sys_pipe2, AUE_PIPE, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 542 = pipe2 */
{ AS(aio_mlock_args), (sy_call_t *)lkmressys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 543 = aio_mlock */
+ { 0, (sy_call_t *)sys_schedctl, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 544 = schedctl */
};
Modified: projects/umtx/sys/kern/sched_ule.c
==============================================================================
--- projects/umtx/sys/kern/sched_ule.c Sun Aug 18 22:20:53 2013 (r254503)
+++ projects/umtx/sys/kern/sched_ule.c Sun Aug 18 23:12:16 2013 (r254504)
@@ -25,7 +25,7 @@
*/
/*
- * This file implements the ULE scheduler. ULE supports independent CPU
+ * This file implements the ULE Scheduler. ULE supports independent CPU
* run queues and fine grain locking. It has superior interactive
* performance under load even on uni-processor systems.
*
@@ -1944,7 +1944,8 @@ sched_switch(struct thread *td, struct t
if (dtrace_vtime_active)
(*dtrace_vtime_switch_func)(newtd);
#endif
-
+ if (td->td_schedctl != NULL)
+ td->td_schedctl->sh_state = STATE_OFFCPU;
cpu_switch(td, newtd, mtx);
/*
* We may return from cpu_switch on a different cpu. However,
@@ -1971,6 +1972,8 @@ sched_switch(struct thread *td, struct t
TDQ_LOCK_ASSERT(tdq, MA_OWNED|MA_NOTRECURSED);
MPASS(td->td_lock == TDQ_LOCKPTR(tdq));
td->td_oncpu = cpuid;
+ if (td->td_schedctl != NULL)
+ td->td_schedctl->sh_state = STATE_ONCPU;
}
/*
Modified: projects/umtx/sys/kern/syscalls.c
==============================================================================
--- projects/umtx/sys/kern/syscalls.c Sun Aug 18 22:20:53 2013 (r254503)
+++ projects/umtx/sys/kern/syscalls.c Sun Aug 18 23:12:16 2013 (r254504)
@@ -551,4 +551,5 @@ const char *syscallnames[] = {
"accept4", /* 541 = accept4 */
"pipe2", /* 542 = pipe2 */
"aio_mlock", /* 543 = aio_mlock */
+ "schedctl", /* 544 = schedctl */
};
Modified: projects/umtx/sys/kern/syscalls.master
==============================================================================
--- projects/umtx/sys/kern/syscalls.master Sun Aug 18 22:20:53 2013 (r254503)
+++ projects/umtx/sys/kern/syscalls.master Sun Aug 18 23:12:16 2013 (r254504)
@@ -978,5 +978,6 @@
int flags); }
542 AUE_PIPE STD { int pipe2(int *fildes, int flags); }
543 AUE_NULL NOSTD { int aio_mlock(struct aiocb *aiocbp); }
+544 AUE_NULL STD { caddr_t schedctl(void); }
; Please copy any additions and changes to the following compatability tables:
; sys/compat/freebsd32/syscalls.master
Modified: projects/umtx/sys/kern/systrace_args.c
==============================================================================
--- projects/umtx/sys/kern/systrace_args.c Sun Aug 18 22:20:53 2013 (r254503)
+++ projects/umtx/sys/kern/systrace_args.c Sun Aug 18 23:12:16 2013 (r254504)
@@ -3383,6 +3383,11 @@ systrace_args(int sysnum, void *params,
*n_args = 1;
break;
}
+ /* schedctl */
+ case 544: {
+ *n_args = 0;
+ break;
+ }
default:
*n_args = 0;
break;
@@ -9012,6 +9017,9 @@ systrace_entry_setargdesc(int sysnum, in
break;
};
break;
+ /* schedctl */
+ case 544:
+ break;
default:
break;
};
@@ -10960,6 +10968,8 @@ systrace_return_setargdesc(int sysnum, i
if (ndx == 0 || ndx == 1)
p = "int";
break;
+ /* schedctl */
+ case 544:
default:
break;
};
Modified: projects/umtx/sys/sys/proc.h
==============================================================================
--- projects/umtx/sys/sys/proc.h Sun Aug 18 22:20:53 2013 (r254503)
+++ projects/umtx/sys/sys/proc.h Sun Aug 18 23:12:16 2013 (r254504)
@@ -53,6 +53,7 @@
#include <sys/rtprio.h> /* XXX. */
#include <sys/runq.h>
#include <sys/resource.h>
+#include <sys/schedctl.h>
#include <sys/sigio.h>
#include <sys/signal.h>
#include <sys/signalvar.h>
@@ -275,6 +276,8 @@ struct thread {
u_int td_vp_reserv; /* (k) Count of reserved vnodes. */
int td_no_sleeping; /* (k) Sleeping disabled count. */
int td_dom_rr_idx; /* (k) RR Numa domain selection. */
+ shstate_t *td_schedctl; /* (k) Schedctl informations. */
+ shstate_t *td_usrschedctl;
#define td_endzero td_sigmask
/* Copied during fork1() or create_thread(). */
@@ -546,6 +549,7 @@ struct proc {
int p_pendingcnt; /* how many signals are pending */
struct itimers *p_itimers; /* (c) POSIX interval timers. */
struct procdesc *p_procdesc; /* (e) Process descriptor, if any. */
+ SLIST_HEAD(, page_shared) p_shpg; /* List of shared pages, if any. */
/* End area that is zeroed on creation. */
#define p_endzero p_magic
Modified: projects/umtx/sys/sys/syscall.h
==============================================================================
--- projects/umtx/sys/sys/syscall.h Sun Aug 18 22:20:53 2013 (r254503)
+++ projects/umtx/sys/sys/syscall.h Sun Aug 18 23:12:16 2013 (r254504)
@@ -463,4 +463,5 @@
#define SYS_accept4 541
#define SYS_pipe2 542
#define SYS_aio_mlock 543
-#define SYS_MAXSYSCALL 544
+#define SYS_schedctl 544
+#define SYS_MAXSYSCALL 545
Modified: projects/umtx/sys/sys/syscall.mk
==============================================================================
--- projects/umtx/sys/sys/syscall.mk Sun Aug 18 22:20:53 2013 (r254503)
+++ projects/umtx/sys/sys/syscall.mk Sun Aug 18 23:12:16 2013 (r254504)
@@ -411,4 +411,5 @@ MIASM = \
chflagsat.o \
accept4.o \
pipe2.o \
- aio_mlock.o
+ aio_mlock.o \
+ schedctl.o
Modified: projects/umtx/sys/sys/sysproto.h
==============================================================================
--- projects/umtx/sys/sys/sysproto.h Sun Aug 18 22:20:53 2013 (r254503)
+++ projects/umtx/sys/sys/sysproto.h Sun Aug 18 23:12:16 2013 (r254504)
@@ -1815,6 +1815,9 @@ struct pipe2_args {
struct aio_mlock_args {
char aiocbp_l_[PADL_(struct aiocb *)]; struct aiocb * aiocbp; char aiocbp_r_[PADR_(struct aiocb *)];
};
+struct schedctl_args {
+ register_t dummy;
+};
int nosys(struct thread *, struct nosys_args *);
void sys_sys_exit(struct thread *, struct sys_exit_args *);
int sys_fork(struct thread *, struct fork_args *);
@@ -2208,6 +2211,7 @@ int sys_chflagsat(struct thread *, struc
int sys_accept4(struct thread *, struct accept4_args *);
int sys_pipe2(struct thread *, struct pipe2_args *);
int sys_aio_mlock(struct thread *, struct aio_mlock_args *);
+int sys_schedctl(struct thread *, struct schedctl_args *);
#ifdef COMPAT_43
@@ -2915,6 +2919,7 @@ int freebsd7_shmctl(struct thread *, str
#define SYS_AUE_accept4 AUE_ACCEPT
#define SYS_AUE_pipe2 AUE_PIPE
#define SYS_AUE_aio_mlock AUE_NULL
+#define SYS_AUE_schedctl AUE_NULL
#undef PAD_
#undef PADL_
More information about the svn-src-projects
mailing list