Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Gregory Haskins | 6e0534f | 2008-05-12 21:21:01 +0200 | [diff] [blame] | 2 | |
Peter Zijlstra | b13772f | 2020-10-14 21:39:04 +0200 | [diff] [blame] | 3 | #define CPUPRI_NR_PRIORITIES (MAX_RT_PRIO+1) |
Gregory Haskins | 6e0534f | 2008-05-12 21:21:01 +0200 | [diff] [blame] | 4 | |
Ingo Molnar | 97fb7a0 | 2018-03-03 14:01:12 +0100 | [diff] [blame] | 5 | #define CPUPRI_INVALID -1 |
Dietmar Eggemann | 5e054bc | 2020-09-22 10:39:33 +0200 | [diff] [blame] | 6 | #define CPUPRI_NORMAL 0 |
Dietmar Eggemann | 1b08782 | 2020-09-22 10:39:34 +0200 | [diff] [blame] | 7 | /* values 1-99 are for RT1-RT99 priorities */ |
Peter Zijlstra | b13772f | 2020-10-14 21:39:04 +0200 | [diff] [blame] | 8 | #define CPUPRI_HIGHER 100 |
Gregory Haskins | 6e0534f | 2008-05-12 21:21:01 +0200 | [diff] [blame] | 9 | |
| 10 | struct cpupri_vec { |
Ingo Molnar | 97fb7a0 | 2018-03-03 14:01:12 +0100 | [diff] [blame] | 11 | atomic_t count; |
| 12 | cpumask_var_t mask; |
Gregory Haskins | 6e0534f | 2008-05-12 21:21:01 +0200 | [diff] [blame] | 13 | }; |
| 14 | |
| 15 | struct cpupri { |
Ingo Molnar | 97fb7a0 | 2018-03-03 14:01:12 +0100 | [diff] [blame] | 16 | struct cpupri_vec pri_to_cpu[CPUPRI_NR_PRIORITIES]; |
| 17 | int *cpu_to_pri; |
Gregory Haskins | 6e0534f | 2008-05-12 21:21:01 +0200 | [diff] [blame] | 18 | }; |
| 19 | |
| 20 | #ifdef CONFIG_SMP |
Qais Yousef | 804d402 | 2019-10-09 11:46:11 +0100 | [diff] [blame] | 21 | int cpupri_find(struct cpupri *cp, struct task_struct *p, |
Qais Yousef | a1bd02e | 2020-03-02 13:27:18 +0000 | [diff] [blame] | 22 | struct cpumask *lowest_mask); |
| 23 | int cpupri_find_fitness(struct cpupri *cp, struct task_struct *p, |
| 24 | struct cpumask *lowest_mask, |
| 25 | bool (*fitness_fn)(struct task_struct *p, int cpu)); |
Gregory Haskins | 6e0534f | 2008-05-12 21:21:01 +0200 | [diff] [blame] | 26 | void cpupri_set(struct cpupri *cp, int cpu, int pri); |
Ingo Molnar | 97fb7a0 | 2018-03-03 14:01:12 +0100 | [diff] [blame] | 27 | int cpupri_init(struct cpupri *cp); |
Rusty Russell | 68e7456 | 2008-11-25 02:35:13 +1030 | [diff] [blame] | 28 | void cpupri_cleanup(struct cpupri *cp); |
Gregory Haskins | 6e0534f | 2008-05-12 21:21:01 +0200 | [diff] [blame] | 29 | #endif |