• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
17 #pragma once
18 
19 #include <string.h>
20 #include <sys/types.h>
21 #include <unistd.h>
22 
23 #include <string>
24 #include <vector>
25 
26 namespace android {
27 namespace meminfo {
28 
29 struct MemUsage {
30     uint64_t vss;
31     uint64_t rss;
32     uint64_t pss;
33     uint64_t uss;
34 
35     uint64_t swap;
36     uint64_t swap_pss;
37 
38     uint64_t private_clean;
39     uint64_t private_dirty;
40     uint64_t shared_clean;
41     uint64_t shared_dirty;
42 
43     uint64_t anon_huge_pages;
44     uint64_t shmem_pmd_mapped;
45     uint64_t file_pmd_mapped;
46     uint64_t shared_hugetlb;
47     uint64_t private_hugetlb;
48     uint64_t locked;
49 
50     uint64_t thp;
51 
MemUsageMemUsage52     MemUsage()
53         : vss(0),
54           rss(0),
55           pss(0),
56           uss(0),
57           swap(0),
58           swap_pss(0),
59           private_clean(0),
60           private_dirty(0),
61           shared_clean(0),
62           shared_dirty(0),
63           anon_huge_pages(0),
64           shmem_pmd_mapped(0),
65           file_pmd_mapped(0),
66           shared_hugetlb(0),
67           private_hugetlb(0),
68           locked(0),
69           thp(0) {}
70 
71     ~MemUsage() = default;
72 
clearMemUsage73     void clear() {
74         vss = rss = pss = uss = swap = swap_pss = 0;
75         private_clean = private_dirty = shared_clean = shared_dirty = 0;
76     }
77 };
78 
79 struct Vma {
80     uint64_t start;
81     uint64_t end;
82     uint64_t offset;
83     uint16_t flags;
84     std::string name;
85     uint64_t inode;
86     bool is_shared;
87 
VmaVma88     Vma() : start(0), end(0), offset(0), flags(0), name(""), inode(0), is_shared(false) {}
VmaVma89     Vma(uint64_t s, uint64_t e, uint64_t off, uint16_t f, const std::string& n,
90         uint64_t iNode, bool is_shared)
91         : start(s), end(e), offset(off), flags(f), name(n), inode(iNode), is_shared(is_shared) {}
92     ~Vma() = default;
93 
clearVma94     void clear() { memset(&usage, 0, sizeof(usage)); }
95 
96     // Memory usage of this mapping.
97     MemUsage usage;
98 };
99 
100 }  // namespace meminfo
101 }  // namespace android
102