CVS commit: src/sys/arch/x86
Module Name:src Committed By: ad Date: Thu Nov 21 21:48:34 UTC 2019 Modified Files: src/sys/arch/x86/include: cpu.h src/sys/arch/x86/x86: x86_tlb.c Log Message: x86 TLB shootdown IPI changes: - Shave some time off processing. - Reduce cacheline/bus traffic on systems with many CPUs. - Reduce time spent at IPL_VM. To generate a diff of this commit: cvs rdiff -u -r1.111 -r1.112 src/sys/arch/x86/include/cpu.h cvs rdiff -u -r1.8 -r1.9 src/sys/arch/x86/x86/x86_tlb.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys
Module Name:src Committed By: ad Date: Thu Nov 21 21:42:31 UTC 2019 Modified Files: src/sys/kern: sys_select.c src/sys/sys: selinfo.h Log Message: Minor improvements to select/poll: - Increase the maximum number of clusters from 32 to 64 for large systems. kcpuset_t could potentially be used here but that's an excursion I don't want to go on right now. uint32_t -> uint64_t is very simple. - In the case of a non-blocking select/poll, or where we won't block because there are events ready to report, stop registering interest in the back-end objects early. - Change the wmesg for poll back to "poll". To generate a diff of this commit: cvs rdiff -u -r1.48 -r1.49 src/sys/kern/sys_select.c cvs rdiff -u -r1.8 -r1.9 src/sys/sys/selinfo.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/sys_select.c diff -u src/sys/kern/sys_select.c:1.48 src/sys/kern/sys_select.c:1.49 --- src/sys/kern/sys_select.c:1.48 Fri Sep 20 15:00:47 2019 +++ src/sys/kern/sys_select.c Thu Nov 21 21:42:30 2019 @@ -1,7 +1,7 @@ -/* $NetBSD: sys_select.c,v 1.48 2019/09/20 15:00:47 kamil Exp $ */ +/* $NetBSD: sys_select.c,v 1.49 2019/11/21 21:42:30 ad Exp $ */ /*- - * Copyright (c) 2007, 2008, 2009, 2010 The NetBSD Foundation, Inc. + * Copyright (c) 2007, 2008, 2009, 2010, 2019 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation @@ -84,7 +84,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sys_select.c,v 1.48 2019/09/20 15:00:47 kamil Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sys_select.c,v 1.49 2019/11/21 21:42:30 ad Exp $"); #include #include @@ -104,6 +104,7 @@ __KERNEL_RCSID(0, "$NetBSD: sys_select.c #include #include #include +#include /* Flags for lwp::l_selflag. */ #define SEL_RESET 0 /* awoken, interrupted, or not yet polling */ @@ -111,10 +112,6 @@ __KERNEL_RCSID(0, "$NetBSD: sys_select.c #define SEL_BLOCKING 2 /* blocking and waiting for event */ #define SEL_EVENT 3 /* interrupted, events set directly */ -/* Operations: either select() or poll(). */ -#define SELOP_SELECT 1 -#define SELOP_POLL 2 - /* * Per-cluster state for select()/poll(). For a system with fewer * than 32 CPUs, this gives us per-CPU clusters. @@ -125,8 +122,8 @@ __KERNEL_RCSID(0, "$NetBSD: sys_select.c typedef struct selcluster { kmutex_t *sc_lock; sleepq_t sc_sleepq; + uint64_t sc_mask; int sc_ncoll; - uint32_t sc_mask; } selcluster_t; static inline int selscan(char *, const int, const size_t, register_t *); @@ -150,6 +147,10 @@ static syncobj_t select_sobj = { static selcluster_t *selcluster[SELCLUSTERS] __read_mostly; static int direct_select __read_mostly = 0; +/* Operations: either select() or poll(). */ +const char selop_select[] = "select"; +const char selop_poll[] = "poll"; + /* * Select system call. */ @@ -221,7 +222,7 @@ sys___select50(struct lwp *l, const stru * sel_do_scan: common code to perform the scan on descriptors. */ static int -sel_do_scan(const int op, void *fds, const int nf, const size_t ni, +sel_do_scan(const char *opname, void *fds, const int nf, const size_t ni, struct timespec *ts, sigset_t *mask, register_t *retval) { lwp_t * const l = curlwp; @@ -238,10 +239,17 @@ sel_do_scan(const int op, void *fds, con if (__predict_false(mask)) sigsuspendsetup(l, mask); + /* + * We may context switch during or at any time after picking a CPU + * and cluster to associate with, but it doesn't matter. In the + * unlikely event we migrate elsewhere all we risk is a little lock + * contention; correctness is not sacrificed. + */ sc = curcpu()->ci_data.cpu_selcluster; lock = sc->sc_lock; l->l_selcluster = sc; - if (op == SELOP_SELECT) { + + if (opname == selop_select) { l->l_selbits = fds; l->l_selni = ni; } else { @@ -261,10 +269,16 @@ sel_do_scan(const int op, void *fds, con * and lock activity resulting from fo_poll is enough to * provide an up to date value for new polling activity. */ - l->l_selflag = SEL_SCANNING; + if (ts && (ts->tv_sec | ts->tv_nsec | direct_select) == 0) { + /* Non-blocking: no need for selrecord()/selclear() */ + l->l_selflag = SEL_RESET; + } else { + l->l_selflag = SEL_SCANNING; + } ncoll = sc->sc_ncoll; + membar_exit(); - if (op == SELOP_SELECT) { + if (opname == selop_select) { error = selscan((char *)fds, nf, ni, retval); } else { error = pollscan((struct pollfd *)fds, nf, retval); @@ -301,7 +315,7 @@ state_check: l->l_selflag = SEL_BLOCKING; l->l_kpriority = true; sleepq_enter(>sc_sleepq, l, lock); - sleepq_enqueue(>sc_sleepq, sc, "select", _sobj); + sleepq_enqueue(>sc_sleepq, sc, opname, _sobj); error = sleepq_block(timo, true); if (error != 0) { break; @@ -363,7 +377,7 @@ selcommon(register_t *retval, int nd, fd getbits(ex, 2); #undef getbits -
CVS commit: src/sys
Module Name:src Committed By: ad Date: Thu Nov 21 21:42:31 UTC 2019 Modified Files: src/sys/kern: sys_select.c src/sys/sys: selinfo.h Log Message: Minor improvements to select/poll: - Increase the maximum number of clusters from 32 to 64 for large systems. kcpuset_t could potentially be used here but that's an excursion I don't want to go on right now. uint32_t -> uint64_t is very simple. - In the case of a non-blocking select/poll, or where we won't block because there are events ready to report, stop registering interest in the back-end objects early. - Change the wmesg for poll back to "poll". To generate a diff of this commit: cvs rdiff -u -r1.48 -r1.49 src/sys/kern/sys_select.c cvs rdiff -u -r1.8 -r1.9 src/sys/sys/selinfo.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/kern
Module Name:src Committed By: ad Date: Thu Nov 21 20:51:05 UTC 2019 Modified Files: src/sys/kern: kern_synch.c Log Message: - Don't give up kpriority boost in preempt(). That's unfair and bad for interactive response. It should only be dropped on final return to user. - Clear l_dopreempt with atomics and add some comments around concurrency. - Hold proc_lock over the lightning bolt and loadavg calc, no reason not to. - cpu_did_preempt() is useless - don't call it. Will remove soon. To generate a diff of this commit: cvs rdiff -u -r1.324 -r1.325 src/sys/kern/kern_synch.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/kern
Module Name:src Committed By: ad Date: Thu Nov 21 20:51:05 UTC 2019 Modified Files: src/sys/kern: kern_synch.c Log Message: - Don't give up kpriority boost in preempt(). That's unfair and bad for interactive response. It should only be dropped on final return to user. - Clear l_dopreempt with atomics and add some comments around concurrency. - Hold proc_lock over the lightning bolt and loadavg calc, no reason not to. - cpu_did_preempt() is useless - don't call it. Will remove soon. To generate a diff of this commit: cvs rdiff -u -r1.324 -r1.325 src/sys/kern/kern_synch.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/kern_synch.c diff -u src/sys/kern/kern_synch.c:1.324 src/sys/kern/kern_synch.c:1.325 --- src/sys/kern/kern_synch.c:1.324 Thu Oct 3 22:48:44 2019 +++ src/sys/kern/kern_synch.c Thu Nov 21 20:51:05 2019 @@ -1,7 +1,7 @@ -/* $NetBSD: kern_synch.c,v 1.324 2019/10/03 22:48:44 kamil Exp $ */ +/* $NetBSD: kern_synch.c,v 1.325 2019/11/21 20:51:05 ad Exp $ */ /*- - * Copyright (c) 1999, 2000, 2004, 2006, 2007, 2008, 2009 + * Copyright (c) 1999, 2000, 2004, 2006, 2007, 2008, 2009, 2019 *The NetBSD Foundation, Inc. * All rights reserved. * @@ -69,7 +69,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_synch.c,v 1.324 2019/10/03 22:48:44 kamil Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_synch.c,v 1.325 2019/11/21 20:51:05 ad Exp $"); #include "opt_kstack.h" #include "opt_dtrace.h" @@ -272,6 +272,7 @@ yield(void) lwp_lock(l); KASSERT(lwp_locked(l, l->l_cpu->ci_schedstate.spc_lwplock)); KASSERT(l->l_stat == LSONPROC); + /* Voluntary - ditch kpriority boost. */ l->l_kpriority = false; (void)mi_switch(l); KERNEL_LOCK(l->l_biglocks, l); @@ -290,7 +291,7 @@ preempt(void) lwp_lock(l); KASSERT(lwp_locked(l, l->l_cpu->ci_schedstate.spc_lwplock)); KASSERT(l->l_stat == LSONPROC); - l->l_kpriority = false; + /* Involuntary - keep kpriority boost. */ l->l_pflag |= LP_PREEMPTING; (void)mi_switch(l); KERNEL_LOCK(l->l_biglocks, l); @@ -324,12 +325,12 @@ kpreempt(uintptr_t where) * been blocked", since we're going to * context switch. */ - l->l_dopreempt = 0; + atomic_swap_uint(>l_dopreempt, 0); return true; } if (__predict_false((l->l_flag & LW_IDLE) != 0)) { /* Can't preempt idle loop, don't count as failure. */ - l->l_dopreempt = 0; + atomic_swap_uint(>l_dopreempt, 0); return true; } if (__predict_false(l->l_nopreempt != 0)) { @@ -342,7 +343,7 @@ kpreempt(uintptr_t where) } if (__predict_false((l->l_pflag & LP_INTR) != 0)) { /* Can't preempt soft interrupts yet. */ - l->l_dopreempt = 0; + atomic_swap_uint(>l_dopreempt, 0); failed = (uintptr_t)_softint; break; } @@ -484,8 +485,11 @@ nextlwp(struct cpu_info *ci, struct sche } /* - * Only clear want_resched if there are no pending (slow) - * software interrupts. + * Only clear want_resched if there are no pending (slow) software + * interrupts. We can do this without an atomic, because no new + * LWPs can appear in the queue due to our hold on spc_mutex, and + * the update to ci_want_resched will become globally visible before + * the release of spc_mutex becomes globally visible. */ ci->ci_want_resched = ci->ci_data.cpu_softints; spc->spc_flags &= ~SPCF_SWITCHCLEAR; @@ -606,10 +610,11 @@ mi_switch(lwp_t *l) } /* - * Preemption related tasks. Must be done with the current - * CPU locked. + * Preemption related tasks. Must be done holding spc_mutex. Clear + * l_dopreempt without an atomic - it's only ever set non-zero by + * sched_resched_cpu() which also holds spc_mutex, and only ever + * cleared by the LWP itself (us) with atomics when not under lock. */ - cpu_did_resched(l); l->l_dopreempt = 0; if (__predict_false(l->l_pfailaddr != 0)) { LOCKSTAT_FLAG(lsflag); @@ -830,12 +835,6 @@ lwp_exit_switchaway(lwp_t *l) */ ci->ci_data.cpu_onproc = newl; - /* - * Preemption related tasks. Must be done with the current - * CPU locked. - */ - cpu_did_resched(l); - /* Unlock the run queue. */ spc_unlock(ci); @@ -1215,7 +1214,6 @@ sched_pstats(void) psignal(p, sig); } } - mutex_exit(proc_lock); /* Load average calculation. */ if (__predict_false(lavg_count == 0)) { @@ -1229,4 +1227,6 @@ sched_pstats(void) /* Lightning bolt. */ cv_broadcast(); + + mutex_exit(proc_lock); }
CVS commit: src/sys/arch
Module Name:src Committed By: ad Date: Thu Nov 21 19:57:24 UTC 2019 Modified Files: src/sys/arch/aarch64/aarch64: cpu_machdep.c src/sys/arch/mips/mips: cpu_subr.c src/sys/arch/powerpc/powerpc: powerpc_machdep.c src/sys/arch/riscv/riscv: riscv_machdep.c src/sys/arch/x86/include: cpu.h Log Message: mi_userret(): take care of calling preempt(), set spc_curpriority directly, and remove MD code that does the same. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/arch/aarch64/aarch64/cpu_machdep.c cvs rdiff -u -r1.34 -r1.35 src/sys/arch/mips/mips/cpu_subr.c cvs rdiff -u -r1.72 -r1.73 src/sys/arch/powerpc/powerpc/powerpc_machdep.c cvs rdiff -u -r1.4 -r1.5 src/sys/arch/riscv/riscv/riscv_machdep.c cvs rdiff -u -r1.110 -r1.111 src/sys/arch/x86/include/cpu.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch
Module Name:src Committed By: ad Date: Thu Nov 21 19:57:24 UTC 2019 Modified Files: src/sys/arch/aarch64/aarch64: cpu_machdep.c src/sys/arch/mips/mips: cpu_subr.c src/sys/arch/powerpc/powerpc: powerpc_machdep.c src/sys/arch/riscv/riscv: riscv_machdep.c src/sys/arch/x86/include: cpu.h Log Message: mi_userret(): take care of calling preempt(), set spc_curpriority directly, and remove MD code that does the same. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/arch/aarch64/aarch64/cpu_machdep.c cvs rdiff -u -r1.34 -r1.35 src/sys/arch/mips/mips/cpu_subr.c cvs rdiff -u -r1.72 -r1.73 src/sys/arch/powerpc/powerpc/powerpc_machdep.c cvs rdiff -u -r1.4 -r1.5 src/sys/arch/riscv/riscv/riscv_machdep.c cvs rdiff -u -r1.110 -r1.111 src/sys/arch/x86/include/cpu.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/aarch64/aarch64/cpu_machdep.c diff -u src/sys/arch/aarch64/aarch64/cpu_machdep.c:1.6 src/sys/arch/aarch64/aarch64/cpu_machdep.c:1.7 --- src/sys/arch/aarch64/aarch64/cpu_machdep.c:1.6 Fri Aug 3 17:04:30 2018 +++ src/sys/arch/aarch64/aarch64/cpu_machdep.c Thu Nov 21 19:57:23 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu_machdep.c,v 1.6 2018/08/03 17:04:30 ryo Exp $ */ +/* $NetBSD: cpu_machdep.c,v 1.7 2019/11/21 19:57:23 ad Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include -__KERNEL_RCSID(1, "$NetBSD: cpu_machdep.c,v 1.6 2018/08/03 17:04:30 ryo Exp $"); +__KERNEL_RCSID(1, "$NetBSD: cpu_machdep.c,v 1.7 2019/11/21 19:57:23 ad Exp $"); #include "opt_multiprocessor.h" @@ -299,15 +299,6 @@ cpu_need_proftick(struct lwp *l) setsoftast(l->l_cpu); } -void -cpu_set_curpri(int pri) -{ - kpreempt_disable(); - curcpu()->ci_schedstate.spc_curpriority = pri; - kpreempt_enable(); -} - - #ifdef __HAVE_PREEMPTION bool cpu_kpreempt_enter(uintptr_t where, int s) Index: src/sys/arch/mips/mips/cpu_subr.c diff -u src/sys/arch/mips/mips/cpu_subr.c:1.34 src/sys/arch/mips/mips/cpu_subr.c:1.35 --- src/sys/arch/mips/mips/cpu_subr.c:1.34 Mon Jan 21 08:04:26 2019 +++ src/sys/arch/mips/mips/cpu_subr.c Thu Nov 21 19:57:23 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu_subr.c,v 1.34 2019/01/21 08:04:26 skrll Exp $ */ +/* $NetBSD: cpu_subr.c,v 1.35 2019/11/21 19:57:23 ad Exp $ */ /*- * Copyright (c) 2010 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: cpu_subr.c,v 1.34 2019/01/21 08:04:26 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cpu_subr.c,v 1.35 2019/11/21 19:57:23 ad Exp $"); #include "opt_cputype.h" #include "opt_ddb.h" @@ -567,15 +567,6 @@ cpu_need_proftick(struct lwp *l) l->l_md.md_astpending = 1; /* force call to ast() */ } -void -cpu_set_curpri(int pri) -{ - kpreempt_disable(); - curcpu()->ci_schedstate.spc_curpriority = pri; - kpreempt_enable(); -} - - #ifdef __HAVE_PREEMPTION bool cpu_kpreempt_enter(uintptr_t where, int s) Index: src/sys/arch/powerpc/powerpc/powerpc_machdep.c diff -u src/sys/arch/powerpc/powerpc/powerpc_machdep.c:1.72 src/sys/arch/powerpc/powerpc/powerpc_machdep.c:1.73 --- src/sys/arch/powerpc/powerpc/powerpc_machdep.c:1.72 Sun Sep 16 09:25:47 2018 +++ src/sys/arch/powerpc/powerpc/powerpc_machdep.c Thu Nov 21 19:57:24 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: powerpc_machdep.c,v 1.72 2018/09/16 09:25:47 skrll Exp $ */ +/* $NetBSD: powerpc_machdep.c,v 1.73 2019/11/21 19:57:24 ad Exp $ */ /* * Copyright (C) 1995, 1996 Wolfgang Solfrank. @@ -32,7 +32,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: powerpc_machdep.c,v 1.72 2018/09/16 09:25:47 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: powerpc_machdep.c,v 1.73 2019/11/21 19:57:24 ad Exp $"); #include "opt_altivec.h" #include "opt_ddb.h" @@ -378,11 +378,6 @@ cpu_ast(struct lwp *l, struct cpu_info * l->l_pflag &= ~LP_OWEUPC; ADDUPROF(l); } - - /* Check whether we are being preempted. */ - if (ci->ci_want_resched) { - preempt(); - } } void Index: src/sys/arch/riscv/riscv/riscv_machdep.c diff -u src/sys/arch/riscv/riscv/riscv_machdep.c:1.4 src/sys/arch/riscv/riscv/riscv_machdep.c:1.5 --- src/sys/arch/riscv/riscv/riscv_machdep.c:1.4 Sat Apr 6 11:54:20 2019 +++ src/sys/arch/riscv/riscv/riscv_machdep.c Thu Nov 21 19:57:24 2019 @@ -31,7 +31,7 @@ #include "opt_modular.h" -__RCSID("$NetBSD: riscv_machdep.c,v 1.4 2019/04/06 11:54:20 kamil Exp $"); +__RCSID("$NetBSD: riscv_machdep.c,v 1.5 2019/11/21 19:57:24 ad Exp $"); #include #include @@ -324,14 +324,6 @@ cpu_need_proftick(struct lwp *l) } void -cpu_set_curpri(int pri) -{ - kpreempt_disable(); - curcpu()->ci_schedstate.spc_curpriority = pri; - kpreempt_enable(); -} - -void cpu_reboot(int how, char *bootstr) { for (;;) { Index: src/sys/arch/x86/include/cpu.h diff -u src/sys/arch/x86/include/cpu.h:1.110 src/sys/arch/x86/include/cpu.h:1.111 --- src/sys/arch/x86/include/cpu.h:1.110 Sat Oct 12 06:31:03 2019 +++
CVS commit: src/sys
Module Name:src Committed By: ad Date: Thu Nov 21 19:47:21 UTC 2019 Modified Files: src/sys/kern: kern_lwp.c src/sys/sys: lwp.h Log Message: lwp_setlock(): return pointer to the kmutex_t that we replaced To generate a diff of this commit: cvs rdiff -u -r1.210 -r1.211 src/sys/kern/kern_lwp.c cvs rdiff -u -r1.188 -r1.189 src/sys/sys/lwp.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/kern_lwp.c diff -u src/sys/kern/kern_lwp.c:1.210 src/sys/kern/kern_lwp.c:1.211 --- src/sys/kern/kern_lwp.c:1.210 Thu Nov 21 18:22:05 2019 +++ src/sys/kern/kern_lwp.c Thu Nov 21 19:47:21 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_lwp.c,v 1.210 2019/11/21 18:22:05 ad Exp $ */ +/* $NetBSD: kern_lwp.c,v 1.211 2019/11/21 19:47:21 ad Exp $ */ /*- * Copyright (c) 2001, 2006, 2007, 2008, 2009, 2019 The NetBSD Foundation, Inc. @@ -211,7 +211,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_lwp.c,v 1.210 2019/11/21 18:22:05 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_lwp.c,v 1.211 2019/11/21 19:47:21 ad Exp $"); #include "opt_ddb.h" #include "opt_lockdebug.h" @@ -1475,14 +1475,16 @@ lwp_locked(struct lwp *l, kmutex_t *mtx) /* * Lend a new mutex to an LWP. The old mutex must be held. */ -void +kmutex_t * lwp_setlock(struct lwp *l, kmutex_t *mtx) { + kmutex_t *oldmtx = l->l_mutex; - KASSERT(mutex_owned(l->l_mutex)); + KASSERT(mutex_owned(oldmtx)); membar_exit(); l->l_mutex = mtx; + return oldmtx; } /* @@ -1517,11 +1519,11 @@ lwp_trylock(struct lwp *l) } void -lwp_unsleep(lwp_t *l, bool cleanup) +lwp_unsleep(lwp_t *l, bool unlock) { KASSERT(mutex_owned(l->l_mutex)); - (*l->l_syncobj->sobj_unsleep)(l, cleanup); + (*l->l_syncobj->sobj_unsleep)(l, unlock); } /* Index: src/sys/sys/lwp.h diff -u src/sys/sys/lwp.h:1.188 src/sys/sys/lwp.h:1.189 --- src/sys/sys/lwp.h:1.188 Thu Nov 14 16:23:53 2019 +++ src/sys/sys/lwp.h Thu Nov 21 19:47:21 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: lwp.h,v 1.188 2019/11/14 16:23:53 maxv Exp $ */ +/* $NetBSD: lwp.h,v 1.189 2019/11/21 19:47:21 ad Exp $ */ /* * Copyright (c) 2001, 2006, 2007, 2008, 2009, 2010 @@ -326,7 +326,7 @@ void lwp_startup(lwp_t *, lwp_t *); void startlwp(void *); int lwp_locked(lwp_t *, kmutex_t *); -void lwp_setlock(lwp_t *, kmutex_t *); +kmutex_t *lwp_setlock(lwp_t *, kmutex_t *); void lwp_unlock_to(lwp_t *, kmutex_t *); int lwp_trylock(lwp_t *); void lwp_addref(lwp_t *);
CVS commit: src/sys
Module Name:src Committed By: ad Date: Thu Nov 21 19:47:21 UTC 2019 Modified Files: src/sys/kern: kern_lwp.c src/sys/sys: lwp.h Log Message: lwp_setlock(): return pointer to the kmutex_t that we replaced To generate a diff of this commit: cvs rdiff -u -r1.210 -r1.211 src/sys/kern/kern_lwp.c cvs rdiff -u -r1.188 -r1.189 src/sys/sys/lwp.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch
Module Name:src Committed By: ad Date: Thu Nov 21 19:27:54 UTC 2019 Modified Files: src/sys/arch/amd64/amd64: genassym.cf locore.S src/sys/arch/i386/i386: genassym.cf locore.S Log Message: x86: abort pageidlezero unconditionally if there is something to run. To generate a diff of this commit: cvs rdiff -u -r1.77 -r1.78 src/sys/arch/amd64/amd64/genassym.cf cvs rdiff -u -r1.190 -r1.191 src/sys/arch/amd64/amd64/locore.S cvs rdiff -u -r1.114 -r1.115 src/sys/arch/i386/i386/genassym.cf cvs rdiff -u -r1.173 -r1.174 src/sys/arch/i386/i386/locore.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/amd64/amd64/genassym.cf diff -u src/sys/arch/amd64/amd64/genassym.cf:1.77 src/sys/arch/amd64/amd64/genassym.cf:1.78 --- src/sys/arch/amd64/amd64/genassym.cf:1.77 Sat Oct 12 06:31:03 2019 +++ src/sys/arch/amd64/amd64/genassym.cf Thu Nov 21 19:27:54 2019 @@ -1,4 +1,4 @@ -# $NetBSD: genassym.cf,v 1.77 2019/10/12 06:31:03 maxv Exp $ +# $NetBSD: genassym.cf,v 1.78 2019/11/21 19:27:54 ad Exp $ # # Copyright (c) 1998, 2006, 2007, 2008 The NetBSD Foundation, Inc. @@ -385,6 +385,4 @@ define PGSHIFT PGSHIFT define VM_SPACE_SEP_HIGH32 (0x8000 >> 32) -define RESCHED_KPREEMPT RESCHED_KPREEMPT - define SEL_RPL_MASK SEL_RPL Index: src/sys/arch/amd64/amd64/locore.S diff -u src/sys/arch/amd64/amd64/locore.S:1.190 src/sys/arch/amd64/amd64/locore.S:1.191 --- src/sys/arch/amd64/amd64/locore.S:1.190 Thu Nov 14 16:23:52 2019 +++ src/sys/arch/amd64/amd64/locore.S Thu Nov 21 19:27:54 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: locore.S,v 1.190 2019/11/14 16:23:52 maxv Exp $ */ +/* $NetBSD: locore.S,v 1.191 2019/11/21 19:27:54 ad Exp $ */ /* * Copyright-o-rama! @@ -1491,7 +1491,7 @@ ENTRY(sse2_idlezero_page) xorq %rax, %rax .align 16 1: - testl $RESCHED_KPREEMPT, CPUVAR(RESCHED) + cmpl $0, CPUVAR(RESCHED) jnz 2f movnti %rax, 0(%rdi) movnti %rax, 8(%rdi) Index: src/sys/arch/i386/i386/genassym.cf diff -u src/sys/arch/i386/i386/genassym.cf:1.114 src/sys/arch/i386/i386/genassym.cf:1.115 --- src/sys/arch/i386/i386/genassym.cf:1.114 Sat Oct 12 06:31:03 2019 +++ src/sys/arch/i386/i386/genassym.cf Thu Nov 21 19:27:54 2019 @@ -1,4 +1,4 @@ -# $NetBSD: genassym.cf,v 1.114 2019/10/12 06:31:03 maxv Exp $ +# $NetBSD: genassym.cf,v 1.115 2019/11/21 19:27:54 ad Exp $ # # Copyright (c) 1998, 2006, 2007, 2008 The NetBSD Foundation, Inc. @@ -376,8 +376,6 @@ define L2_FRAME L2_FRAME define PGOFSET PGOFSET define PGSHIFT PGSHIFT -define RESCHED_KPREEMPT RESCHED_KPREEMPT - ifdef XEN define CPU_INFO_VCPU offsetof(struct cpu_info, ci_vcpu) define CPU_INFO_XPENDING offsetof(struct cpu_info, ci_xpending) Index: src/sys/arch/i386/i386/locore.S diff -u src/sys/arch/i386/i386/locore.S:1.173 src/sys/arch/i386/i386/locore.S:1.174 --- src/sys/arch/i386/i386/locore.S:1.173 Fri Oct 18 01:38:28 2019 +++ src/sys/arch/i386/i386/locore.S Thu Nov 21 19:27:54 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: locore.S,v 1.173 2019/10/18 01:38:28 manu Exp $ */ +/* $NetBSD: locore.S,v 1.174 2019/11/21 19:27:54 ad Exp $ */ /* * Copyright-o-rama! @@ -128,7 +128,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.173 2019/10/18 01:38:28 manu Exp $"); +__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.174 2019/11/21 19:27:54 ad Exp $"); #include "opt_copy_symtab.h" #include "opt_ddb.h" @@ -1590,7 +1590,7 @@ ENTRY(sse2_idlezero_page) xorl %eax, %eax .align 16 1: - testl $RESCHED_KPREEMPT, CPUVAR(RESCHED) + cmpl $0, CPUVAR(RESCHED) jnz 2f movnti %eax, 0(%edx) movnti %eax, 4(%edx)
CVS commit: src/sys/arch
Module Name:src Committed By: ad Date: Thu Nov 21 19:27:54 UTC 2019 Modified Files: src/sys/arch/amd64/amd64: genassym.cf locore.S src/sys/arch/i386/i386: genassym.cf locore.S Log Message: x86: abort pageidlezero unconditionally if there is something to run. To generate a diff of this commit: cvs rdiff -u -r1.77 -r1.78 src/sys/arch/amd64/amd64/genassym.cf cvs rdiff -u -r1.190 -r1.191 src/sys/arch/amd64/amd64/locore.S cvs rdiff -u -r1.114 -r1.115 src/sys/arch/i386/i386/genassym.cf cvs rdiff -u -r1.173 -r1.174 src/sys/arch/i386/i386/locore.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys
Module Name:src Committed By: ad Date: Thu Nov 21 19:24:02 UTC 2019 Modified Files: src/sys/arch/aarch64/aarch64: trap.c src/sys/arch/aarch64/include: cpu.h src/sys/arch/alpha/alpha: trap.c src/sys/arch/amd64/amd64: cpufunc.S trap.c src/sys/arch/amd64/include: cpu.h src/sys/arch/amiga/amiga: trap.c src/sys/arch/arm/arm: ast.c src/sys/arch/arm/include: cpu.h src/sys/arch/atari/atari: trap.c src/sys/arch/cesfic/cesfic: trap.c src/sys/arch/hp300/hp300: trap.c src/sys/arch/hppa/hppa: trap.c src/sys/arch/i386/i386: cpufunc.S trap.c src/sys/arch/i386/include: cpu.h src/sys/arch/luna68k/luna68k: trap.c src/sys/arch/mac68k/mac68k: trap.c src/sys/arch/mips/include: cpu.h src/sys/arch/mvme68k/mvme68k: trap.c src/sys/arch/news68k/news68k: trap.c src/sys/arch/next68k/next68k: trap.c src/sys/arch/or1k/include: cpu.h src/sys/arch/riscv/include: cpu.h src/sys/arch/riscv/riscv: trap.c src/sys/arch/sh3/sh3: exception.c src/sys/arch/sparc/include: userret.h src/sys/arch/sparc64/sparc64: trap.c src/sys/arch/sun2/sun2: trap.c src/sys/arch/sun3/sun3: trap.c src/sys/arch/usermode/usermode: trap.c src/sys/arch/vax/vax: trap.c src/sys/arch/x68k/x68k: trap.c src/sys/sys: userret.h Log Message: mi_userret(): take care of calling preempt(), set spc_curpriority directly, and remove MD code that does the same. To generate a diff of this commit: cvs rdiff -u -r1.19 -r1.20 src/sys/arch/aarch64/aarch64/trap.c cvs rdiff -u -r1.14 -r1.15 src/sys/arch/aarch64/include/cpu.h cvs rdiff -u -r1.134 -r1.135 src/sys/arch/alpha/alpha/trap.c cvs rdiff -u -r1.48 -r1.49 src/sys/arch/amd64/amd64/cpufunc.S cvs rdiff -u -r1.124 -r1.125 src/sys/arch/amd64/amd64/trap.c cvs rdiff -u -r1.65 -r1.66 src/sys/arch/amd64/include/cpu.h cvs rdiff -u -r1.137 -r1.138 src/sys/arch/amiga/amiga/trap.c cvs rdiff -u -r1.30 -r1.31 src/sys/arch/arm/arm/ast.c cvs rdiff -u -r1.101 -r1.102 src/sys/arch/arm/include/cpu.h cvs rdiff -u -r1.115 -r1.116 src/sys/arch/atari/atari/trap.c cvs rdiff -u -r1.59 -r1.60 src/sys/arch/cesfic/cesfic/trap.c cvs rdiff -u -r1.153 -r1.154 src/sys/arch/hp300/hp300/trap.c cvs rdiff -u -r1.111 -r1.112 src/sys/arch/hppa/hppa/trap.c cvs rdiff -u -r1.37 -r1.38 src/sys/arch/i386/i386/cpufunc.S cvs rdiff -u -r1.302 -r1.303 src/sys/arch/i386/i386/trap.c cvs rdiff -u -r1.181 -r1.182 src/sys/arch/i386/include/cpu.h cvs rdiff -u -r1.71 -r1.72 src/sys/arch/luna68k/luna68k/trap.c cvs rdiff -u -r1.149 -r1.150 src/sys/arch/mac68k/mac68k/trap.c cvs rdiff -u -r1.126 -r1.127 src/sys/arch/mips/include/cpu.h cvs rdiff -u -r1.110 -r1.111 src/sys/arch/mvme68k/mvme68k/trap.c cvs rdiff -u -r1.71 -r1.72 src/sys/arch/news68k/news68k/trap.c cvs rdiff -u -r1.90 -r1.91 src/sys/arch/next68k/next68k/trap.c cvs rdiff -u -r1.2 -r1.3 src/sys/arch/or1k/include/cpu.h cvs rdiff -u -r1.5 -r1.6 src/sys/arch/riscv/include/cpu.h cvs rdiff -u -r1.3 -r1.4 src/sys/arch/riscv/riscv/trap.c cvs rdiff -u -r1.67 -r1.68 src/sys/arch/sh3/sh3/exception.c cvs rdiff -u -r1.8 -r1.9 src/sys/arch/sparc/include/userret.h cvs rdiff -u -r1.191 -r1.192 src/sys/arch/sparc64/sparc64/trap.c cvs rdiff -u -r1.45 -r1.46 src/sys/arch/sun2/sun2/trap.c cvs rdiff -u -r1.145 -r1.146 src/sys/arch/sun3/sun3/trap.c cvs rdiff -u -r1.70 -r1.71 src/sys/arch/usermode/usermode/trap.c cvs rdiff -u -r1.135 -r1.136 src/sys/arch/vax/vax/trap.c cvs rdiff -u -r1.108 -r1.109 src/sys/arch/x68k/x68k/trap.c cvs rdiff -u -r1.28 -r1.29 src/sys/sys/userret.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys
Module Name:src Committed By: ad Date: Thu Nov 21 19:24:02 UTC 2019 Modified Files: src/sys/arch/aarch64/aarch64: trap.c src/sys/arch/aarch64/include: cpu.h src/sys/arch/alpha/alpha: trap.c src/sys/arch/amd64/amd64: cpufunc.S trap.c src/sys/arch/amd64/include: cpu.h src/sys/arch/amiga/amiga: trap.c src/sys/arch/arm/arm: ast.c src/sys/arch/arm/include: cpu.h src/sys/arch/atari/atari: trap.c src/sys/arch/cesfic/cesfic: trap.c src/sys/arch/hp300/hp300: trap.c src/sys/arch/hppa/hppa: trap.c src/sys/arch/i386/i386: cpufunc.S trap.c src/sys/arch/i386/include: cpu.h src/sys/arch/luna68k/luna68k: trap.c src/sys/arch/mac68k/mac68k: trap.c src/sys/arch/mips/include: cpu.h src/sys/arch/mvme68k/mvme68k: trap.c src/sys/arch/news68k/news68k: trap.c src/sys/arch/next68k/next68k: trap.c src/sys/arch/or1k/include: cpu.h src/sys/arch/riscv/include: cpu.h src/sys/arch/riscv/riscv: trap.c src/sys/arch/sh3/sh3: exception.c src/sys/arch/sparc/include: userret.h src/sys/arch/sparc64/sparc64: trap.c src/sys/arch/sun2/sun2: trap.c src/sys/arch/sun3/sun3: trap.c src/sys/arch/usermode/usermode: trap.c src/sys/arch/vax/vax: trap.c src/sys/arch/x68k/x68k: trap.c src/sys/sys: userret.h Log Message: mi_userret(): take care of calling preempt(), set spc_curpriority directly, and remove MD code that does the same. To generate a diff of this commit: cvs rdiff -u -r1.19 -r1.20 src/sys/arch/aarch64/aarch64/trap.c cvs rdiff -u -r1.14 -r1.15 src/sys/arch/aarch64/include/cpu.h cvs rdiff -u -r1.134 -r1.135 src/sys/arch/alpha/alpha/trap.c cvs rdiff -u -r1.48 -r1.49 src/sys/arch/amd64/amd64/cpufunc.S cvs rdiff -u -r1.124 -r1.125 src/sys/arch/amd64/amd64/trap.c cvs rdiff -u -r1.65 -r1.66 src/sys/arch/amd64/include/cpu.h cvs rdiff -u -r1.137 -r1.138 src/sys/arch/amiga/amiga/trap.c cvs rdiff -u -r1.30 -r1.31 src/sys/arch/arm/arm/ast.c cvs rdiff -u -r1.101 -r1.102 src/sys/arch/arm/include/cpu.h cvs rdiff -u -r1.115 -r1.116 src/sys/arch/atari/atari/trap.c cvs rdiff -u -r1.59 -r1.60 src/sys/arch/cesfic/cesfic/trap.c cvs rdiff -u -r1.153 -r1.154 src/sys/arch/hp300/hp300/trap.c cvs rdiff -u -r1.111 -r1.112 src/sys/arch/hppa/hppa/trap.c cvs rdiff -u -r1.37 -r1.38 src/sys/arch/i386/i386/cpufunc.S cvs rdiff -u -r1.302 -r1.303 src/sys/arch/i386/i386/trap.c cvs rdiff -u -r1.181 -r1.182 src/sys/arch/i386/include/cpu.h cvs rdiff -u -r1.71 -r1.72 src/sys/arch/luna68k/luna68k/trap.c cvs rdiff -u -r1.149 -r1.150 src/sys/arch/mac68k/mac68k/trap.c cvs rdiff -u -r1.126 -r1.127 src/sys/arch/mips/include/cpu.h cvs rdiff -u -r1.110 -r1.111 src/sys/arch/mvme68k/mvme68k/trap.c cvs rdiff -u -r1.71 -r1.72 src/sys/arch/news68k/news68k/trap.c cvs rdiff -u -r1.90 -r1.91 src/sys/arch/next68k/next68k/trap.c cvs rdiff -u -r1.2 -r1.3 src/sys/arch/or1k/include/cpu.h cvs rdiff -u -r1.5 -r1.6 src/sys/arch/riscv/include/cpu.h cvs rdiff -u -r1.3 -r1.4 src/sys/arch/riscv/riscv/trap.c cvs rdiff -u -r1.67 -r1.68 src/sys/arch/sh3/sh3/exception.c cvs rdiff -u -r1.8 -r1.9 src/sys/arch/sparc/include/userret.h cvs rdiff -u -r1.191 -r1.192 src/sys/arch/sparc64/sparc64/trap.c cvs rdiff -u -r1.45 -r1.46 src/sys/arch/sun2/sun2/trap.c cvs rdiff -u -r1.145 -r1.146 src/sys/arch/sun3/sun3/trap.c cvs rdiff -u -r1.70 -r1.71 src/sys/arch/usermode/usermode/trap.c cvs rdiff -u -r1.135 -r1.136 src/sys/arch/vax/vax/trap.c cvs rdiff -u -r1.108 -r1.109 src/sys/arch/x68k/x68k/trap.c cvs rdiff -u -r1.28 -r1.29 src/sys/sys/userret.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/aarch64/aarch64/trap.c diff -u src/sys/arch/aarch64/aarch64/trap.c:1.19 src/sys/arch/aarch64/aarch64/trap.c:1.20 --- src/sys/arch/aarch64/aarch64/trap.c:1.19 Sat Sep 28 07:06:50 2019 +++ src/sys/arch/aarch64/aarch64/trap.c Thu Nov 21 19:23:58 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: trap.c,v 1.19 2019/09/28 07:06:50 skrll Exp $ */ +/* $NetBSD: trap.c,v 1.20 2019/11/21 19:23:58 ad Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include -__KERNEL_RCSID(1, "$NetBSD: trap.c,v 1.19 2019/09/28 07:06:50 skrll Exp $"); +__KERNEL_RCSID(1, "$NetBSD: trap.c,v 1.20 2019/11/21 19:23:58 ad Exp $"); #include "opt_arm_intr_impl.h" #include "opt_compat_netbsd32.h" @@ -158,7 +158,6 @@ trap_doast(struct trapframe *tf) ci->ci_data.cpu_ntrap++; KDASSERT(ci->ci_cpl == IPL_NONE); - const int want_resched = ci->ci_want_resched; #ifdef __HAVE_PREEMPTION kpreempt_enable(); #endif @@ -168,9 +167,6 @@ trap_doast(struct trapframe *tf) ADDUPROF(l); } - /* Allow a forced task switch. */ - if (want_resched) - preempt(); userret(l); } Index: src/sys/arch/aarch64/include/cpu.h diff -u src/sys/arch/aarch64/include/cpu.h:1.14
CVS commit: src/sys/arch/alpha/alpha
Module Name:src Committed By: ad Date: Thu Nov 21 19:02:43 UTC 2019 Modified Files: src/sys/arch/alpha/alpha: ipifuncs.c Log Message: alpha_ipi_ast: use ci_data.cpu_onproc, not ci_curlwp. To generate a diff of this commit: cvs rdiff -u -r1.48 -r1.49 src/sys/arch/alpha/alpha/ipifuncs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/alpha/alpha/ipifuncs.c diff -u src/sys/arch/alpha/alpha/ipifuncs.c:1.48 src/sys/arch/alpha/alpha/ipifuncs.c:1.49 --- src/sys/arch/alpha/alpha/ipifuncs.c:1.48 Mon May 19 22:47:53 2014 +++ src/sys/arch/alpha/alpha/ipifuncs.c Thu Nov 21 19:02:43 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: ipifuncs.c,v 1.48 2014/05/19 22:47:53 rmind Exp $ */ +/* $NetBSD: ipifuncs.c,v 1.49 2019/11/21 19:02:43 ad Exp $ */ /*- * Copyright (c) 1998, 1999, 2000, 2001 The NetBSD Foundation, Inc. @@ -32,7 +32,7 @@ #include /* RCS ID & Copyright macro defns */ -__KERNEL_RCSID(0, "$NetBSD: ipifuncs.c,v 1.48 2014/05/19 22:47:53 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ipifuncs.c,v 1.49 2019/11/21 19:02:43 ad Exp $"); /* * Interprocessor interrupt handlers. @@ -263,8 +263,8 @@ static void alpha_ipi_ast(struct cpu_info *ci, struct trapframe *framep) { - if (ci->ci_curlwp != ci->ci_data.cpu_idlelwp) - aston(ci->ci_curlwp); + if (ci->ci_data.cpu_onproc != ci->ci_data.cpu_idlelwp) + aston(ci->ci_data.cpu_onproc); } static void
CVS commit: src/sys/arch/alpha/alpha
Module Name:src Committed By: ad Date: Thu Nov 21 19:02:43 UTC 2019 Modified Files: src/sys/arch/alpha/alpha: ipifuncs.c Log Message: alpha_ipi_ast: use ci_data.cpu_onproc, not ci_curlwp. To generate a diff of this commit: cvs rdiff -u -r1.48 -r1.49 src/sys/arch/alpha/alpha/ipifuncs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys
Module Name:src Committed By: ad Date: Thu Nov 21 18:56:55 UTC 2019 Modified Files: src/sys/kern: kern_sleepq.c kern_turnstile.c src/sys/sys: sleepq.h Log Message: Sleep queues & turnstiles: - Avoid false sharing. - Make the turnstile hash function more suitable. - Increase turnstile hash table size. - Make amends by having only one set of system wide sleep queue hash locks. To generate a diff of this commit: cvs rdiff -u -r1.51 -r1.52 src/sys/kern/kern_sleepq.c cvs rdiff -u -r1.32 -r1.33 src/sys/kern/kern_turnstile.c cvs rdiff -u -r1.25 -r1.26 src/sys/sys/sleepq.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys
Module Name:src Committed By: ad Date: Thu Nov 21 18:56:55 UTC 2019 Modified Files: src/sys/kern: kern_sleepq.c kern_turnstile.c src/sys/sys: sleepq.h Log Message: Sleep queues & turnstiles: - Avoid false sharing. - Make the turnstile hash function more suitable. - Increase turnstile hash table size. - Make amends by having only one set of system wide sleep queue hash locks. To generate a diff of this commit: cvs rdiff -u -r1.51 -r1.52 src/sys/kern/kern_sleepq.c cvs rdiff -u -r1.32 -r1.33 src/sys/kern/kern_turnstile.c cvs rdiff -u -r1.25 -r1.26 src/sys/sys/sleepq.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/kern_sleepq.c diff -u src/sys/kern/kern_sleepq.c:1.51 src/sys/kern/kern_sleepq.c:1.52 --- src/sys/kern/kern_sleepq.c:1.51 Sun Jul 3 14:24:58 2016 +++ src/sys/kern/kern_sleepq.c Thu Nov 21 18:56:55 2019 @@ -1,7 +1,7 @@ -/* $NetBSD: kern_sleepq.c,v 1.51 2016/07/03 14:24:58 christos Exp $ */ +/* $NetBSD: kern_sleepq.c,v 1.52 2019/11/21 18:56:55 ad Exp $ */ /*- - * Copyright (c) 2006, 2007, 2008, 2009 The NetBSD Foundation, Inc. + * Copyright (c) 2006, 2007, 2008, 2009, 2019 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_sleepq.c,v 1.51 2016/07/03 14:24:58 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_sleepq.c,v 1.52 2019/11/21 18:56:55 ad Exp $"); #include #include @@ -65,7 +65,8 @@ __KERNEL_RCSID(0, "$NetBSD: kern_sleepq. static int sleepq_sigtoerror(lwp_t *, int); /* General purpose sleep table, used by mtsleep() and condition variables. */ -sleeptab_t sleeptab __cacheline_aligned; +sleeptab_t sleeptab __cacheline_aligned; +kmutex_t *sleepq_locks[SLEEPTAB_HASH_SIZE] __read_mostly; /* * sleeptab_init: @@ -75,14 +76,11 @@ sleeptab_t sleeptab __cacheline_aligned; void sleeptab_init(sleeptab_t *st) { - sleepq_t *sq; int i; for (i = 0; i < SLEEPTAB_HASH_SIZE; i++) { - sq = >st_queues[i].st_queue; - st->st_queues[i].st_mutex = - mutex_obj_alloc(MUTEX_DEFAULT, IPL_SCHED); - sleepq_init(sq); + sleepq_locks[i] = mutex_obj_alloc(MUTEX_DEFAULT, IPL_SCHED); + sleepq_init(>st_queue[i]); } } @@ -266,8 +264,12 @@ sleepq_block(int timo, bool catch_p) /* The LWP and sleep queue are now unlocked. */ if (timo) { /* - * Even if the callout appears to have fired, we need to - * stop it in order to synchronise with other CPUs. + * Even if the callout appears to have fired, we + * need to stop it in order to synchronise with + * other CPUs. It's important that we do this in + * this LWP's context, and not during wakeup, in + * order to keep the callout & its cache lines + * co-located on the CPU with the LWP. */ if (callout_halt(>l_timeout_ch, NULL)) error = EWOULDBLOCK; @@ -333,10 +335,10 @@ sleepq_wake(sleepq_t *sq, wchan_t wchan, * * Remove an LWP from its sleep queue and set it runnable again. * sleepq_unsleep() is called with the LWP's mutex held, and will - * always release it. + * release it if "unlock" is true. */ void -sleepq_unsleep(lwp_t *l, bool cleanup) +sleepq_unsleep(lwp_t *l, bool unlock) { sleepq_t *sq = l->l_sleepq; kmutex_t *mp = l->l_mutex; @@ -345,7 +347,7 @@ sleepq_unsleep(lwp_t *l, bool cleanup) KASSERT(l->l_wchan != NULL); sleepq_remove(sq, l); - if (cleanup) { + if (unlock) { mutex_spin_exit(mp); } } Index: src/sys/kern/kern_turnstile.c diff -u src/sys/kern/kern_turnstile.c:1.32 src/sys/kern/kern_turnstile.c:1.33 --- src/sys/kern/kern_turnstile.c:1.32 Fri Jun 15 13:51:40 2012 +++ src/sys/kern/kern_turnstile.c Thu Nov 21 18:56:55 2019 @@ -1,7 +1,7 @@ -/* $NetBSD: kern_turnstile.c,v 1.32 2012/06/15 13:51:40 yamt Exp $ */ +/* $NetBSD: kern_turnstile.c,v 1.33 2019/11/21 18:56:55 ad Exp $ */ /*- - * Copyright (c) 2002, 2006, 2007, 2009 The NetBSD Foundation, Inc. + * Copyright (c) 2002, 2006, 2007, 2009, 2019 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation @@ -56,11 +56,11 @@ * grabs a free turnstile off the free list. Otherwise, it can take back * the active turnstile from the lock (thus deactivating the turnstile). * - * Turnstiles are the place to do priority inheritence. + * Turnstiles are where we do priority inheritence. */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_turnstile.c,v 1.32 2012/06/15 13:51:40 yamt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_turnstile.c,v 1.33 2019/11/21 18:56:55 ad Exp $"); #include #include @@ -69,17 +69,23 @@ __KERNEL_RCSID(0, "$NetBSD: kern_turnsti #include #include -#define TS_HASH_SIZE 64 +/* + * Shift of 6 aligns to typical cache line size of 64 bytes; there's no + * point having two turnstile locks to back two lock objects that share
CVS commit: src/sys/kern
Module Name:src Committed By: ad Date: Thu Nov 21 18:22:05 UTC 2019 Modified Files: src/sys/kern: kern_lwp.c Log Message: lwp_create: - Don't need to check for PK_SYSTEM when inheriting an affinity mask. - Inherit processor set ID under proc_lock, to sync with pset syscalls. To generate a diff of this commit: cvs rdiff -u -r1.209 -r1.210 src/sys/kern/kern_lwp.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/kern
Module Name:src Committed By: ad Date: Thu Nov 21 18:22:05 UTC 2019 Modified Files: src/sys/kern: kern_lwp.c Log Message: lwp_create: - Don't need to check for PK_SYSTEM when inheriting an affinity mask. - Inherit processor set ID under proc_lock, to sync with pset syscalls. To generate a diff of this commit: cvs rdiff -u -r1.209 -r1.210 src/sys/kern/kern_lwp.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/kern_lwp.c diff -u src/sys/kern/kern_lwp.c:1.209 src/sys/kern/kern_lwp.c:1.210 --- src/sys/kern/kern_lwp.c:1.209 Thu Nov 21 18:17:36 2019 +++ src/sys/kern/kern_lwp.c Thu Nov 21 18:22:05 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_lwp.c,v 1.209 2019/11/21 18:17:36 ad Exp $ */ +/* $NetBSD: kern_lwp.c,v 1.210 2019/11/21 18:22:05 ad Exp $ */ /*- * Copyright (c) 2001, 2006, 2007, 2008, 2009, 2019 The NetBSD Foundation, Inc. @@ -211,7 +211,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_lwp.c,v 1.209 2019/11/21 18:17:36 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_lwp.c,v 1.210 2019/11/21 18:22:05 ad Exp $"); #include "opt_ddb.h" #include "opt_lockdebug.h" @@ -952,26 +952,18 @@ lwp_create(lwp_t *l1, proc_t *p2, vaddr_ KASSERT(l2->l_affinity == NULL); - if ((p2->p_flag & PK_SYSTEM) == 0) { - /* Inherit the affinity mask. */ + /* Inherit the affinity mask. */ + if (l1->l_affinity) { + /* + * Note that we hold the state lock while inheriting + * the affinity to avoid race with sched_setaffinity(). + */ + lwp_lock(l1); if (l1->l_affinity) { - /* - * Note that we hold the state lock while inheriting - * the affinity to avoid race with sched_setaffinity(). - */ - lwp_lock(l1); - if (l1->l_affinity) { -kcpuset_use(l1->l_affinity); -l2->l_affinity = l1->l_affinity; - } - lwp_unlock(l1); + kcpuset_use(l1->l_affinity); + l2->l_affinity = l1->l_affinity; } - lwp_lock(l2); - /* Inherit a processor-set */ - l2->l_psid = l1->l_psid; - /* Look for a CPU to start */ - l2->l_cpu = sched_takecpu(l2); - lwp_unlock_to(l2, l2->l_cpu->ci_schedstate.spc_mutex); + lwp_unlock(l1); } mutex_exit(p2->p_lock); @@ -979,6 +971,8 @@ lwp_create(lwp_t *l1, proc_t *p2, vaddr_ mutex_enter(proc_lock); LIST_INSERT_HEAD(, l2, l_list); + /* Inherit a processor-set */ + l2->l_psid = l1->l_psid; mutex_exit(proc_lock); SYSCALL_TIME_LWP_INIT(l2);
CVS commit: src/sys/kern
Module Name:src Committed By: ad Date: Thu Nov 21 18:17:36 UTC 2019 Modified Files: src/sys/kern: kern_lwp.c kern_sig.c Log Message: - lwp_need_userret(): only do it if ONPROC and !curlwp, and explain why. - Use signotify() in a couple more places. To generate a diff of this commit: cvs rdiff -u -r1.208 -r1.209 src/sys/kern/kern_lwp.c cvs rdiff -u -r1.379 -r1.380 src/sys/kern/kern_sig.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/kern
Module Name:src Committed By: ad Date: Thu Nov 21 18:17:36 UTC 2019 Modified Files: src/sys/kern: kern_lwp.c kern_sig.c Log Message: - lwp_need_userret(): only do it if ONPROC and !curlwp, and explain why. - Use signotify() in a couple more places. To generate a diff of this commit: cvs rdiff -u -r1.208 -r1.209 src/sys/kern/kern_lwp.c cvs rdiff -u -r1.379 -r1.380 src/sys/kern/kern_sig.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/kern_lwp.c diff -u src/sys/kern/kern_lwp.c:1.208 src/sys/kern/kern_lwp.c:1.209 --- src/sys/kern/kern_lwp.c:1.208 Thu Nov 14 16:23:52 2019 +++ src/sys/kern/kern_lwp.c Thu Nov 21 18:17:36 2019 @@ -1,7 +1,7 @@ -/* $NetBSD: kern_lwp.c,v 1.208 2019/11/14 16:23:52 maxv Exp $ */ +/* $NetBSD: kern_lwp.c,v 1.209 2019/11/21 18:17:36 ad Exp $ */ /*- - * Copyright (c) 2001, 2006, 2007, 2008, 2009 The NetBSD Foundation, Inc. + * Copyright (c) 2001, 2006, 2007, 2008, 2009, 2019 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation @@ -211,7 +211,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_lwp.c,v 1.208 2019/11/14 16:23:52 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_lwp.c,v 1.209 2019/11/21 18:17:36 ad Exp $"); #include "opt_ddb.h" #include "opt_lockdebug.h" @@ -1147,7 +1147,7 @@ lwp_exit(struct lwp *l) firstsig(>p_sigpend.sp_set) != 0) { LIST_FOREACH(l2, >p_lwps, l_sibling) { lwp_lock(l2); - l2->l_flag |= LW_PENDSIG; + signotify(l2); lwp_unlock(l2); } } @@ -1616,15 +1616,26 @@ lwp_userret(struct lwp *l) void lwp_need_userret(struct lwp *l) { + + KASSERT(!cpu_intr_p()); KASSERT(lwp_locked(l, NULL)); /* - * Since the tests in lwp_userret() are done unlocked, make sure - * that the condition will be seen before forcing the LWP to enter - * kernel mode. - */ - membar_producer(); - cpu_signotify(l); + * If the LWP is in any state other than LSONPROC, we know that it + * is executing in-kernel and will hit userret() on the way out. + * + * If the LWP is curlwp, then we know we'll be back out to userspace + * soon (can't be called from a hardware interrupt here). + * + * Otherwise, we can't be sure what the LWP is doing, so first make + * sure the update to l_flag will be globally visible, and then + * force the LWP to take a trip through trap() where it will do + * userret(). + */ + if (l->l_stat == LSONPROC && l != curlwp) { + membar_producer(); + cpu_signotify(l); + } } /* Index: src/sys/kern/kern_sig.c diff -u src/sys/kern/kern_sig.c:1.379 src/sys/kern/kern_sig.c:1.380 --- src/sys/kern/kern_sig.c:1.379 Wed Nov 20 19:37:53 2019 +++ src/sys/kern/kern_sig.c Thu Nov 21 18:17:36 2019 @@ -1,7 +1,7 @@ -/* $NetBSD: kern_sig.c,v 1.379 2019/11/20 19:37:53 pgoyette Exp $ */ +/* $NetBSD: kern_sig.c,v 1.380 2019/11/21 18:17:36 ad Exp $ */ /*- - * Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc. + * Copyright (c) 2006, 2007, 2008, 2019 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation @@ -70,7 +70,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_sig.c,v 1.379 2019/11/20 19:37:53 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_sig.c,v 1.380 2019/11/21 18:17:36 ad Exp $"); #include "opt_ptrace.h" #include "opt_dtrace.h" @@ -710,6 +710,9 @@ sigclearall(struct proc *p, const sigset * current LWP. May be called unlocked provided that LW_PENDSIG is set, * and that the signal has been posted to the appopriate queue before * LW_PENDSIG is set. + * + * This should only ever be called with (l == curlwp), unless the + * result does not matter (procfs, sysctl). */ int sigispending(struct lwp *l, int signo) @@ -1133,7 +1136,7 @@ sigpost(struct lwp *l, sig_t action, int * Have the LWP check for signals. This ensures that even if no LWP * is found to take the signal immediately, it should be taken soon. */ - l->l_flag |= LW_PENDSIG; + signotify(l); /* * SIGCONT can be masked, but if LWP is stopped, it needs restart. @@ -1167,7 +1170,6 @@ sigpost(struct lwp *l, sig_t action, int switch (l->l_stat) { case LSRUN: case LSONPROC: - lwp_need_userret(l); rv = 1; break;
CVS commit: src/sys/kern
Module Name:src Committed By: ad Date: Thu Nov 21 17:57:40 UTC 2019 Modified Files: src/sys/kern: kern_timeout.c Log Message: Break the slow path for callout_halt() out into its own routine. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.56 -r1.57 src/sys/kern/kern_timeout.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/kern_timeout.c diff -u src/sys/kern/kern_timeout.c:1.56 src/sys/kern/kern_timeout.c:1.57 --- src/sys/kern/kern_timeout.c:1.56 Sun Mar 10 13:44:49 2019 +++ src/sys/kern/kern_timeout.c Thu Nov 21 17:57:40 2019 @@ -1,7 +1,7 @@ -/* $NetBSD: kern_timeout.c,v 1.56 2019/03/10 13:44:49 kre Exp $ */ +/* $NetBSD: kern_timeout.c,v 1.57 2019/11/21 17:57:40 ad Exp $ */ /*- - * Copyright (c) 2003, 2006, 2007, 2008, 2009 The NetBSD Foundation, Inc. + * Copyright (c) 2003, 2006, 2007, 2008, 2009, 2019 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation @@ -59,7 +59,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_timeout.c,v 1.56 2019/03/10 13:44:49 kre Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_timeout.c,v 1.57 2019/11/21 17:57:40 ad Exp $"); /* * Timeouts are kept in a hierarchical timing wheel. The c_time is the @@ -185,8 +185,10 @@ struct callout_cpu { #ifndef CRASH static void callout_softclock(void *); -static struct callout_cpu callout_cpu0; -static void *callout_sih; +static void callout_wait(callout_impl_t *, void *, kmutex_t *); + +static struct callout_cpu callout_cpu0 __cacheline_aligned; +static void *callout_sih __read_mostly; static inline kmutex_t * callout_lock(callout_impl_t *c) @@ -466,24 +468,42 @@ bool callout_halt(callout_t *cs, void *interlock) { callout_impl_t *c = (callout_impl_t *)cs; - struct callout_cpu *cc; - struct lwp *l; - kmutex_t *lock, *relock; - bool expired; + kmutex_t *lock; + int flags; KASSERT(c->c_magic == CALLOUT_MAGIC); KASSERT(!cpu_intr_p()); KASSERT(interlock == NULL || mutex_owned(interlock)); + /* Fast path. */ lock = callout_lock(c); - relock = NULL; - - expired = ((c->c_flags & CALLOUT_FIRED) != 0); - if ((c->c_flags & CALLOUT_PENDING) != 0) + flags = c->c_flags; + if ((flags & CALLOUT_PENDING) != 0) CIRCQ_REMOVE(>c_list); - c->c_flags &= ~(CALLOUT_PENDING|CALLOUT_FIRED); + c->c_flags = flags & ~(CALLOUT_PENDING|CALLOUT_FIRED); + if (__predict_false(flags & CALLOUT_FIRED)) { + callout_wait(c, interlock, lock); + return true; + } + mutex_spin_exit(lock); + return false; +} + +/* + * callout_wait: + * + * Slow path for callout_halt(). Deliberately marked __noinline to + * prevent unneeded overhead in the caller. + */ +static void __noinline +callout_wait(callout_impl_t *c, void *interlock, kmutex_t *lock) +{ + struct callout_cpu *cc; + struct lwp *l; + kmutex_t *relock; l = curlwp; + relock = NULL; for (;;) { cc = c->c_cpu; if (__predict_true(cc->cc_active != c || cc->cc_lwp == l)) @@ -515,8 +535,6 @@ callout_halt(callout_t *cs, void *interl mutex_spin_exit(lock); if (__predict_false(relock != NULL)) mutex_enter(relock); - - return expired; } #ifdef notyet
CVS commit: src/sys/kern
Module Name:src Committed By: ad Date: Thu Nov 21 17:57:40 UTC 2019 Modified Files: src/sys/kern: kern_timeout.c Log Message: Break the slow path for callout_halt() out into its own routine. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.56 -r1.57 src/sys/kern/kern_timeout.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys
Module Name:src Committed By: ad Date: Thu Nov 21 17:54:04 UTC 2019 Modified Files: src/sys/kern: sys_pset.c src/sys/sys: pset.h Log Message: Simplify pset locking, making it easier to sync with LWP creation, etc. To generate a diff of this commit: cvs rdiff -u -r1.21 -r1.22 src/sys/kern/sys_pset.c cvs rdiff -u -r1.6 -r1.7 src/sys/sys/pset.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys
Module Name:src Committed By: ad Date: Thu Nov 21 17:54:04 UTC 2019 Modified Files: src/sys/kern: sys_pset.c src/sys/sys: pset.h Log Message: Simplify pset locking, making it easier to sync with LWP creation, etc. To generate a diff of this commit: cvs rdiff -u -r1.21 -r1.22 src/sys/kern/sys_pset.c cvs rdiff -u -r1.6 -r1.7 src/sys/sys/pset.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/sys_pset.c diff -u src/sys/kern/sys_pset.c:1.21 src/sys/kern/sys_pset.c:1.22 --- src/sys/kern/sys_pset.c:1.21 Sun Dec 9 23:05:02 2018 +++ src/sys/kern/sys_pset.c Thu Nov 21 17:54:04 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: sys_pset.c,v 1.21 2018/12/09 23:05:02 mlelstv Exp $ */ +/* $NetBSD: sys_pset.c,v 1.22 2019/11/21 17:54:04 ad Exp $ */ /* * Copyright (c) 2008, Mindaugas Rasiukevicius @@ -36,7 +36,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sys_pset.c,v 1.21 2018/12/09 23:05:02 mlelstv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sys_pset.c,v 1.22 2019/11/21 17:54:04 ad Exp $"); #include @@ -156,8 +156,6 @@ psid_validate(psetid_t psid, bool chkps) return EINVAL; if (psets[psid - 1] == NULL) return EINVAL; - if (psets[psid - 1]->ps_flags & PSET_BUSY) - return EBUSY; return 0; } @@ -204,7 +202,6 @@ static int kern_pset_destroy(psetid_t psid) { struct cpu_info *ci; - pset_info_t *pi; struct lwp *l; CPU_INFO_ITERATOR cii; int error; @@ -229,10 +226,6 @@ kern_pset_destroy(psetid_t psid) continue; spc->spc_psid = PS_NONE; } - /* Mark that processor-set is going to be destroyed */ - pi = psets[psid - 1]; - pi->ps_flags |= PSET_BUSY; - mutex_exit(_lock); /* Unmark the processor-set ID from each thread */ mutex_enter(proc_lock); @@ -245,12 +238,11 @@ kern_pset_destroy(psetid_t psid) mutex_exit(proc_lock); /* Destroy the processor-set */ - mutex_enter(_lock); + kmem_free(psets[psid - 1], sizeof(pset_info_t)); psets[psid - 1] = NULL; psets_count--; mutex_exit(_lock); - kmem_free(pi, sizeof(pset_info_t)); return 0; } @@ -452,9 +444,6 @@ sys__pset_bind(struct lwp *l, const stru } if (psid == PS_MYID) psid = curlwp->l_psid; - if (psid != PS_QUERY && psid != PS_NONE) - psets[psid - 1]->ps_flags |= PSET_BUSY; - mutex_exit(_lock); /* * Get PID and LID from the ID. @@ -463,6 +452,7 @@ sys__pset_bind(struct lwp *l, const stru id1 = SCARG(uap, first_id); id2 = SCARG(uap, second_id); + mutex_enter(proc_lock); switch (SCARG(uap, idtype)) { case P_PID: /* @@ -493,19 +483,13 @@ sys__pset_bind(struct lwp *l, const stru } /* Find the process */ - mutex_enter(proc_lock); p = proc_find(pid); if (p == NULL) { - mutex_exit(proc_lock); error = ESRCH; goto error; } - mutex_enter(p->p_lock); - mutex_exit(proc_lock); - /* Disallow modification of the system processes */ if (p->p_flag & PK_SYSTEM) { - mutex_exit(p->p_lock); error = EPERM; goto error; } @@ -513,6 +497,7 @@ sys__pset_bind(struct lwp *l, const stru /* Find the LWP(s) */ lcnt = 0; ci = NULL; + mutex_enter(p->p_lock); LIST_FOREACH(t, >p_lwps, l_sibling) { if (lid && lid != t->l_lid) continue; @@ -531,16 +516,12 @@ sys__pset_bind(struct lwp *l, const stru mutex_exit(p->p_lock); if (lcnt == 0) { error = ESRCH; - goto error; } - if (SCARG(uap, opsid)) - error = copyout(, SCARG(uap, opsid), sizeof(psetid_t)); error: - if (psid != PS_QUERY && psid != PS_NONE) { - mutex_enter(_lock); - psets[psid - 1]->ps_flags &= ~PSET_BUSY; - mutex_exit(_lock); - } + mutex_exit(proc_lock); + mutex_exit(_lock); + if (error == 0 && SCARG(uap, opsid)) + error = copyout(, SCARG(uap, opsid), sizeof(psetid_t)); return error; } Index: src/sys/sys/pset.h diff -u src/sys/sys/pset.h:1.6 src/sys/sys/pset.h:1.7 --- src/sys/sys/pset.h:1.6 Mon May 28 21:05:02 2018 +++ src/sys/sys/pset.h Thu Nov 21 17:54:04 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: pset.h,v 1.6 2018/05/28 21:05:02 chs Exp $ */ +/* $NetBSD: pset.h,v 1.7 2019/11/21 17:54:04 ad Exp $ */ /* * Copyright (c) 2008, Mindaugas Rasiukevicius @@ -57,9 +57,6 @@ typedef struct { int ps_flags; } pset_info_t; -/* Flags */ -#define PSET_BUSY 0x01 - void psets_init(void); #endif /* _KERNEL */
CVS commit: src/sys/kern
Module Name:src Committed By: ad Date: Thu Nov 21 17:50:49 UTC 2019 Modified Files: src/sys/kern: kern_resource.c kern_softint.c Log Message: calcru: ignore running softints, unless softint_timing is on. Fixes crazy times reported for proc0. To generate a diff of this commit: cvs rdiff -u -r1.182 -r1.183 src/sys/kern/kern_resource.c cvs rdiff -u -r1.48 -r1.49 src/sys/kern/kern_softint.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/kern_resource.c diff -u src/sys/kern/kern_resource.c:1.182 src/sys/kern/kern_resource.c:1.183 --- src/sys/kern/kern_resource.c:1.182 Fri Apr 5 00:33:21 2019 +++ src/sys/kern/kern_resource.c Thu Nov 21 17:50:49 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_resource.c,v 1.182 2019/04/05 00:33:21 mlelstv Exp $ */ +/* $NetBSD: kern_resource.c,v 1.183 2019/11/21 17:50:49 ad Exp $ */ /*- * Copyright (c) 1982, 1986, 1991, 1993 @@ -37,7 +37,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_resource.c,v 1.182 2019/04/05 00:33:21 mlelstv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_resource.c,v 1.183 2019/11/21 17:50:49 ad Exp $"); #include #include @@ -506,7 +506,8 @@ calcru(struct proc *p, struct timeval *u LIST_FOREACH(l, >p_lwps, l_sibling) { lwp_lock(l); bintime_add(, >l_rtime); - if ((l->l_pflag & LP_RUNNING) != 0) { + if ((l->l_pflag & LP_RUNNING) != 0 && + (l->l_pflag & (LP_INTR | LP_TIMEINTR)) != LP_INTR) { struct bintime diff; /* * Adjust for the current time slice. This is @@ -516,6 +517,7 @@ calcru(struct proc *p, struct timeval *u * error. */ binuptime(); + membar_consumer(); /* for softint_dispatch() */ bintime_sub(, >l_stime); bintime_add(, ); } Index: src/sys/kern/kern_softint.c diff -u src/sys/kern/kern_softint.c:1.48 src/sys/kern/kern_softint.c:1.49 --- src/sys/kern/kern_softint.c:1.48 Sun Oct 6 15:11:17 2019 +++ src/sys/kern/kern_softint.c Thu Nov 21 17:50:49 2019 @@ -1,7 +1,7 @@ -/* $NetBSD: kern_softint.c,v 1.48 2019/10/06 15:11:17 uwe Exp $ */ +/* $NetBSD: kern_softint.c,v 1.49 2019/11/21 17:50:49 ad Exp $ */ /*- - * Copyright (c) 2007, 2008 The NetBSD Foundation, Inc. + * Copyright (c) 2007, 2008, 2019 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation @@ -170,7 +170,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_softint.c,v 1.48 2019/10/06 15:11:17 uwe Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_softint.c,v 1.49 2019/11/21 17:50:49 ad Exp $"); #include #include @@ -866,14 +866,16 @@ softint_dispatch(lwp_t *pinned, int s) timing = (softint_timing ? LP_TIMEINTR : 0); l->l_switchto = pinned; l->l_stat = LSONPROC; - l->l_pflag |= (LP_RUNNING | timing); /* * Dispatch the interrupt. If softints are being timed, charge * for it. */ - if (timing) + if (timing) { binuptime(>l_stime); + membar_producer(); /* for calcru */ + } + l->l_pflag |= (LP_RUNNING | timing); softint_execute(si, l, s); if (timing) { binuptime();
CVS commit: src/sys/kern
Module Name:src Committed By: ad Date: Thu Nov 21 17:50:49 UTC 2019 Modified Files: src/sys/kern: kern_resource.c kern_softint.c Log Message: calcru: ignore running softints, unless softint_timing is on. Fixes crazy times reported for proc0. To generate a diff of this commit: cvs rdiff -u -r1.182 -r1.183 src/sys/kern/kern_resource.c cvs rdiff -u -r1.48 -r1.49 src/sys/kern/kern_softint.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/uvm
Module Name:src Committed By: ad Date: Thu Nov 21 17:47:53 UTC 2019 Modified Files: src/sys/uvm: uvm_glue.c Log Message: Use lwp_changepri(). To generate a diff of this commit: cvs rdiff -u -r1.169 -r1.170 src/sys/uvm/uvm_glue.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/uvm/uvm_glue.c diff -u src/sys/uvm/uvm_glue.c:1.169 src/sys/uvm/uvm_glue.c:1.170 --- src/sys/uvm/uvm_glue.c:1.169 Thu Nov 14 16:48:51 2019 +++ src/sys/uvm/uvm_glue.c Thu Nov 21 17:47:53 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: uvm_glue.c,v 1.169 2019/11/14 16:48:51 maxv Exp $ */ +/* $NetBSD: uvm_glue.c,v 1.170 2019/11/21 17:47:53 ad Exp $ */ /* * Copyright (c) 1997 Charles D. Cranor and Washington University. @@ -62,7 +62,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uvm_glue.c,v 1.169 2019/11/14 16:48:51 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uvm_glue.c,v 1.170 2019/11/21 17:47:53 ad Exp $"); #include "opt_kgdb.h" #include "opt_kstack.h" @@ -496,8 +496,8 @@ uvm_scheduler(void) lwp_t *l = curlwp; lwp_lock(l); - l->l_priority = PRI_VM; l->l_class = SCHED_FIFO; + lwp_changepri(l, PRI_VM); lwp_unlock(l); for (;;) {
CVS commit: src/sys/dev/pci
Module Name:src Committed By: ad Date: Thu Nov 21 17:47:23 UTC 2019 Modified Files: src/sys/dev/pci: ichsmb.c Log Message: If attach fails, don't panic on detach. To generate a diff of this commit: cvs rdiff -u -r1.60 -r1.61 src/sys/dev/pci/ichsmb.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ichsmb.c diff -u src/sys/dev/pci/ichsmb.c:1.60 src/sys/dev/pci/ichsmb.c:1.61 --- src/sys/dev/pci/ichsmb.c:1.60 Mon Dec 10 06:23:54 2018 +++ src/sys/dev/pci/ichsmb.c Thu Nov 21 17:47:23 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: ichsmb.c,v 1.60 2018/12/10 06:23:54 jdolecek Exp $ */ +/* $NetBSD: ichsmb.c,v 1.61 2019/11/21 17:47:23 ad Exp $ */ /* $OpenBSD: ichiic.c,v 1.18 2007/05/03 09:36:26 dlg Exp $ */ /* @@ -22,7 +22,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ichsmb.c,v 1.60 2018/12/10 06:23:54 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ichsmb.c,v 1.61 2019/11/21 17:47:23 ad Exp $"); #include #include @@ -265,7 +265,8 @@ ichsmb_detach(device_t self, int flags) sc->sc_pihp = NULL; } - bus_space_unmap(sc->sc_iot, sc->sc_ioh, sc->sc_size); + if (sc->sc_size != 0) + bus_space_unmap(sc->sc_iot, sc->sc_ioh, sc->sc_size); return 0; }
CVS commit: src/sys/uvm
Module Name:src Committed By: ad Date: Thu Nov 21 17:47:53 UTC 2019 Modified Files: src/sys/uvm: uvm_glue.c Log Message: Use lwp_changepri(). To generate a diff of this commit: cvs rdiff -u -r1.169 -r1.170 src/sys/uvm/uvm_glue.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/pci
Module Name:src Committed By: ad Date: Thu Nov 21 17:47:23 UTC 2019 Modified Files: src/sys/dev/pci: ichsmb.c Log Message: If attach fails, don't panic on detach. To generate a diff of this commit: cvs rdiff -u -r1.60 -r1.61 src/sys/dev/pci/ichsmb.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/kern
Module Name:src Committed By: ad Date: Wed Nov 20 21:49:00 UTC 2019 Modified Files: src/sys/kern: kern_condvar.c Log Message: - Put back a microoptimisation that was accidentally removed. - Comments. To generate a diff of this commit: cvs rdiff -u -r1.41 -r1.42 src/sys/kern/kern_condvar.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/kern_condvar.c diff -u src/sys/kern/kern_condvar.c:1.41 src/sys/kern/kern_condvar.c:1.42 --- src/sys/kern/kern_condvar.c:1.41 Tue Jan 30 07:52:22 2018 +++ src/sys/kern/kern_condvar.c Wed Nov 20 21:49:00 2019 @@ -1,7 +1,7 @@ -/* $NetBSD: kern_condvar.c,v 1.41 2018/01/30 07:52:22 ozaki-r Exp $ */ +/* $NetBSD: kern_condvar.c,v 1.42 2019/11/20 21:49:00 ad Exp $ */ /*- - * Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc. + * Copyright (c) 2006, 2007, 2008, 2019 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation @@ -34,7 +34,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_condvar.c,v 1.41 2018/01/30 07:52:22 ozaki-r Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_condvar.c,v 1.42 2019/11/20 21:49:00 ad Exp $"); #include #include @@ -210,10 +210,10 @@ cv_exit(kcondvar_t *cv, kmutex_t *mtx, l * Remove an LWP from the condition variable and sleep queue. This * is called when the LWP has not been awoken normally but instead * interrupted: for example, when a signal is received. Must be - * called with the LWP locked, and must return it unlocked. + * called with the LWP locked. Will unlock if "unlock" is true. */ static void -cv_unsleep(lwp_t *l, bool cleanup) +cv_unsleep(lwp_t *l, bool unlock) { kcondvar_t *cv __diagused; @@ -224,7 +224,7 @@ cv_unsleep(lwp_t *l, bool cleanup) KASSERT(cv_is_valid(cv)); KASSERT(cv_has_waiters(cv)); - sleepq_unsleep(l, cleanup); + sleepq_unsleep(l, unlock); } /* @@ -490,7 +490,14 @@ cv_signal(kcondvar_t *cv) cv_wakeup_one(cv); } -static inline void +/* + * cv_wakeup_one: + * + * Slow path for cv_signal(). Deliberately marked __noinline to + * prevent the compiler pulling it in to cv_signal(), which adds + * extra prologue and epilogue code. + */ +static __noinline void cv_wakeup_one(kcondvar_t *cv) { sleepq_t *sq; @@ -502,7 +509,7 @@ cv_wakeup_one(kcondvar_t *cv) mp = sleepq_hashlock(cv); sq = CV_SLEEPQ(cv); l = TAILQ_FIRST(sq); - if (l == NULL) { + if (__predict_false(l == NULL)) { mutex_spin_exit(mp); return; } @@ -533,7 +540,14 @@ cv_broadcast(kcondvar_t *cv) cv_wakeup_all(cv); } -static inline void +/* + * cv_wakeup_all: + * + * Slow path for cv_broadcast(). Deliberately marked __noinline to + * prevent the compiler pulling it in to cv_broadcast(), which adds + * extra prologue and epilogue code. + */ +static __noinline void cv_wakeup_all(kcondvar_t *cv) { sleepq_t *sq;
CVS commit: src/sys/kern
Module Name:src Committed By: ad Date: Wed Nov 20 21:49:00 UTC 2019 Modified Files: src/sys/kern: kern_condvar.c Log Message: - Put back a microoptimisation that was accidentally removed. - Comments. To generate a diff of this commit: cvs rdiff -u -r1.41 -r1.42 src/sys/kern/kern_condvar.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Re: CVS commit: src/sys
On Mon, Feb 28, 2011 at 04:48:43PM +, Mindaugas Rasiukevicius wrote: Jukka Ruohonen jru...@netbsd.org wrote: Module Name:src Committed By: jruoho Date: Fri Feb 25 09:16:00 UTC 2011 Modified Files: src/sys/arch/x86/acpi: acpi_cpu_md.c src/sys/dev/acpi: acpi_cpu.h acpi_cpu_pstate.c Log Message: Add preliminary support for the IA32_APERF and IA32_MPERF frequency counters. These are not yet used for anything and only Intel is supported at the moment. ... From acpicpu_md_pstate_percent(): + x86_disable_intr(); + + aperf = sc-sc_pstate_aperf; + mperf = sc-sc_pstate_mperf; + + xc = xc_unicast(0, acpicpu_md_pstate_percent_status, sc, NULL, ci); + xc_wait(xc); + + x86_enable_intr(); Why interrupts are disabled here? Calling xc_wait() with interrupts disabled is, at minimum, very expensive, and I would say it is wrong. Note that xc_wait(9) does not necessary spin - it can block. You must not call these interfaces or any kind of MI synchronization interface, spin mutexes included, with interrupts switched off at the machine level!
Re: CVS commit: src/sys
On Tue, Mar 01, 2011 at 01:17:11PM +0200, Jukka Ruohonen wrote: On Tue, Mar 01, 2011 at 09:53:24AM +, Andrew Doran wrote: You must not call these interfaces or any kind of MI synchronization interface, spin mutexes included, with interrupts switched off at the machine level! Yes, of course. It was a bug in a code that is not yet used. Already fixed, will not happen again. Thanks. Also in case it's not clear my e-mail was intended to convey surprise and not much else! The interrupt restriction is true for atomic operations also, incidentally. I think maybe the only MI sync interfaces we have where it's OK to disable interrupts on the CPU are __cpu_simple_lock_t and the memory barriers (membar). Where the raw spinlocks are used it's a case of all bets are off, you need to be aware of the side effects. E.g. there are restrictions on how long you can hold the locks, what sort of events you can wait for and so on.
Re: CVS commit: src/sys/kern
On Fri, Oct 15, 2010 at 10:33:22PM +, Andrew Doran wrote: On Fri, Oct 15, 2010 at 05:30:52PM +0100, Mindaugas Rasiukevicius wrote: o...@netbsd.org wrote: In M_WAIT case, m_reclaim() will run and run until get mbuf cluster if mclpool limit reached. If m_reclaim() repeatedly but cannot to get new mbuf cluster, m_clget() will not return. network stacks using mbufs is use with M_DONTWAIT, but it will failed to get new mbuf cluster in this case. freeze means that. Yes, hitting the limit would trigger m_reclaim() and m_clget() would block. It is a quite similar condition to memory or KVA starvation. However, why such blocking in sosend() is problematic, or, how is it different from any other WAITOK allocation? I see the point about the limit. Inadequately low limit may cause many blocking processes, while there is still a lot of memory. However, in such case, perhaps you want PR_LIMITFAIL, instead of PR_NOWAIT? Note that PR_NOWAIT (M_DONTWAIT) has other implications, e.g. it might fail due to try-locks. So, I think your fix is incorrect. Agreed. NOWAIT should almost never be used from thread/process context, it indicates that an underlying problem is not being tackled properly. In this case it may introduce sporadic and hard to reproduce failures. If we're not going to fix the reclaim problem in the near future I suggest it's better to change this back to WAITOK. Has this been fixed? The least objectionable hack that I can see would be to add an analogue of PR_LIMITFAIL. Thanks.
Re: CVS commit: src/sys/kern
On Fri, Oct 15, 2010 at 05:30:52PM +0100, Mindaugas Rasiukevicius wrote: o...@netbsd.org wrote: In M_WAIT case, m_reclaim() will run and run until get mbuf cluster if mclpool limit reached. If m_reclaim() repeatedly but cannot to get new mbuf cluster, m_clget() will not return. network stacks using mbufs is use with M_DONTWAIT, but it will failed to get new mbuf cluster in this case. freeze means that. Yes, hitting the limit would trigger m_reclaim() and m_clget() would block. It is a quite similar condition to memory or KVA starvation. However, why such blocking in sosend() is problematic, or, how is it different from any other WAITOK allocation? I see the point about the limit. Inadequately low limit may cause many blocking processes, while there is still a lot of memory. However, in such case, perhaps you want PR_LIMITFAIL, instead of PR_NOWAIT? Note that PR_NOWAIT (M_DONTWAIT) has other implications, e.g. it might fail due to try-locks. So, I think your fix is incorrect. Agreed. NOWAIT should almost never be used from thread/process context, it indicates that an underlying problem is not being tackled properly. In this case it may introduce sporadic and hard to reproduce failures. If we're not going to fix the reclaim problem in the near future I suggest it's better to change this back to WAITOK.
Re: CVS commit: src/sys/kern
On Thu, Oct 14, 2010 at 04:59:42AM +0100, Mindaugas Rasiukevicius wrote: Hello, Masaru OKI o...@netbsd.org wrote: Module Name:src Committed By: oki Date: Thu Oct 14 03:07:52 UTC 2010 Modified Files: src/sys/kern: uipc_socket.c Log Message: Wait for freeing mbuf cluster in sosend() causes freeze network stack. Don't wait for it. problem was found by iij seil team. it is similar to OpenBSD uipc_socket.c rev.1.72. Can you explain what the actual problem M_WAIT causes i.e. how would it freeze network stack? I don't see what it would solve on the face of it, but regardless M_DONTWAIT is almost certainly the wrong thing to do here.
Re: CVS commit: src
On Thu, Oct 07, 2010 at 01:33:46AM +0200, Jean-Yves Migeon wrote: On 06.10.2010 12:16, Manuel Bouyer wrote: On Tue, Oct 05, 2010 at 11:48:17PM +, Jean-Yves Migeon wrote: [...] XXX Currently, savecore(8) will fail to dump a PAE kernel in a !PAE environment (and reciprocally). So you need to sync and reboot with a kernel of the same mode as the one that crashed. Once the dump is successful, this does not matter anymore. Doesn't it work with savecore -N /the_right_kernel ? No; in fact, dumplo is complete garbage, so savecore fails dumping the image. I suspect that the KREAD() in savecore.c does not read at the correct offset, and just sets garbage for dumplo. I have to see what code path takes savecore with -N, and where it differs from the case where it goes through getbootfile(3) when the booted kernel is different from the one that is about to get dumped. Just thinking out loud: With the ksyms dump code I added, the kernel image is only used to find the symbol table etc. It would be nice to eventually ditch the need for a kernel image. Everything required is already in the dump, we just need to extract the symbol table from ksyms. Also, on reflection I think that crash(8) is a better all round deal than the limited debug symbols we were thinking about previously.
Re: CVS commit: src/sys/kern
On Tue, Aug 17, 2010 at 04:45:36PM +0300, Antti Kantee wrote: On Tue Aug 17 2010 at 15:41:11 +0200, Juergen Hannken-Illjes wrote: vp-v_freelisthd = NULL; mutex_exit(vnode_free_list_lock); - if (vp-v_usecount != 0) { - /* -* was referenced again before we got the interlock -* Don't return to freelist - the holder of the last -* reference will destroy it. -*/ - mutex_exit(vp-v_interlock); - mutex_enter(vnode_free_list_lock); - goto retry; - } + KASSERT(vp-v_usecount == 0); It's not obvious from your commit message what prevents it from gaining a reference after the lock is dropped. The interlock is taken before the freelist lock is dropped and vnodes on the free lists should never appear on other lists. Not even the name cache? (I can't remember off the top of my head, but IIRC there's something sneaky about it) They can still appear on mount lists I think (it has been a while).. Are these changes in diff format anywhere?
Re: CVS commit: src/sys/arch
Hi, Why are any types other than in the pmap different between PAE and !PAE? When this was originally proposed I asked for stuff like paddr_t to be 64 bits no matter what the kernel compile settings where. Thanks. On Mon, Aug 16, 2010 at 10:45:10PM +0200, Jean-Yves Migeon wrote: On 16.08.2010 22:22, matthew green wrote: Module Name: src Committed By: jym Date: Mon Aug 16 19:39:06 UTC 2010 Modified Files: src/sys/arch/i386/i386: machdep.c src/sys/arch/x86/include: cpu.h Log Message: Add machdep.pae sysctl(7) for i386. Thanks to Paul and Joerg for their reviews. In kernel, it matches the 'i386_use_pae' variable (0: kernel does not use PAE, 1: kernel uses PAE). Will be used by i386 kvm(3) to know the functions that should get called for VA = PA translations. does this work for core files as well? if not, wouldn't this feature be better done use ugly kvm/nlist so that it works with the same code on dead kernels? getting a 0/1 value via kvm shouldn't really be considered any real problem. That's the purpose; I don't know of any other way. The sysctl is only there for practical purposes: cpuctl(8) can indicate that the CPU supports PAE, but there is no easy way to know if it is active or not (unless playing with config -x together with the booted kernel, not very practical...). Hence, the sysctl machdep. (why the extern in cpu.h? i doesn't seem necessary.) Yes; I wanted to place it at the same level as i386_use_fxsave. i386_use_pae may get use elsewhere eventually, so I added it to cpu.h. -- Jean-Yves Migeon jeanyves.mig...@free.fr
Re: CVS commit: src/sys
On Thu, Apr 29, 2010 at 09:39:50AM +1000, matthew green wrote: Modified Files: src/sys/arch/amd64/amd64: busfunc.S genassym.cf mainbus.c src/sys/arch/i386/i386: apmbios.c busfunc.S genassym.cf ipkdb_glue.c mainbus.c src/sys/arch/i386/isa: isapnp_machdep.c src/sys/arch/i386/pci: pceb.c pcibios.c pcmb.c src/sys/arch/i386/pnpbios: pnpbios.c src/sys/arch/i386/xbox: xbox.c xboxfb.c src/sys/arch/x86/include: bus.h src/sys/arch/x86/pci: pcib.c src/sys/arch/x86/x86: acpi_machdep.c bus_space.c consinit.c genfb_machdep.c src/sys/arch/xen/x86: consinit.c mainbus.c src/sys/arch/xen/xen: hypervisor.c xpci_xenbus.c src/sys/compat/ndis: nbcompat.h src/sys/dev/if_ndis: if_ndis_pci.c src/sys/dev/pci: puccn.c Log Message: On x86, change the bus_space_tag_t to a pointer to a struct bus_space_tag. For now, bus_space_tag's only member is bst_type, the type of space, which is either X86_BUS_SPACE_IO or X86_BUS_SPACE_MEM. In the future, new bus_space_tag members will refer to override-functions installed by a new function, bus_space_tag_create(9). Add pointers to constant struct bus_space_tag, x86_bus_space_io and x86_bus_space_mem. Use them to replace most uses of X86_BUS_SPACE_IO and X86_BUS_SPACE_MEM. Add an x86-specific bus_space_is_equal(9) implementation that compares the two tags' bst_type. this needs a kernel version bump i believe. old drivers should be allowed to load anymore... at the very least, the *drm driver modules will be broken. annoying that an MD change requires the MI version to bump but these sorts of changes aren't too common i guess. Also annoying that so much of this code is MD. Please run large x86 changes by me before commit. I would have told you what Matt just did :-). FYI you can now remove the #error from both busfunc.S and special _ALIGN_TEXT definitions since the sizes of the routines will be quite different now.
Re: CVS commit: src/sys/miscfs/specfs
On Tue, Apr 13, 2010 at 10:47:51AM +0300, Antti Kantee wrote: On Tue Apr 13 2010 at 01:15:56 +, Adam Hoka wrote: Module Name:src Committed By: ahoka Date: Tue Apr 13 01:15:56 UTC 2010 Modified Files: src/sys/miscfs/specfs: spec_vnops.c Log Message: Autoload modules with any class. This fixes autoloading of pf, zfs and possibly others. What is wrong with making drivers MODULE_CLASS_DRIVER? I think we should limit autoload aiming for safety, not splatter it all over. Eventually everything will of course be fixed by, *tadaa*, devfs. Meanwhile, please back this out and if you don't think calling a driver a driver is the right thing to do, have a discussion. What's the problem with autoloading any class? Is it just a cosmetic thing? One doesn't have to be an anointed driver to have an entry in /dev. (It implies that the modules and devsw entries inhabit the same namespace.)
Re: CVS commit: src/sys/dist/pf/net
On Tue, Apr 13, 2010 at 02:54:23PM +0300, Antti Kantee wrote: On Tue Apr 13 2010 at 01:02:44 +, Adam Hoka wrote: Module Name:src Committed By: ahoka Date: Tue Apr 13 01:02:43 UTC 2010 Modified Files: src/sys/dist/pf/net: pf_ioctl.c Log Message: Do not auto unload pf if it's enabled. Well what happens if you non-auto unload it when it's enabled? Just let unload fail if it's busy. There are a few issues with this: - Unload should be atomic. If it fails for some reason, we must not urinate in the user's corkflakes. So on that basis the EBUSY check belongs in the CMD_UNLOAD block. - At the point this is called, only module_lock is held. So there is no locking in at least the autounload case noted. Presumably the same is true for unload? That could cause crashes and is therefore unacceptable. (A strong choice of words - I am not trying to frustrate or rile anyone. As we say in Dublin the truth does be bitter. :-) - ENOTTY implies I don't understand what you just asked, zero would be a better return code as in yes that's fine, whatever. :-) This all needs to be written down somewhere, I'll have a look. #ifdef _KERNEL_OPT #include opt_inet.h @@ -3367,6 +3367,13 @@ pfdetach(); pflogdetach(); return devsw_detach(NULL, pf_cdevsw); + case MODULE_CMD_AUTOUNLOAD: + /* Do not auto unload pf if it's enabled. */ + if (pf_status.running) { + return EBUSY; + } else { + return ENOTTY; + } default: return ENOTTY; }
Re: CVS commit: src/sys/miscfs/specfs
On Tue, Apr 13, 2010 at 03:27:11PM +0300, Antti Kantee wrote: On Tue Apr 13 2010 at 12:18:38 +, Andrew Doran wrote: On Tue, Apr 13, 2010 at 10:47:51AM +0300, Antti Kantee wrote: On Tue Apr 13 2010 at 01:15:56 +, Adam Hoka wrote: Module Name:src Committed By: ahoka Date: Tue Apr 13 01:15:56 UTC 2010 Modified Files: src/sys/miscfs/specfs: spec_vnops.c Log Message: Autoload modules with any class. This fixes autoloading of pf, zfs and possibly others. What is wrong with making drivers MODULE_CLASS_DRIVER? I think we should limit autoload aiming for safety, not splatter it all over. Eventually everything will of course be fixed by, *tadaa*, devfs. Meanwhile, please back this out and if you don't think calling a driver a driver is the right thing to do, have a discussion. What's the problem with autoloading any class? Is it just a cosmetic thing? I already mentioned my opinion above: aim for safety. Since there is currently no common place to manage the different names we have, I don't want to discover some day that e.g. some secmodel name matches a devsw name. So the kernel of the problem is namespace collisions, correct? Would you agree that's it's the kernel programmers responsibility to avoid conflicts? If so how about sprinkling a little process in order to make it harder to screw up?
Re: CVS commit: src/sys/miscfs/specfs
On Tue, Apr 13, 2010 at 03:40:24PM +0300, Antti Kantee wrote: On Tue Apr 13 2010 at 12:32:38 +, Andrew Doran wrote: So the kernel of the problem is namespace collisions, correct? Mostly. Though I still think it's not expected that opening a /dev node will load e.g. an exec package or secmodel even if that's what some programmer wants. Would you agree that's it's the kernel programmers responsibility to avoid conflicts? If so how about sprinkling a little process in order to make it harder to screw up? I'd say computers do conflict detection better. So the result of our teeth-pulling so far is: 1. You are concerned about namespace conflicts. I am too. 2. I would be happy to see these managed through documentation and a straightforward approval process for adding modules. 3. You suggest that it would be better for the computer to manage it. Can you suggest an alternative mechanism that will (a) allow us to autoload things that are not anointed device drivers and (b) satisfy your concerns? As an example of something that wants autoloading both as a file system and a driver, see ZFS.
Re: CVS commit: src/sys/dev/ic
On Wed, Mar 31, 2010 at 09:45:40AM -0500, David Young wrote: On Wed, Mar 31, 2010 at 05:09:41AM +, Michael Lorenz wrote: Module Name:src Committed By: macallan Date: Wed Mar 31 05:09:41 UTC 2010 Modified Files: src/sys/dev/ic: pcf8584.c Log Message: Do as OpenSolaris does and read the status register after each write. Now this driver works on my Blade 2500. void pcfiic_write(struct pcfiic_softc *sc, bus_size_t r, u_int8_t v) { + volatile uint8_t junk; bus_space_write_1(sc-sc_iot, sc-sc_ioh, sc-sc_regmap[r], v); + junk = bus_space_read_1(sc-sc_iot, sc-sc_ioh, PCF_S1); bus_space_barrier(sc-sc_iot, sc-sc_ioh, sc-sc_regmap[r], 1, BUS_SPACE_BARRIER_WRITE); } I wonder, does the device need the read, or is the bus_space_barrier() insufficient to flush the write to the device? Additionally, should this read not be after the barrier?
Re: CVS commit: src/sys
On Tue, Feb 23, 2010 at 09:58:25AM +1300, Darran Hunt wrote: static void dtrace_vtime_switch(lwp_t *newl) { #ifdef KDTRACE_HOOKS /* * If DTrace has set the active vtime enum to anything * other than INACTIVE (0), then it should have set the * function to call. */ if (dtrace_vtime_active) { (*dtrace_vtime_switch_func)(newl); } One more comment... If these are not enabled, then presumably you can simply set them to (void *)nullop and skip the conditional? (Although I'm sure somebody will be along shortly to say that casting a function pointer that way is a bad idea :-)
Re: CVS commit: src/sys
On Mon, Feb 22, 2010 at 11:31:31AM -0600, David Young wrote: On Sun, Feb 21, 2010 at 02:11:40AM +, Darran Hunt wrote: Module Name:src Committed By: darran Date: Sun Feb 21 02:11:40 UTC 2010 Modified Files: src/sys/arch/i386/i386: trap.c vector.S src/sys/kern: kern_lwp.c kern_proc.c kern_synch.c src/sys/sys: lwp.h proc.h Added Files: src/sys/sys: dtrace_bsd.h Log Message: Add the DTrace hooks to the kernel (KDTRACE_HOOKS config option). DTrace adds a pointer to the lwp and proc structures which it uses to manage its state. These are opaque from the kernel perspective to keep the kernel free of CDDL code. The state arenas are kmem_alloced and freed as proccesses and threads are created and destoyed. Also add a check for trap06 (privileged/illegal instruction) so that DTrace can check for D scripts that may have triggered the trap so it can clean up after them and resume normal operation. Ok with c...@. Wow, dtrace in the kernel! This is exciting, thanks! #ifdef makes kernel code hard to read. Will you help arrest the accretion of conditional compilation in kern_synch.c by consolidating the conditional compilation in a static subroutine, for example: static void dtrace_vtime_switch(lwp_t *newl) { #ifdef KDTRACE_HOOKS /* * If DTrace has set the active vtime enum to anything * other than INACTIVE (0), then it should have set the * function to call. */ if (dtrace_vtime_active) { (*dtrace_vtime_switch_func)(newl); } #endif How much code do the hooks add? If it is not very much, then just drop the ifdefs completely..
Re: CVS commit: src
On Wed, Nov 18, 2009 at 11:35:15PM +, YAMAMOTO Takashi wrote: hi, On Wed, Nov 18, 2009 at 01:29:05AM +, YAMAMOTO Takashi wrote: hi, Module Name: src Committed By:dyoung Date:Tue Nov 17 18:36:07 UTC 2009 Modified Files: src/distrib/sets/lists/comp: mi src/share/man/man9: Makefile spl.9 Log Message: Describe spllower(9) and splraise(9). these are MD implementation details which are not appropriate to be described in this page. please revert. adding xrefs to splraiseipl and makeiplcookie instead is probably a good idea. I see. I will describe spllower(9) and splraise(9) in an i386 page, instead. imo, for internal functions like them, it's more appropriate to put comments in the source code than man pages. ... or in a book about the kernel. Section 9 describes how to use kernel facilities, not how they work internally. By documenting this item you give the impression of availability and stability, neither of which is provided.
Re: CVS commit: src/sys/kern
On Wed, Aug 26, 2009 at 10:34:47PM +, Manuel Bouyer wrote: Module Name: src Committed By: bouyer Date: Wed Aug 26 22:34:47 UTC 2009 Modified Files: src/sys/kern: uipc_usrreq.c Log Message: In uipc_usrreq(PRU_ACCEPT), grab the unp_streamlock before unp_setpeerlocks(). This fixes a race where, for a short period of time, so-so_lock and so2-so_lock are not sync. This makes solocked2() and solocked() unreliable and cause DIAGNOSTIC kernel panics. This also fixes a possible panic in unp_setaddr() which expects the socket locked. Should fix kern/38968, fix proposed in http://mail-index.netbsd.org/tech-kern/2009/08/17/msg005863.html I think this is wrong and could cause a deadlock. We know that the modus operandi breaks solocked2(), but does it really break solocked()? I think we should revert this one. Thanks.
Re: CVS commit: src/external/cddl/osnet/dist/uts/common/sys
On Mon, Aug 10, 2009 at 10:47:09PM +, Adam Hamsik wrote: Added Files: src/external/cddl/osnet/dist/uts/common/sys: priv_names.h Log Message: Add missing header file. We should tag this file with osnet-20081117 (cvs tag)
Re: CVS commit: src/sys
On Tue, Jun 23, 2009 at 07:36:41PM +, Elad Efrat wrote: Log Message: Move the implementation of vaccess() to genfs_can_access(), in line with the other routines of the same spirit. ... No objections on tech-kern@: http://mail-index.netbsd.org/tech-kern/2009/06/21/msg005310.html 48 hours is not long enough, it has been raised with you before. Are you deliberately trying to piss everyone off? Because it certainly comes over that way.
Re: CVS commit: src/sys
On Sat, May 16, 2009 at 08:29:54AM +, YAMAMOTO Takashi wrote: Modified Files: src/sys/kern: vfs_subr.c src/sys/sys: vnode.h Log Message: put a flag bit into v_usecount to prevent vtryget during getcleanvnode. this fixes the following deadlock. Thanks! How about this to avoid potential sign compare issues? I forgot to e-mail you about it earlier. @@ -252,8 +252,8 @@ typedef struct vnode vnode_t; /* * v_usecount; see the comment in vfs_subr.c */ -#defineVC_XLOCK0x8000 -#defineVC_MASK 0x7fff +#defineVC_XLOCK0x4000 +#defineVC_MASK (0x ~VC_XLOCK)
Re: CVS commit: src
On Sat, Apr 25, 2009 at 09:42:30PM +0100, Mindaugas Rasiukevicius wrote: Module Name:src Committed By: ad Date: Sun Apr 19 14:11:38 UTC 2009 ... x86: - Make intr_establish, intr_disestablish safe to use when !cold. - Distribute hardware interrupts among the CPUs, instead of directing everything to the boot CPU. This is cool! Just a shame it doesn't work properly yet. The balancing code is OK I think, something in the guts of APIC/SPL handling is busted. From sys/arch/x86/x86/intr.c: /* * A simple round-robin allocator to assign interrupts to CPUs. */ static int __noinline intr_allocate_slot(struct pic *pic, int pin, int level, struct cpu_info **cip, int *index, int *idt_slot) { From what I read, it is no longer round-robin, right? Right, the comment is stale.
Re: CVS commit: src/sys/dev/acpi
On Wed, Apr 08, 2009 at 12:15:45AM +, David Young wrote: Modified Files: src/sys/dev/acpi: acpi_timer.c acpi_timer.h Log Message: Add acpitimer_detach() to eventually support acpi(4) detachment. tc_detach() does not work correctly on a running system. It can race with binuptime(), so the timecounter may still be in use when it is destroyed. One solution would be to use the passive serialization patch that I posted to tech-k...@. I believe rmind@ is working on it.
Re: CVS commit: src/sys/dev/acpi/acpica
On Tue, Mar 31, 2009 at 05:17:47PM +, Matthias Drochner wrote: Module Name: src Committed By: drochner Date: Tue Mar 31 17:17:47 UTC 2009 Modified Files: src/sys/dev/acpi/acpica: OsdSchedule.c OsdSynch.c Log Message: avoid tsleep also during shutdown (and in particular ACPI poweroff), should fix PR kern/39141 by Takahiro Kambe and PR port-i386/41110 by Reinoud Zandijk Thank you for fixing an annoying panic. However it's one of many hacks to be applied to this. There's no good reason for interrupts to be off while the shutdown hooks are being processed.
Re: CVS commit: src/sys/dev/sbus
On Fri, Mar 27, 2009 at 12:25:41PM +, Izumi Tsutsui wrote: Log Message: Use bus_space(9) to access registers. SETREG() macro using bogus casts against packed structures doesn't work on gcc4. (no character on screen) See also: http://mail-index.NetBSD.org/port-sparc/2003/11/11/0002.html It has been a long time, but from what I remember SETREG() was an invention of mine to work around either a compiler or code bug. Maybe bus_space does the same.
Re: CVS commit: src/sys/dev/sbus
On Fri, Mar 27, 2009 at 04:31:33PM -0400, Michael wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hello, On Mar 27, 2009, at 9:07 AM, Izumi Tsutsui wrote: a...@netbsd.org wrote: On Fri, Mar 27, 2009 at 12:25:41PM +, Izumi Tsutsui wrote: Log Message: Use bus_space(9) to access registers. SETREG() macro using bogus casts against packed structures doesn't work on gcc4. (no character on screen) See also: http://mail-index.NetBSD.org/port-sparc/2003/11/11/0002.html It has been a long time, but from what I remember SETREG() was an invention of mine to work around either a compiler or code bug. Maybe bus_space does the same. I'm not sure if it's a compiler bug or not, but SETREG() doesn't work on gcc4 while it's confirmed working on gcc3. (as the noted in the above mail, it looks generating byte access code) Removing __packed might also help, but bus_space(9) just works and it's a right way to go, I think. I strongly agree - I've been trying to get our zx driver to work for a while but got sidetracked by other stuff ( mostly sgimips-related ) - thanks for doing this. Writing an accelerated Xorg driver is next on my todo list ( after adding wscons support to zx ) It worked for the console when I checked it in (haven't touched it since). I think I remember now what SETREG() might have been about. The compiler was generating sub-word writes, or something along those lines.
Re: CVS commit: othersrc/zfs/external/cddl/osnet/dist
On Thu, Mar 26, 2009 at 10:21:49PM +, Andrew Doran wrote: On Fri, Mar 27, 2009 at 09:14:40AM +1100, Simon Burge wrote: +#ifdef __NetBSD__ +#include uvm/uvm.h +#definebtop(x) ((x) * PAGE_SIZE) [ ... ] Isn't that working out pages to bytes and not bytes to pages ? Unless btop() means something non-obvious in Solaris land... Probably, please fix ;-) By the way, this is basically the tarball that I posted to tech-kern in January: it doesn't work yet. Interest has been expressed in finishing it.