• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2022 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 #pragma once
18 
19 #include <stdint.h>
20 
21 #ifdef __cplusplus
22 #include <type_traits>
23 
24 namespace android {
25 namespace gpuwork {
26 #endif
27 
28 typedef struct  {
29     uint32_t gpu_id;
30     uint32_t uid;
31 } GpuIdUid;
32 
33 typedef struct {
34     // The end time of the previous period where the GPU was active for the UID,
35     // in nanoseconds.
36     uint64_t previous_active_end_time_ns;
37 
38     // The total amount of time the GPU has spent running work for the UID, in
39     // nanoseconds.
40     uint64_t total_active_duration_ns;
41 
42     // The total amount of time of the "gaps" between "continuous" GPU work for
43     // the UID, in nanoseconds. This is estimated by ignoring large gaps between
44     // GPU work for this UID.
45     uint64_t total_inactive_duration_ns;
46 
47     // The number of errors detected due to |GpuWorkPeriodEvent| events for the
48     // UID violating the specification in some way. E.g. periods with a zero or
49     // negative duration.
50     uint32_t error_count;
51 
52     // Needed to make 32-bit arch struct size match 64-bit BPF arch struct size.
53     uint32_t padding0;
54 } UidTrackingInfo;
55 
56 typedef struct {
57     // We cannot query the number of entries in BPF map |gpu_work_map|. We track
58     // the number of entries (approximately) using a counter so we can check if
59     // the map is nearly full.
60     uint64_t num_map_entries;
61 } GlobalData;
62 
63 // The maximum number of tracked GPU ID and UID pairs (|GpuIdUid|).
64 static const uint32_t kMaxTrackedGpuIdUids = 512;
65 
66 #ifdef __cplusplus
67 } // namespace gpuwork
68 } // namespace android
69 #endif
70