sched_ule.c (172887) | sched_ule.c (173600) |
---|---|
1/*- 2 * Copyright (c) 2002-2007, Jeffrey Roberson <jeff@freebsd.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 22 unchanged lines hidden (view full) --- 31 * 32 * etymology: 33 * ULE is the last three letters in schedule. It owes its name to a 34 * generic user created for a scheduling system by Paul Mikesell at 35 * Isilon Systems and a general lack of creativity on the part of the author. 36 */ 37 38#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2002-2007, Jeffrey Roberson <jeff@freebsd.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 22 unchanged lines hidden (view full) --- 31 * 32 * etymology: 33 * ULE is the last three letters in schedule. It owes its name to a 34 * generic user created for a scheduling system by Paul Mikesell at 35 * Isilon Systems and a general lack of creativity on the part of the author. 36 */ 37 38#include <sys/cdefs.h> |
39__FBSDID("$FreeBSD: head/sys/kern/sched_ule.c 172887 2007-10-23 00:52:25Z grehan $"); | 39__FBSDID("$FreeBSD: head/sys/kern/sched_ule.c 173600 2007-11-14 06:21:24Z julian $"); |
40 41#include "opt_hwpmc_hooks.h" 42#include "opt_sched.h" 43 44#include <sys/param.h> 45#include <sys/systm.h> 46#include <sys/kdb.h> 47#include <sys/kernel.h> --- 286 unchanged lines hidden (view full) --- 334 printf("\t\trunq bits %d 0x%zx\n", 335 i, rq->rq_status.rqb_bits[i]); 336 for (j = 0; j < RQB_BPW; j++) 337 if (rq->rq_status.rqb_bits[i] & (1ul << j)) { 338 pri = j + (i << RQB_L2BPW); 339 rqh = &rq->rq_queues[pri]; 340 TAILQ_FOREACH(ts, rqh, ts_procq) { 341 printf("\t\t\ttd %p(%s) priority %d rqindex %d pri %d\n", | 40 41#include "opt_hwpmc_hooks.h" 42#include "opt_sched.h" 43 44#include <sys/param.h> 45#include <sys/systm.h> 46#include <sys/kdb.h> 47#include <sys/kernel.h> --- 286 unchanged lines hidden (view full) --- 334 printf("\t\trunq bits %d 0x%zx\n", 335 i, rq->rq_status.rqb_bits[i]); 336 for (j = 0; j < RQB_BPW; j++) 337 if (rq->rq_status.rqb_bits[i] & (1ul << j)) { 338 pri = j + (i << RQB_L2BPW); 339 rqh = &rq->rq_queues[pri]; 340 TAILQ_FOREACH(ts, rqh, ts_procq) { 341 printf("\t\t\ttd %p(%s) priority %d rqindex %d pri %d\n", |
342 ts->ts_thread, ts->ts_thread->td_proc->p_comm, ts->ts_thread->td_priority, ts->ts_rqindex, pri); | 342 ts->ts_thread, ts->ts_thread->td_name, ts->ts_thread->td_priority, ts->ts_rqindex, pri); |
343 } 344 } 345 } 346} 347 348/* 349 * Print the status of a per-cpu thread queue. Should be a ddb show cmd. 350 */ --- 1244 unchanged lines hidden (view full) --- 1595 * functions. 1596 */ 1597static void 1598sched_thread_priority(struct thread *td, u_char prio) 1599{ 1600 struct td_sched *ts; 1601 1602 CTR6(KTR_SCHED, "sched_prio: %p(%s) prio %d newprio %d by %p(%s)", | 343 } 344 } 345 } 346} 347 348/* 349 * Print the status of a per-cpu thread queue. Should be a ddb show cmd. 350 */ --- 1244 unchanged lines hidden (view full) --- 1595 * functions. 1596 */ 1597static void 1598sched_thread_priority(struct thread *td, u_char prio) 1599{ 1600 struct td_sched *ts; 1601 1602 CTR6(KTR_SCHED, "sched_prio: %p(%s) prio %d newprio %d by %p(%s)", |
1603 td, td->td_proc->p_comm, td->td_priority, prio, curthread, 1604 curthread->td_proc->p_comm); | 1603 td, td->td_name, td->td_priority, prio, curthread, 1604 curthread->td_name); |
1605 ts = td->td_sched; 1606 THREAD_LOCK_ASSERT(td, MA_OWNED); 1607 if (td->td_priority == prio) 1608 return; 1609 1610 if (TD_ON_RUNQ(td) && prio < td->td_priority) { 1611 /* 1612 * If the priority has been elevated due to priority --- 469 unchanged lines hidden (view full) --- 2082 * Return some of the child's priority and interactivity to the parent. 2083 */ 2084void 2085sched_exit(struct proc *p, struct thread *child) 2086{ 2087 struct thread *td; 2088 2089 CTR3(KTR_SCHED, "sched_exit: %p(%s) prio %d", | 1605 ts = td->td_sched; 1606 THREAD_LOCK_ASSERT(td, MA_OWNED); 1607 if (td->td_priority == prio) 1608 return; 1609 1610 if (TD_ON_RUNQ(td) && prio < td->td_priority) { 1611 /* 1612 * If the priority has been elevated due to priority --- 469 unchanged lines hidden (view full) --- 2082 * Return some of the child's priority and interactivity to the parent. 2083 */ 2084void 2085sched_exit(struct proc *p, struct thread *child) 2086{ 2087 struct thread *td; 2088 2089 CTR3(KTR_SCHED, "sched_exit: %p(%s) prio %d", |
2090 child, child->td_proc->p_comm, child->td_priority); | 2090 child, child->td_name, child->td_priority); |
2091 2092 PROC_SLOCK_ASSERT(p, MA_OWNED); 2093 td = FIRST_THREAD_IN_PROC(p); 2094 sched_exit_thread(td, child); 2095} 2096 2097/* 2098 * Penalize another thread for the time spent on this one. This helps to 2099 * worsen the priority and interactivity of processes which schedule batch 2100 * jobs such as make. This has little effect on the make process itself but 2101 * causes new processes spawned by it to receive worse scores immediately. 2102 */ 2103void 2104sched_exit_thread(struct thread *td, struct thread *child) 2105{ 2106 2107 CTR3(KTR_SCHED, "sched_exit_thread: %p(%s) prio %d", | 2091 2092 PROC_SLOCK_ASSERT(p, MA_OWNED); 2093 td = FIRST_THREAD_IN_PROC(p); 2094 sched_exit_thread(td, child); 2095} 2096 2097/* 2098 * Penalize another thread for the time spent on this one. This helps to 2099 * worsen the priority and interactivity of processes which schedule batch 2100 * jobs such as make. This has little effect on the make process itself but 2101 * causes new processes spawned by it to receive worse scores immediately. 2102 */ 2103void 2104sched_exit_thread(struct thread *td, struct thread *child) 2105{ 2106 2107 CTR3(KTR_SCHED, "sched_exit_thread: %p(%s) prio %d", |
2108 child, child->td_proc->p_comm, child->td_priority); | 2108 child, child->td_name, child->td_priority); |
2109 2110#ifdef KSE 2111 /* 2112 * KSE forks and exits so often that this penalty causes short-lived 2113 * threads to always be non-interactive. This causes mozilla to 2114 * crawl under load. 2115 */ 2116 if ((td->td_pflags & TDP_SA) && td->td_proc == child->td_proc) --- 274 unchanged lines hidden (view full) --- 2391{ 2392 struct td_sched *ts; 2393 struct tdq *tdq; 2394#ifdef SMP 2395 int cpuid; 2396 int cpu; 2397#endif 2398 CTR5(KTR_SCHED, "sched_add: %p(%s) prio %d by %p(%s)", | 2109 2110#ifdef KSE 2111 /* 2112 * KSE forks and exits so often that this penalty causes short-lived 2113 * threads to always be non-interactive. This causes mozilla to 2114 * crawl under load. 2115 */ 2116 if ((td->td_pflags & TDP_SA) && td->td_proc == child->td_proc) --- 274 unchanged lines hidden (view full) --- 2391{ 2392 struct td_sched *ts; 2393 struct tdq *tdq; 2394#ifdef SMP 2395 int cpuid; 2396 int cpu; 2397#endif 2398 CTR5(KTR_SCHED, "sched_add: %p(%s) prio %d by %p(%s)", |
2399 td, td->td_proc->p_comm, td->td_priority, curthread, 2400 curthread->td_proc->p_comm); | 2399 td, td->td_name, td->td_priority, curthread, 2400 curthread->td_name); |
2401 THREAD_LOCK_ASSERT(td, MA_OWNED); 2402 ts = td->td_sched; 2403 /* 2404 * Recalculate the priority before we select the target cpu or 2405 * run-queue. 2406 */ 2407 if (PRI_BASE(td->td_pri_class) == PRI_TIMESHARE) 2408 sched_priority(td); --- 36 unchanged lines hidden (view full) --- 2445 */ 2446void 2447sched_rem(struct thread *td) 2448{ 2449 struct tdq *tdq; 2450 struct td_sched *ts; 2451 2452 CTR5(KTR_SCHED, "sched_rem: %p(%s) prio %d by %p(%s)", | 2401 THREAD_LOCK_ASSERT(td, MA_OWNED); 2402 ts = td->td_sched; 2403 /* 2404 * Recalculate the priority before we select the target cpu or 2405 * run-queue. 2406 */ 2407 if (PRI_BASE(td->td_pri_class) == PRI_TIMESHARE) 2408 sched_priority(td); --- 36 unchanged lines hidden (view full) --- 2445 */ 2446void 2447sched_rem(struct thread *td) 2448{ 2449 struct tdq *tdq; 2450 struct td_sched *ts; 2451 2452 CTR5(KTR_SCHED, "sched_rem: %p(%s) prio %d by %p(%s)", |
2453 td, td->td_proc->p_comm, td->td_priority, curthread, 2454 curthread->td_proc->p_comm); | 2453 td, td->td_name, td->td_priority, curthread, 2454 curthread->td_name); |
2455 ts = td->td_sched; 2456 tdq = TDQ_CPU(ts->ts_cpu); 2457 TDQ_LOCK_ASSERT(tdq, MA_OWNED); 2458 MPASS(td->td_lock == TDQ_LOCKPTR(tdq)); 2459 KASSERT(TD_ON_RUNQ(td), 2460 ("sched_rem: thread not on run queue")); 2461 tdq_runq_rem(tdq, ts); 2462 tdq_load_rem(tdq, ts); --- 234 unchanged lines hidden --- | 2455 ts = td->td_sched; 2456 tdq = TDQ_CPU(ts->ts_cpu); 2457 TDQ_LOCK_ASSERT(tdq, MA_OWNED); 2458 MPASS(td->td_lock == TDQ_LOCKPTR(tdq)); 2459 KASSERT(TD_ON_RUNQ(td), 2460 ("sched_rem: thread not on run queue")); 2461 tdq_runq_rem(tdq, ts); 2462 tdq_load_rem(tdq, ts); --- 234 unchanged lines hidden --- |