Lines Matching +full:self +full:- +full:describing
2 # SPDX-License-Identifier: GPL-2.0-only
5 # Utility providing smaps-like output detailing transparent hugepage usage.
7 # ./thpmaps --help
34 return (v + (a - 1)) & ~(a - 1)
38 return v & (a - 1)
65 r[1:] -= d
66 r[:-1] -= d
67 return [np.repeat(arr, r).reshape(-1, 2) for arr in index]
82 def __init__(self, filename, element_size):
83 self.element_size = element_size
84 self.filename = filename
85 self.fd = os.open(self.filename, os.O_RDONLY)
87 def cleanup(self):
88 os.close(self.fd)
90 def __enter__(self):
91 return self
93 def __exit__(self, exc_type, exc_val, exc_tb):
94 self.cleanup()
96 def _readin(self, offset, buffer):
97 length = os.preadv(self.fd, (buffer,), offset)
100 .format(self.filename, len(buffer), offset))
102 def _toarray(self, buf):
103 assert(self.element_size == 8)
106 def getv(self, vec):
107 vec *= self.element_size
109 lengths = (np.diff(vec) + self.element_size).reshape(len(vec))
116 self._readin(offset, view[pos:pos+length])
118 return self._toarray(buf)
120 def get(self, index, nr=1):
121 offset = index * self.element_size
122 length = nr * self.element_size
124 self._readin(offset, buf)
125 return self._toarray(buf)
129 PM_PFN_MASK = (1 << 55) - 1
133 def __init__(self, pid='self'):
144 def __init__(self):
197 def __init__(self, pid='self', stats=[]):
198 self.vmas = []
202 if '-' in elements[0]:
203 start, end = map(lambda x: int(x, 16), elements[0].split('-'))
205 self.vmas.append(VMA(
220 param = elements[0][:-1]
223 self.vmas[-1].stats[param] = {'type': None, 'value': value}
225 def __iter__(self):
226 yield from self.vmas
230 # Given 4 same-sized arrays representing a range within a page table backed
233 # dictionary of statistics describing the mapped THPs.
256 nr = (int(folios[0]) if len(folios) else index_end) - index_next
264 nr = index_end - int(folios[-1])
265 folios = folios[:-1]
266 index_end -= nr
267 stats['anon' if anons[index_end - 1] else 'file']['partial'] += nr
271 folio_nrs = np.append(np.diff(folios), np.uint64(index_end - folios[-1]))
282 # Account PMD-mapped THPs spearately, so filter out of the stats. There is a
288 …stats['anon']['aligned'][PMD_ORDER] = max(0, stats['anon']['aligned'][PMD_ORDER] - kbnr(anon_pmd_m…
289 …stats['file']['aligned'][PMD_ORDER] = max(0, stats['file']['aligned'][PMD_ORDER] - kbnr(file_pmd_m…
292 f"anon-thp-pmd-aligned-{odkb(PMD_ORDER)}kB": {'type': 'anon', 'value': anon_pmd_mapped},
293 f"file-thp-pmd-aligned-{odkb(PMD_ORDER)}kB": {'type': 'file', 'value': file_pmd_mapped},
297 param = f"{type}-thp-pte-{subtype}-{{}}kB"
304 rstats[f"{type}-thp-pte-partial"] = {'type': type, 'value': nrkb(stats['partial'])}
313 # Given 4 same-sized arrays representing a range within a page table backed
316 # dictionary of statistics describing the contiguous blocks.
330 off = align_forward(vfn_start, nr_cont) - vfn_start
342 # Account blocks that are PMD-mapped spearately, so filter out of the stats.
349 nr_anon = max(0, nr_anon - kbnr(anon_pmd_mapped))
350 nr_file = max(0, nr_file - kbnr(file_pmd_mapped))
353 f"anon-cont-pmd-aligned-{nrkb(nr_cont)}kB": {'type': 'anon', 'value': anon_pmd_mapped},
354 f"file-cont-pmd-aligned-{nrkb(nr_cont)}kB": {'type': 'file', 'value': file_pmd_mapped},
357 rstats[f"anon-cont-pte-aligned-{nrkb(nr_cont)}kB"] = {'type': 'anon', 'value': nrkb(nr_anon)}
358 rstats[f"file-cont-pte-aligned-{nrkb(nr_cont)}kB"] = {'type': 'file', 'value': nrkb(nr_file)}
366 print("{:010d}: {:016x}-{:016x} {}{}{}{} {:08x} {:02x}:{:02x} {:08x} {}"
369 'r' if vma.read else '-', 'w' if vma.write else '-',
370 'x' if vma.execute else '-', 'p' if vma.private else 's',
382 pad = max(0, label_field - len(label) - 1)
397 pmes = pagemap.get(start, end - start)
422 tot_file = vma.stats['Rss']['value'] - tot_anon
490 docs_width -= 2
509 if human[-1] in units:
510 unit = units[human[-1]]
511 human = human[:-1]
515 raise ArgException('error: --cont value must be integer size with optional KMG unit')
519 raise ArgException('error: --cont value must be size of at least 2 pages')
521 raise ArgException('error: --cont value must be size of power-of-2 pages')
523 raise ArgException('error: --cont value must be less than or equal to PMD order')
528 pages are mapped, either system-wide, or for a specified
531 When run with --pid, the user explicitly specifies the set
532 of pids to scan. e.g. "--pid 10 [--pid 134 ...]". When run
533 with --cgroup, the user passes either a v1 or v2 cgroup and
535 run with neither --pid nor --cgroup, the full set of pids on
537 had provided "--pid 1 --pid 2 ...".\\n
542 the block size is user-defined.\\n
545 file-backed (pagecache) memory and are shown both in kB and
547 file-backed memory as appropriate.\\n
550 --------------\\n
552 Statistics are always generated for fully- and
553 contiguously-mapped THPs whose mapping address is aligned to
557 PMD if it is PMD-sized):\\n
559 - anon-thp-pte-aligned-<size>kB\\n
560 - file-thp-pte-aligned-<size>kB\\n
561 - anon-thp-pmd-aligned-<size>kB\\n
562 - file-thp-pmd-aligned-<size>kB\\n
564 Similarly, statistics are always generated for fully- and
565 contiguously-mapped THPs whose mapping address is *not*
570 - anon-thp-pte-unaligned-<size>kB\\n
571 - file-thp-pte-unaligned-<size>kB\\n
574 belong to a THP but where the is THP is *not* fully- and
575 contiguously- mapped. These "partial" mappings are all
579 - anon-thp-pte-partial\\n
580 - file-thp-pte-partial\\n
583 ---------------------------\\n
586 every contiguous block size specified with `--cont <size>`.
594 - anon-cont-pte-aligned-<size>kB\\n
595 - file-cont-pte-aligned-<size>kB\\n
596 - anon-cont-pmd-aligned-<size>kB\\n
597 - file-cont-pmd-aligned-<size>kB\\n
599 As an example, if monitoring 64K contiguous blocks (--cont
601 blocks: a fully- and contiguously-mapped 64K THP that is
602 aligned to a 64K boundary would provide 1 block. A fully-
603 and contiguously-mapped 128K THP that is aligned to at least
606 boundary would provide 1 block. A fully- and
607 contiguously-mapped 2M THP would provide 32 blocks. There
613 group.add_argument('--pid',
616 scan multiple processes. --pid and --cgroup are mutually exclusive.
618 system-wide information.""")
620 group.add_argument('--cgroup',
623 the cgroup and its children. --pid and --cgroup are mutually
625 provide system-wide information.""")
627 parser.add_argument('--rollup',
629 help="""Sum the per-vma statistics to provide a summary over the whole
632 parser.add_argument('--cont',
637 hpa mappings. Size must be a power-of-2 number of pages.""")
639 parser.add_argument('--inc-smaps',
644 parser.add_argument('--inc-empty',
648 parser.add_argument('--periodic',