Deleted Added
full compact
sched_4bsd.c (288463) sched_4bsd.c (260817)
1/*-
2 * Copyright (c) 1982, 1986, 1990, 1991, 1993
3 * The Regents of the University of California. All rights reserved.
4 * (c) UNIX System Laboratories, Inc.
5 * All or some portions of this file are derived from material licensed
6 * to the University of California by American Telephone and Telegraph
7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
8 * the permission of UNIX System Laboratories, Inc.

--- 19 unchanged lines hidden (view full) ---

28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
33 */
34
35#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1982, 1986, 1990, 1991, 1993
3 * The Regents of the University of California. All rights reserved.
4 * (c) UNIX System Laboratories, Inc.
5 * All or some portions of this file are derived from material licensed
6 * to the University of California by American Telephone and Telegraph
7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
8 * the permission of UNIX System Laboratories, Inc.

--- 19 unchanged lines hidden (view full) ---

28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
33 */
34
35#include <sys/cdefs.h>
36__FBSDID("$FreeBSD: stable/10/sys/kern/sched_4bsd.c 288463 2015-10-01 21:54:43Z jhb $");
36__FBSDID("$FreeBSD: stable/10/sys/kern/sched_4bsd.c 260817 2014-01-17 10:58:59Z avg $");
37
38#include "opt_hwpmc_hooks.h"
39#include "opt_sched.h"
40#include "opt_kdtrace.h"
41
42#include <sys/param.h>
43#include <sys/systm.h>
44#include <sys/cpuset.h>

--- 743 unchanged lines hidden (view full) ---

788 sched_fork_thread(td, childtd);
789}
790
791void
792sched_fork_thread(struct thread *td, struct thread *childtd)
793{
794 struct td_sched *ts;
795
37
38#include "opt_hwpmc_hooks.h"
39#include "opt_sched.h"
40#include "opt_kdtrace.h"
41
42#include <sys/param.h>
43#include <sys/systm.h>
44#include <sys/cpuset.h>

--- 743 unchanged lines hidden (view full) ---

788 sched_fork_thread(td, childtd);
789}
790
791void
792sched_fork_thread(struct thread *td, struct thread *childtd)
793{
794 struct td_sched *ts;
795
796 childtd->td_oncpu = NOCPU;
797 childtd->td_lastcpu = NOCPU;
798 childtd->td_estcpu = td->td_estcpu;
799 childtd->td_lock = &sched_lock;
800 childtd->td_cpuset = cpuset_ref(td->td_cpuset);
801 childtd->td_priority = childtd->td_base_pri;
802 ts = childtd->td_sched;
803 bzero(ts, sizeof(*ts));
804 ts->ts_flags |= (td->td_sched->ts_flags & TSF_AFFINITY);
805 ts->ts_slice = 1;

--- 174 unchanged lines hidden (view full) ---

980 mtx_lock_spin(&sched_lock);
981 tmtx = thread_lock_block(td);
982 }
983
984 if ((td->td_flags & TDF_NOLOAD) == 0)
985 sched_load_rem();
986
987 td->td_lastcpu = td->td_oncpu;
796 childtd->td_estcpu = td->td_estcpu;
797 childtd->td_lock = &sched_lock;
798 childtd->td_cpuset = cpuset_ref(td->td_cpuset);
799 childtd->td_priority = childtd->td_base_pri;
800 ts = childtd->td_sched;
801 bzero(ts, sizeof(*ts));
802 ts->ts_flags |= (td->td_sched->ts_flags & TSF_AFFINITY);
803 ts->ts_slice = 1;

--- 174 unchanged lines hidden (view full) ---

978 mtx_lock_spin(&sched_lock);
979 tmtx = thread_lock_block(td);
980 }
981
982 if ((td->td_flags & TDF_NOLOAD) == 0)
983 sched_load_rem();
984
985 td->td_lastcpu = td->td_oncpu;
988 preempted = !((td->td_flags & TDF_SLICEEND) ||
989 (flags & SWT_RELINQUISH));
986 preempted = !(td->td_flags & TDF_SLICEEND);
990 td->td_flags &= ~(TDF_NEEDRESCHED | TDF_SLICEEND);
991 td->td_owepreempt = 0;
992 td->td_oncpu = NOCPU;
993
994 /*
995 * At the last moment, if this thread is still marked RUNNING,
996 * then put it back on the run queue as it has not been suspended
997 * or stopped or any thing else similar. We never put the idle

--- 33 unchanged lines hidden (view full) ---

1031 }
1032
1033 if (td != newtd) {
1034#ifdef HWPMC_HOOKS
1035 if (PMC_PROC_IS_USING_PMCS(td->td_proc))
1036 PMC_SWITCH_CONTEXT(td, PMC_FN_CSW_OUT);
1037#endif
1038
987 td->td_flags &= ~(TDF_NEEDRESCHED | TDF_SLICEEND);
988 td->td_owepreempt = 0;
989 td->td_oncpu = NOCPU;
990
991 /*
992 * At the last moment, if this thread is still marked RUNNING,
993 * then put it back on the run queue as it has not been suspended
994 * or stopped or any thing else similar. We never put the idle

--- 33 unchanged lines hidden (view full) ---

1028 }
1029
1030 if (td != newtd) {
1031#ifdef HWPMC_HOOKS
1032 if (PMC_PROC_IS_USING_PMCS(td->td_proc))
1033 PMC_SWITCH_CONTEXT(td, PMC_FN_CSW_OUT);
1034#endif
1035
1039 SDT_PROBE2(sched, , , off__cpu, newtd, newtd->td_proc);
1036 SDT_PROBE2(sched, , , off__cpu, td, td->td_proc);
1040
1041 /* I feel sleepy */
1042 lock_profile_release_lock(&sched_lock.lock_object);
1043#ifdef KDTRACE_HOOKS
1044 /*
1045 * If DTrace has set the active vtime enum to anything
1046 * other than INACTIVE (0), then it should have set the
1047 * function to call.

--- 535 unchanged lines hidden (view full) ---

1583{
1584 struct td_sched *ts;
1585
1586 THREAD_LOCK_ASSERT(td, MA_OWNED);
1587 ts = td->td_sched;
1588 return (ts->ts_pctcpu);
1589}
1590
1037
1038 /* I feel sleepy */
1039 lock_profile_release_lock(&sched_lock.lock_object);
1040#ifdef KDTRACE_HOOKS
1041 /*
1042 * If DTrace has set the active vtime enum to anything
1043 * other than INACTIVE (0), then it should have set the
1044 * function to call.

--- 535 unchanged lines hidden (view full) ---

1580{
1581 struct td_sched *ts;
1582
1583 THREAD_LOCK_ASSERT(td, MA_OWNED);
1584 ts = td->td_sched;
1585 return (ts->ts_pctcpu);
1586}
1587
1591#ifdef RACCT
1588#ifdef RACCT
1592/*
1593 * Calculates the contribution to the thread cpu usage for the latest
1594 * (unfinished) second.
1595 */
1596fixpt_t
1597sched_pctcpu_delta(struct thread *td)
1598{
1599 struct td_sched *ts;

--- 69 unchanged lines hidden (view full) ---

1669 if (td == NULL) {
1670 mtx_lock_spin(&sched_lock);
1671 spinlock_exit();
1672 PCPU_SET(switchtime, cpu_ticks());
1673 PCPU_SET(switchticks, ticks);
1674 } else {
1675 lock_profile_release_lock(&sched_lock.lock_object);
1676 MPASS(td->td_lock == &sched_lock);
1589/*
1590 * Calculates the contribution to the thread cpu usage for the latest
1591 * (unfinished) second.
1592 */
1593fixpt_t
1594sched_pctcpu_delta(struct thread *td)
1595{
1596 struct td_sched *ts;

--- 69 unchanged lines hidden (view full) ---

1666 if (td == NULL) {
1667 mtx_lock_spin(&sched_lock);
1668 spinlock_exit();
1669 PCPU_SET(switchtime, cpu_ticks());
1670 PCPU_SET(switchticks, ticks);
1671 } else {
1672 lock_profile_release_lock(&sched_lock.lock_object);
1673 MPASS(td->td_lock == &sched_lock);
1677 td->td_lastcpu = td->td_oncpu;
1678 td->td_oncpu = NOCPU;
1679 }
1680 mtx_assert(&sched_lock, MA_OWNED);
1681 KASSERT(curthread->td_md.md_spinlock_count == 1, ("invalid count"));
1682 cpu_throw(td, choosethread()); /* doesn't return */
1683}
1684
1685void
1686sched_fork_exit(struct thread *td)

--- 103 unchanged lines hidden ---
1674 }
1675 mtx_assert(&sched_lock, MA_OWNED);
1676 KASSERT(curthread->td_md.md_spinlock_count == 1, ("invalid count"));
1677 cpu_throw(td, choosethread()); /* doesn't return */
1678}
1679
1680void
1681sched_fork_exit(struct thread *td)

--- 103 unchanged lines hidden ---