kern_racct.c (243088) | kern_racct.c (248298) |
---|---|
1/*- 2 * Copyright (c) 2010 The FreeBSD Foundation 3 * All rights reserved. 4 * 5 * This software was developed by Edward Tomasz Napierala under sponsorship 6 * from the FreeBSD Foundation. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 12 unchanged lines hidden (view full) --- 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * | 1/*- 2 * Copyright (c) 2010 The FreeBSD Foundation 3 * All rights reserved. 4 * 5 * This software was developed by Edward Tomasz Napierala under sponsorship 6 * from the FreeBSD Foundation. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 12 unchanged lines hidden (view full) --- 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * |
29 * $FreeBSD: head/sys/kern/kern_racct.c 243088 2012-11-15 15:55:49Z trasz $ | 29 * $FreeBSD: head/sys/kern/kern_racct.c 248298 2013-03-14 23:20:18Z trasz $ |
30 */ 31 32#include <sys/cdefs.h> | 30 */ 31 32#include <sys/cdefs.h> |
33__FBSDID("$FreeBSD: head/sys/kern/kern_racct.c 243088 2012-11-15 15:55:49Z trasz $"); | 33__FBSDID("$FreeBSD: head/sys/kern/kern_racct.c 248298 2013-03-14 23:20:18Z trasz $"); |
34 35#include "opt_kdtrace.h" 36#include "opt_sched.h" 37 38#include <sys/param.h> 39#include <sys/systm.h> 40#include <sys/eventhandler.h> 41#include <sys/jail.h> --- 986 unchanged lines hidden (view full) --- 1028 * low %cpu utilization to improve interactivity. 1029 */ 1030 if (((p->p_flag & (P_SYSTEM | P_KTHREAD)) != 0) || 1031 (p->p_racct->r_resources[RACCT_PCTCPU] <= pcpu_threshold)) 1032 return; 1033 p->p_throttled = 1; 1034 1035 FOREACH_THREAD_IN_PROC(p, td) { | 34 35#include "opt_kdtrace.h" 36#include "opt_sched.h" 37 38#include <sys/param.h> 39#include <sys/systm.h> 40#include <sys/eventhandler.h> 41#include <sys/jail.h> --- 986 unchanged lines hidden (view full) --- 1028 * low %cpu utilization to improve interactivity. 1029 */ 1030 if (((p->p_flag & (P_SYSTEM | P_KTHREAD)) != 0) || 1031 (p->p_racct->r_resources[RACCT_PCTCPU] <= pcpu_threshold)) 1032 return; 1033 p->p_throttled = 1; 1034 1035 FOREACH_THREAD_IN_PROC(p, td) { |
1036 thread_lock(td); |
|
1036 switch (td->td_state) { 1037 case TDS_RUNQ: 1038 /* 1039 * If the thread is on the scheduler run-queue, we can 1040 * not just remove it from there. So we set the flag 1041 * TDF_NEEDRESCHED for the thread, so that once it is 1042 * running, it is taken off the cpu as soon as possible. 1043 */ | 1037 switch (td->td_state) { 1038 case TDS_RUNQ: 1039 /* 1040 * If the thread is on the scheduler run-queue, we can 1041 * not just remove it from there. So we set the flag 1042 * TDF_NEEDRESCHED for the thread, so that once it is 1043 * running, it is taken off the cpu as soon as possible. 1044 */ |
1044 thread_lock(td); | |
1045 td->td_flags |= TDF_NEEDRESCHED; | 1045 td->td_flags |= TDF_NEEDRESCHED; |
1046 thread_unlock(td); | |
1047 break; 1048 case TDS_RUNNING: 1049 /* 1050 * If the thread is running, we request a context 1051 * switch for it by setting the TDF_NEEDRESCHED flag. 1052 */ | 1046 break; 1047 case TDS_RUNNING: 1048 /* 1049 * If the thread is running, we request a context 1050 * switch for it by setting the TDF_NEEDRESCHED flag. 1051 */ |
1053 thread_lock(td); | |
1054 td->td_flags |= TDF_NEEDRESCHED; 1055#ifdef SMP 1056 cpuid = td->td_oncpu; 1057 if ((cpuid != NOCPU) && (td != curthread)) 1058 ipi_cpu(cpuid, IPI_AST); 1059#endif | 1052 td->td_flags |= TDF_NEEDRESCHED; 1053#ifdef SMP 1054 cpuid = td->td_oncpu; 1055 if ((cpuid != NOCPU) && (td != curthread)) 1056 ipi_cpu(cpuid, IPI_AST); 1057#endif |
1060 thread_unlock(td); | |
1061 break; 1062 default: 1063 break; 1064 } | 1058 break; 1059 default: 1060 break; 1061 } |
1062 thread_unlock(td); |
|
1065 } 1066} 1067 1068static void 1069racct_proc_wakeup(struct proc *p) 1070{ 1071 PROC_LOCK_ASSERT(p, MA_OWNED); 1072 --- 221 unchanged lines hidden --- | 1063 } 1064} 1065 1066static void 1067racct_proc_wakeup(struct proc *p) 1068{ 1069 PROC_LOCK_ASSERT(p, MA_OWNED); 1070 --- 221 unchanged lines hidden --- |