1 /* 2 * Copyright (C) 2018 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef __ANDROID_PSI_H__ 18 #define __ANDROID_PSI_H__ 19 20 #include <sys/cdefs.h> 21 #include <sys/types.h> 22 23 __BEGIN_DECLS 24 25 enum psi_stall_type { 26 PSI_SOME, 27 PSI_FULL, 28 PSI_TYPE_COUNT 29 }; 30 31 /* 32 * Initializes psi monitor. 33 * stall_type, threshold_us and window_us are monitor parameters 34 * When successful, the function returns file descriptor that can 35 * be used with poll/epoll syscalls to wait for EPOLLPRI events. 36 * When unsuccessful, the function returns -1 and errno is set 37 * appropriately. 38 */ 39 int init_psi_monitor(enum psi_stall_type stall_type, 40 int threshold_us, int window_us); 41 42 /* 43 * Registers psi monitor file descriptor fd on the epoll instance 44 * referred to by the file descriptor epollfd. 45 * data parameter will be associated with event's epoll_data.ptr 46 * member. 47 */ 48 int register_psi_monitor(int epollfd, int fd, void* data); 49 50 /* 51 * Unregisters psi monitor file descriptor fd from the epoll instance 52 * referred to by the file descriptor epollfd. 53 */ 54 int unregister_psi_monitor(int epollfd, int fd); 55 56 /* 57 * Destroys psi monitor. 58 * fd is the file descriptor returned by psi monitor initialization 59 * routine. 60 * Note that if user process exits without calling this routine 61 * kernel will destroy the monitor as its lifetime is linked to 62 * the file descriptor. 63 */ 64 void destroy_psi_monitor(int fd); 65 66 __END_DECLS 67 68 #endif // __ANDROID_PSI_H__ 69