blob: 41453745a0c86831f6bc7c6894319747eb26672a [file] [log] [blame]
Connor O'Brien57337192018-11-20 12:49:16 -08001/*
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'Briend250acc2019-01-23 17:21:41 -080017#pragma once
18
Connor O'Brien57337192018-11-20 12:49:16 -080019#include <unordered_map>
20#include <vector>
21
22namespace android {
23namespace bpf {
24
Rafal Slawik45caa842021-01-29 12:25:56 +000025bool isTrackingUidTimesSupported();
Connor O'Brien26de80f2019-06-11 13:49:19 -070026bool startTrackingUidTimes();
Rafal Slawik27c48db2021-01-05 19:10:07 +000027std::optional<std::vector<std::vector<uint64_t>>> getTotalCpuFreqTimes();
Connor O'Brienf03b6ae2019-06-05 18:03:12 -070028std::optional<std::vector<std::vector<uint64_t>>> getUidCpuFreqTimes(uint32_t uid);
29std::optional<std::unordered_map<uint32_t, std::vector<std::vector<uint64_t>>>>
30 getUidsCpuFreqTimes();
Connor O'Brien2a716a42020-01-31 18:51:56 -080031std::optional<std::unordered_map<uint32_t, std::vector<std::vector<uint64_t>>>>
32 getUidsUpdatedCpuFreqTimes(uint64_t *lastUpdate);
Connor O'Brien8f296eb2019-10-01 17:58:38 -070033std::optional<std::vector<std::vector<uint32_t>>> getCpuFreqs();
Connor O'Brien26de80f2019-06-11 13:49:19 -070034
35struct concurrent_time_t {
36 std::vector<uint64_t> active;
37 std::vector<std::vector<uint64_t>> policy;
38};
39
40std::optional<concurrent_time_t> getUidConcurrentTimes(uint32_t uid, bool retry = true);
41std::optional<std::unordered_map<uint32_t, concurrent_time_t>> getUidsConcurrentTimes();
Connor O'Brien2a716a42020-01-31 18:51:56 -080042std::optional<std::unordered_map<uint32_t, concurrent_time_t>>
43 getUidsUpdatedConcurrentTimes(uint64_t *lastUpdate);
Connor O'Brien26de80f2019-06-11 13:49:19 -070044bool clearUidTimes(unsigned int uid);
Connor O'Brien57337192018-11-20 12:49:16 -080045
Dmitri Plotnikov2677dba2020-10-17 21:06:55 -070046bool startTrackingProcessCpuTimes(pid_t pid);
47bool startAggregatingTaskCpuTimes(pid_t pid, uint16_t aggregationKey);
48std::optional<std::unordered_map<uint16_t, std::vector<std::vector<uint64_t>>>>
49getAggregatedTaskCpuFreqTimes(pid_t pid, const std::vector<uint16_t> &aggregationKeys);
50
Connor O'Brien57337192018-11-20 12:49:16 -080051} // namespace bpf
52} // namespace android