Connor O'Brien | 5733719 | 2018-11-20 12:49:16 -0800 | [diff] [blame] | 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 | |
Connor O'Brien | d250acc | 2019-01-23 17:21:41 -0800 | [diff] [blame] | 17 | #pragma once |
| 18 | |
Connor O'Brien | 5733719 | 2018-11-20 12:49:16 -0800 | [diff] [blame] | 19 | #include <unordered_map> |
| 20 | #include <vector> |
| 21 | |
| 22 | namespace android { |
| 23 | namespace bpf { |
| 24 | |
Rafal Slawik | 45caa84 | 2021-01-29 12:25:56 +0000 | [diff] [blame^] | 25 | bool isTrackingUidTimesSupported(); |
Connor O'Brien | 26de80f | 2019-06-11 13:49:19 -0700 | [diff] [blame] | 26 | bool startTrackingUidTimes(); |
Rafal Slawik | 27c48db | 2021-01-05 19:10:07 +0000 | [diff] [blame] | 27 | std::optional<std::vector<std::vector<uint64_t>>> getTotalCpuFreqTimes(); |
Connor O'Brien | f03b6ae | 2019-06-05 18:03:12 -0700 | [diff] [blame] | 28 | std::optional<std::vector<std::vector<uint64_t>>> getUidCpuFreqTimes(uint32_t uid); |
| 29 | std::optional<std::unordered_map<uint32_t, std::vector<std::vector<uint64_t>>>> |
| 30 | getUidsCpuFreqTimes(); |
Connor O'Brien | 2a716a4 | 2020-01-31 18:51:56 -0800 | [diff] [blame] | 31 | std::optional<std::unordered_map<uint32_t, std::vector<std::vector<uint64_t>>>> |
| 32 | getUidsUpdatedCpuFreqTimes(uint64_t *lastUpdate); |
Connor O'Brien | 8f296eb | 2019-10-01 17:58:38 -0700 | [diff] [blame] | 33 | std::optional<std::vector<std::vector<uint32_t>>> getCpuFreqs(); |
Connor O'Brien | 26de80f | 2019-06-11 13:49:19 -0700 | [diff] [blame] | 34 | |
| 35 | struct concurrent_time_t { |
| 36 | std::vector<uint64_t> active; |
| 37 | std::vector<std::vector<uint64_t>> policy; |
| 38 | }; |
| 39 | |
| 40 | std::optional<concurrent_time_t> getUidConcurrentTimes(uint32_t uid, bool retry = true); |
| 41 | std::optional<std::unordered_map<uint32_t, concurrent_time_t>> getUidsConcurrentTimes(); |
Connor O'Brien | 2a716a4 | 2020-01-31 18:51:56 -0800 | [diff] [blame] | 42 | std::optional<std::unordered_map<uint32_t, concurrent_time_t>> |
| 43 | getUidsUpdatedConcurrentTimes(uint64_t *lastUpdate); |
Connor O'Brien | 26de80f | 2019-06-11 13:49:19 -0700 | [diff] [blame] | 44 | bool clearUidTimes(unsigned int uid); |
Connor O'Brien | 5733719 | 2018-11-20 12:49:16 -0800 | [diff] [blame] | 45 | |
Dmitri Plotnikov | 2677dba | 2020-10-17 21:06:55 -0700 | [diff] [blame] | 46 | bool startTrackingProcessCpuTimes(pid_t pid); |
| 47 | bool startAggregatingTaskCpuTimes(pid_t pid, uint16_t aggregationKey); |
| 48 | std::optional<std::unordered_map<uint16_t, std::vector<std::vector<uint64_t>>>> |
| 49 | getAggregatedTaskCpuFreqTimes(pid_t pid, const std::vector<uint16_t> &aggregationKeys); |
| 50 | |
Connor O'Brien | 5733719 | 2018-11-20 12:49:16 -0800 | [diff] [blame] | 51 | } // namespace bpf |
| 52 | } // namespace android |