hrtimer.c (0ab6a3ddbad40ef5b6b8c2353fd53fa4ecf9c479) | hrtimer.c (f5c2f0215e36d76fbb9605283dd7535af09f5770) |
---|---|
1// SPDX-License-Identifier: GPL-2.0 2/* 3 * Copyright(C) 2005-2006, Thomas Gleixner <tglx@linutronix.de> 4 * Copyright(C) 2005-2007, Red Hat, Inc., Ingo Molnar 5 * Copyright(C) 2006-2007 Timesys Corp., Thomas Gleixner 6 * 7 * High-resolution kernel timers 8 * --- 1261 unchanged lines hidden (view full) --- 1270 WARN(1, "Invalid clockid %d. Using MONOTONIC\n", clock_id); 1271 return HRTIMER_BASE_MONOTONIC; 1272} 1273 1274static void __hrtimer_init(struct hrtimer *timer, clockid_t clock_id, 1275 enum hrtimer_mode mode) 1276{ 1277 bool softtimer = !!(mode & HRTIMER_MODE_SOFT); | 1// SPDX-License-Identifier: GPL-2.0 2/* 3 * Copyright(C) 2005-2006, Thomas Gleixner <tglx@linutronix.de> 4 * Copyright(C) 2005-2007, Red Hat, Inc., Ingo Molnar 5 * Copyright(C) 2006-2007 Timesys Corp., Thomas Gleixner 6 * 7 * High-resolution kernel timers 8 * --- 1261 unchanged lines hidden (view full) --- 1270 WARN(1, "Invalid clockid %d. Using MONOTONIC\n", clock_id); 1271 return HRTIMER_BASE_MONOTONIC; 1272} 1273 1274static void __hrtimer_init(struct hrtimer *timer, clockid_t clock_id, 1275 enum hrtimer_mode mode) 1276{ 1277 bool softtimer = !!(mode & HRTIMER_MODE_SOFT); |
1278 int base = softtimer ? HRTIMER_MAX_CLOCK_BASES / 2 : 0; | |
1279 struct hrtimer_cpu_base *cpu_base; | 1278 struct hrtimer_cpu_base *cpu_base; |
1279 int base; |
|
1280 | 1280 |
1281 /* 1282 * On PREEMPT_RT enabled kernels hrtimers which are not explicitely 1283 * marked for hard interrupt expiry mode are moved into soft 1284 * interrupt context for latency reasons and because the callbacks 1285 * can invoke functions which might sleep on RT, e.g. spin_lock(). 1286 */ 1287 if (IS_ENABLED(CONFIG_PREEMPT_RT) && !(mode & HRTIMER_MODE_HARD)) 1288 softtimer = true; 1289 |
|
1281 memset(timer, 0, sizeof(struct hrtimer)); 1282 1283 cpu_base = raw_cpu_ptr(&hrtimer_bases); 1284 1285 /* 1286 * POSIX magic: Relative CLOCK_REALTIME timers are not affected by 1287 * clock modifications, so they needs to become CLOCK_MONOTONIC to 1288 * ensure POSIX compliance. 1289 */ 1290 if (clock_id == CLOCK_REALTIME && mode & HRTIMER_MODE_REL) 1291 clock_id = CLOCK_MONOTONIC; 1292 | 1290 memset(timer, 0, sizeof(struct hrtimer)); 1291 1292 cpu_base = raw_cpu_ptr(&hrtimer_bases); 1293 1294 /* 1295 * POSIX magic: Relative CLOCK_REALTIME timers are not affected by 1296 * clock modifications, so they needs to become CLOCK_MONOTONIC to 1297 * ensure POSIX compliance. 1298 */ 1299 if (clock_id == CLOCK_REALTIME && mode & HRTIMER_MODE_REL) 1300 clock_id = CLOCK_MONOTONIC; 1301 |
1302 base = softtimer ? HRTIMER_MAX_CLOCK_BASES / 2 : 0; |
|
1293 base += hrtimer_clockid_to_base(clock_id); 1294 timer->is_soft = softtimer; 1295 timer->is_hard = !softtimer; 1296 timer->base = &cpu_base->clock_base[base]; 1297 timerqueue_init(&timer->node); 1298} 1299 1300/** --- 760 unchanged lines hidden --- | 1303 base += hrtimer_clockid_to_base(clock_id); 1304 timer->is_soft = softtimer; 1305 timer->is_hard = !softtimer; 1306 timer->base = &cpu_base->clock_base[base]; 1307 timerqueue_init(&timer->node); 1308} 1309 1310/** --- 760 unchanged lines hidden --- |