blob: 61d3324103d79124a592ae6e5d612b6f92a1475c [file] [log] [blame]
Connor O'Brien85087ae2019-09-03 14:53:51 -07001/*
2 * Copyright (C) 2019 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#include <inttypes.h>
Dmitri Plotnikov7c315222020-10-17 21:29:09 -070018#include <sys/types.h>
Connor O'Brien85087ae2019-09-03 14:53:51 -070019
20#define BPF_FS_PATH "/sys/fs/bpf/"
21
22// Number of frequencies for which a UID's times can be tracked in a single map entry. If some CPUs
23// have more than 32 freqs available, a single UID is tracked using 2 or more entries.
24#define FREQS_PER_ENTRY 32
25// Number of distinct CPU counts for which a UID's concurrent time stats can be tracked in a single
26// map entry. On systems with more than 8 CPUs, a single UID is tracked using 2 or more entries.
27#define CPUS_PER_ENTRY 8
28
29typedef struct {
30 uint32_t uid;
31 uint32_t bucket;
32} time_key_t;
33
34typedef struct {
35 uint64_t ar[FREQS_PER_ENTRY];
36} tis_val_t;
37
38typedef struct {
39 uint64_t active[CPUS_PER_ENTRY];
40 uint64_t policy[CPUS_PER_ENTRY];
41} concurrent_val_t;
42
43typedef struct {
44 uint32_t policy;
45 uint32_t freq;
46} freq_idx_key_t;
Dmitri Plotnikov7c315222020-10-17 21:29:09 -070047
48typedef struct {
49 pid_t tgid;
50 uint16_t aggregation_key;
51 uint16_t bucket;
52} aggregated_task_tis_key_t;