1 /* 2 * Copyright (c) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef SCHED_RTG_H 17 #define SCHED_RTG_H 18 19 #include <unistd.h> 20 #include <stdbool.h> 21 22 #ifdef __cplusplus 23 extern "C" { 24 #endif 25 26 #define DEFAULT_RT_FRAME_ID 8 27 #define FRAME_START (1 << 0) 28 #define FRAME_END (1 << 1) 29 30 void set_task_rtg(pid_t tid, unsigned int grp_id); 31 void set_rtg_status(unsigned long long status); 32 void set_rtg_qos(int qos); 33 void set_rtg_load_mode(unsigned int grp_id, bool util_enabled, bool freq_enabled); 34 void set_task_min_util(pid_t tid, unsigned int util); 35 36 /* inner use */ 37 38 struct rtg_group_task { 39 pid_t pid; 40 unsigned int grp_id; 41 bool pmu_sample_enabled; 42 }; 43 44 struct rtg_load_mode { 45 unsigned int grp_id; 46 unsigned int freq_enabled; 47 unsigned int util_enabled; 48 }; 49 50 struct task_config { 51 pid_t pid; 52 unsigned int value; 53 }; 54 55 #define SET_TASK_RTG 11 56 #define SET_FRAME_STATUS 10 57 #define SET_FRAME_RATE 8 58 #define SET_RTG_LOAD_MODE 22 59 #define SET_TASK_MIN_UTIL 28 60 61 #define PERF_CTRL_MAGIC 'x' 62 #define PERF_CTRL_SET_TASK_RTG _IOWR(PERF_CTRL_MAGIC, SET_TASK_RTG, struct rtg_group_task) 63 #define PERF_CTRL_SET_FRAME_STATUS _IOWR(PERF_CTRL_MAGIC, SET_FRAME_STATUS, unsigned long long) 64 #define PERF_CTRL_SET_FRAME_RATE _IOWR(PERF_CTRL_MAGIC, SET_FRAME_RATE, int) 65 #define PERF_CTRL_SET_RTG_LOAD_MODE _IOW(PERF_CTRL_MAGIC, SET_RTG_LOAD_MODE, struct rtg_load_mode) 66 #define PERF_CTRL_SET_TASK_MIN_UTIL _IOW(PERF_CTRL_MAGIC, SET_TASK_MIN_UTIL, struct task_config) 67 68 #ifdef __cplusplus 69 } 70 #endif 71 72 #endif /* SCHED_RTG_H */ 73