diff --git a/sys/kern/kern_syscalls.c b/sys/kern/kern_syscalls.c index 93d40d420541..b9dbf45015a4 100644 --- a/sys/kern/kern_syscalls.c +++ b/sys/kern/kern_syscalls.c @@ -80,14 +80,12 @@ syscall_thread_drain(struct sysent *se) } int -syscall_thread_enter(struct thread *td, struct sysent *se) +_syscall_thread_enter(struct thread *td, struct sysent *se) { u_int32_t cnt, oldcnt; do { oldcnt = se->sy_thrcnt; - if ((oldcnt & SY_THR_STATIC) != 0) - return (0); if ((oldcnt & (SY_THR_DRAINING | SY_THR_ABSENT)) != 0) return (ENOSYS); cnt = oldcnt + SY_THR_INCR; @@ -96,14 +94,12 @@ syscall_thread_enter(struct thread *td, struct sysent *se) } void -syscall_thread_exit(struct thread *td, struct sysent *se) +_syscall_thread_exit(struct thread *td, struct sysent *se) { u_int32_t cnt, oldcnt; do { oldcnt = se->sy_thrcnt; - if ((oldcnt & SY_THR_STATIC) != 0) - return; cnt = oldcnt - SY_THR_INCR; } while (atomic_cmpset_rel_32(&se->sy_thrcnt, oldcnt, cnt) == 0); } diff --git a/sys/sys/sysent.h b/sys/sys/sysent.h index e4117cc2ec2a..3938a8ab0e95 100644 --- a/sys/sys/sysent.h +++ b/sys/sys/sysent.h @@ -289,8 +289,26 @@ struct nosys_args; int lkmnosys(struct thread *, struct nosys_args *); int lkmressys(struct thread *, struct nosys_args *); -int syscall_thread_enter(struct thread *td, struct sysent *se); -void syscall_thread_exit(struct thread *td, struct sysent *se); +int _syscall_thread_enter(struct thread *td, struct sysent *se); +void _syscall_thread_exit(struct thread *td, struct sysent *se); + +static inline int +syscall_thread_enter(struct thread *td, struct sysent *se) +{ + + if (__predict_true((se->sy_thrcnt & SY_THR_STATIC) != 0)) + return (0); + return (_syscall_thread_enter(td, se)); +} + +static inline void +syscall_thread_exit(struct thread *td, struct sysent *se) +{ + + if (__predict_true((se->sy_thrcnt & SY_THR_STATIC) != 0)) + return; + _syscall_thread_exit(td, se); +} int shared_page_alloc(int size, int align); int shared_page_fill(int size, int align, const void *data);