sched_ule.c (e15046952d71a1f9ab3b16f9cda66577b7787078) sched_ule.c (61322a0a8affb0c41dcf441ea331f041e15879ff)
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3 *
4 * Copyright (c) 2002-2007, Jeffrey Roberson <jeff@freebsd.org>
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

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

67#include <sys/sbuf.h>
68
69#ifdef HWPMC_HOOKS
70#include <sys/pmckern.h>
71#endif
72
73#ifdef KDTRACE_HOOKS
74#include <sys/dtrace_bsd.h>
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3 *
4 * Copyright (c) 2002-2007, Jeffrey Roberson <jeff@freebsd.org>
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

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

67#include <sys/sbuf.h>
68
69#ifdef HWPMC_HOOKS
70#include <sys/pmckern.h>
71#endif
72
73#ifdef KDTRACE_HOOKS
74#include <sys/dtrace_bsd.h>
75int dtrace_vtime_active;
75int __read_mostly dtrace_vtime_active;
76dtrace_vtime_switch_func_t dtrace_vtime_switch_func;
77#endif
78
79#include <machine/cpu.h>
80#include <machine/smp.h>
81
82#define KTR_ULE 0
83

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

201/*
202 * tickincr: Converts a stathz tick into a hz domain scaled by
203 * the shift factor. Without the shift the error rate
204 * due to rounding would be unacceptably high.
205 * realstathz: stathz is sometimes 0 and run off of hz.
206 * sched_slice: Runtime of each thread before rescheduling.
207 * preempt_thresh: Priority threshold for preemption and remote IPIs.
208 */
76dtrace_vtime_switch_func_t dtrace_vtime_switch_func;
77#endif
78
79#include <machine/cpu.h>
80#include <machine/smp.h>
81
82#define KTR_ULE 0
83

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

201/*
202 * tickincr: Converts a stathz tick into a hz domain scaled by
203 * the shift factor. Without the shift the error rate
204 * due to rounding would be unacceptably high.
205 * realstathz: stathz is sometimes 0 and run off of hz.
206 * sched_slice: Runtime of each thread before rescheduling.
207 * preempt_thresh: Priority threshold for preemption and remote IPIs.
208 */
209static int sched_interact = SCHED_INTERACT_THRESH;
210static int tickincr = 8 << SCHED_TICK_SHIFT;
211static int realstathz = 127; /* reset during boot. */
212static int sched_slice = 10; /* reset during boot. */
213static int sched_slice_min = 1; /* reset during boot. */
209static int __read_mostly sched_interact = SCHED_INTERACT_THRESH;
210static int __read_mostly tickincr = 8 << SCHED_TICK_SHIFT;
211static int __read_mostly realstathz = 127; /* reset during boot. */
212static int __read_mostly sched_slice = 10; /* reset during boot. */
213static int __read_mostly sched_slice_min = 1; /* reset during boot. */
214#ifdef PREEMPTION
215#ifdef FULL_PREEMPTION
214#ifdef PREEMPTION
215#ifdef FULL_PREEMPTION
216static int preempt_thresh = PRI_MAX_IDLE;
216static int __read_mostly preempt_thresh = PRI_MAX_IDLE;
217#else
217#else
218static int preempt_thresh = PRI_MIN_KERN;
218static int __read_mostly preempt_thresh = PRI_MIN_KERN;
219#endif
220#else
219#endif
220#else
221static int preempt_thresh = 0;
221static int __read_mostly preempt_thresh = 0;
222#endif
222#endif
223static int static_boost = PRI_MIN_BATCH;
224static int sched_idlespins = 10000;
225static int sched_idlespinthresh = -1;
223static int __read_mostly static_boost = PRI_MIN_BATCH;
224static int __read_mostly sched_idlespins = 10000;
225static int __read_mostly sched_idlespinthresh = -1;
226
227/*
228 * tdq - per processor runqs and statistics. All fields are protected by the
229 * tdq_lock. The load and lowpri may be accessed without to avoid excess
230 * locking in sched_pickcpu();
231 */
232struct tdq {
233 /*

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

257#endif
258} __aligned(64);
259
260/* Idle thread states and config. */
261#define TDQ_RUNNING 1
262#define TDQ_IDLE 2
263
264#ifdef SMP
226
227/*
228 * tdq - per processor runqs and statistics. All fields are protected by the
229 * tdq_lock. The load and lowpri may be accessed without to avoid excess
230 * locking in sched_pickcpu();
231 */
232struct tdq {
233 /*

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

257#endif
258} __aligned(64);
259
260/* Idle thread states and config. */
261#define TDQ_RUNNING 1
262#define TDQ_IDLE 2
263
264#ifdef SMP
265struct cpu_group *cpu_top; /* CPU topology */
265struct cpu_group __read_mostly *cpu_top; /* CPU topology */
266
267#define SCHED_AFFINITY_DEFAULT (max(1, hz / 1000))
268#define SCHED_AFFINITY(ts, t) ((ts)->ts_rltick > ticks - ((t) * affinity))
269
270/*
271 * Run-time tunables.
272 */
273static int rebalance = 1;
274static int balance_interval = 128; /* Default set in sched_initticks(). */
266
267#define SCHED_AFFINITY_DEFAULT (max(1, hz / 1000))
268#define SCHED_AFFINITY(ts, t) ((ts)->ts_rltick > ticks - ((t) * affinity))
269
270/*
271 * Run-time tunables.
272 */
273static int rebalance = 1;
274static int balance_interval = 128; /* Default set in sched_initticks(). */
275static int affinity;
276static int steal_idle = 1;
277static int steal_thresh = 2;
278static int always_steal = 0;
279static int trysteal_limit = 2;
275static int __read_mostly affinity;
276static int __read_mostly steal_idle = 1;
277static int __read_mostly steal_thresh = 2;
278static int __read_mostly always_steal = 0;
279static int __read_mostly trysteal_limit = 2;
280
281/*
282 * One thread queue per processor.
283 */
280
281/*
282 * One thread queue per processor.
283 */
284static struct tdq *balance_tdq;
284static struct tdq __read_mostly *balance_tdq;
285static int balance_ticks;
286DPCPU_DEFINE_STATIC(struct tdq, tdq);
287DPCPU_DEFINE_STATIC(uint32_t, randomval);
288
289#define TDQ_SELF() ((struct tdq *)PCPU_GET(sched))
290#define TDQ_CPU(x) (DPCPU_ID_PTR((x), tdq))
291#define TDQ_ID(x) ((x)->tdq_id)
292#else /* !SMP */

--- 2838 unchanged lines hidden ---
285static int balance_ticks;
286DPCPU_DEFINE_STATIC(struct tdq, tdq);
287DPCPU_DEFINE_STATIC(uint32_t, randomval);
288
289#define TDQ_SELF() ((struct tdq *)PCPU_GET(sched))
290#define TDQ_CPU(x) (DPCPU_ID_PTR((x), tdq))
291#define TDQ_ID(x) ((x)->tdq_id)
292#else /* !SMP */

--- 2838 unchanged lines hidden ---