• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #ifndef FRAMEWORK_NATIVE_UNIFIED_COLLECTION_COLLECTOR_UNIFIED_COLLECTION_DATA
16 #define FRAMEWORK_NATIVE_UNIFIED_COLLECTION_COLLECTOR_UNIFIED_COLLECTION_DATA
17 
18 #include <cstdint>
19 #include <string>
20 #include <sys/ioctl.h>
21 
22 // kernel struct, modify at the same time
23 struct ucollection_process_cpu_item {
24     int pid;
25     unsigned long long min_flt;
26     unsigned long long maj_flt;
27     unsigned long long cpu_usage_utime;
28     unsigned long long cpu_usage_stime;
29     unsigned long long cpu_load_time;
30 };
31 
32 struct ucollection_process_filter {
33     int uid;
34     int pid;
35     int tid;
36 };
37 
38 struct ucollection_process_cpu_entry {
39     int magic;
40     int total_count;
41     int cur_count;
42     struct ucollection_process_filter filter;
43     struct ucollection_process_cpu_item datas[];
44 };
45 
46 struct ucollection_cpu_dmips {
47     int magic;
48     int total_count;
49     char dmips[];
50 };
51 
52 #define PROCESS_TOTAL_COUNT 2500
53 
54 #define IOCTRL_COLLECT_ALL_PROC_CPU_MAGIC 1
55 #define IOCTRL_COLLECT_THE_PROC_CPU_MAGIC 1
56 #define IOCTRL_SET_CPU_DMIPS_MAGIC 1
57 #define DMIPS_NUM 128
58 
59 #define IOCTRL_COLLECT_CPU_BASE 0
60 #define IOCTRL_COLLECT_ALL_PROC_CPU _IOR(IOCTRL_COLLECT_CPU_BASE, 1, struct ucollection_process_cpu_entry)
61 #define IOCTRL_COLLECT_THE_PROC_CPU _IOR(IOCTRL_COLLECT_CPU_BASE, 2, struct ucollection_process_cpu_entry)
62 #define IOCTRL_SET_CPU_DMIPS _IOW(IOCTRL_COLLECT_CPU_BASE, 3, struct ucollection_cpu_dmips)
63 #endif // FRAMEWORK_NATIVE_UNIFIED_COLLECTION_COLLECTOR_UNIFIED_COLLECTION_DATA
64