• 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 
49     uint64_t thp;
50 
MemUsageMemUsage51     MemUsage()
52         : vss(0),
53           rss(0),
54           pss(0),
55           uss(0),
56           swap(0),
57           swap_pss(0),
58           private_clean(0),
59           private_dirty(0),
60           shared_clean(0),
61           shared_dirty(0),
62           anon_huge_pages(0),
63           shmem_pmd_mapped(0),
64           file_pmd_mapped(0),
65           shared_hugetlb(0),
66           private_hugetlb(0),
67           thp(0) {}
68 
69     ~MemUsage() = default;
70 
clearMemUsage71     void clear() {
72         vss = rss = pss = uss = swap = swap_pss = 0;
73         private_clean = private_dirty = shared_clean = shared_dirty = 0;
74     }
75 };
76 
77 struct Vma {
78     uint64_t start;
79     uint64_t end;
80     uint64_t offset;
81     uint16_t flags;
82     std::string name;
83     uint64_t inode;
84     bool is_shared;
85 
VmaVma86     Vma() : start(0), end(0), offset(0), flags(0), name(""), inode(0), is_shared(false) {}
VmaVma87     Vma(uint64_t s, uint64_t e, uint64_t off, uint16_t f, const std::string& n,
88         uint64_t iNode, bool is_shared)
89         : start(s), end(e), offset(off), flags(f), name(n), inode(iNode), is_shared(is_shared) {}
90     ~Vma() = default;
91 
clearVma92     void clear() { memset(&usage, 0, sizeof(usage)); }
93 
94     // Memory usage of this mapping.
95     MemUsage usage;
96 };
97 
98 }  // namespace meminfo
99 }  // namespace android
100