lib/Mojo/IOLoop/ReadWriteProcess/CGroup/v1/Memory.pm

filter: Statementstmt 96.8% 31 / 32 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 96.1% 25 / 26 Podpod 0.0% 0 / 23 totaltotal 69.1% 56 / 81 CC 1 SCAR 0.0
CC
1
Cov
97%
__ANON__
1.1
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« lib/Mojo/IOLoop/ReadWriteProcess/CGroup/v2/Memory.pm ↑ Summary lib/Mojo/IOLoop/ReadWriteProcess/CGroup/v2.pm »
1 package Mojo::IOLoop::ReadWriteProcess::CGroup::v1::Memory;
2  
3 15 ▶use Mojo::Base -base;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 15 ▶use constant {
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 # show various statistics
8 15 STAT_INTERFACE => 'memory.stat',
9  
10 # show current usage for memory
11 CURRENT_INTERFACE => 'memory.usage_in_bytes',
12  
13 # show current usage for memory+Swap
14 CURRENT_AND_SWAP_INTERFACE => 'memory.memsw.usage_in_bytes',
15  
16 # set/show limit of memory usage
17 LIMIT_INTERFACE => 'memory.limit_in_bytes',
18  
19 # show current usage for memory
20 LIMIT_AND_SWAP_INTERFACE => 'memory.memsw.limit_in_bytes',
21  
22 # show the number of memory usage hits limits
23 FAILCNT_INTERFACE => 'memory.failcnt',
24  
25 # show max memory usage recorded
26 MAX_RECORDED_INTERFACE => 'memory.max_usage_in_bytes',
27  
28 # show max memory+Swap usage recorded
29 MAX_RECORDED_AND_SWAP_INTERFACE => 'memory.memsw.max_usage_in_bytes',
30  
31 # set/show soft limit of memory usage
32 SOFT_LIMIT_INTERFACE => 'memory.soft_limit_in_bytes',
33  
34 # set/show hierarchical account enabled
35 USE_HIERARCHY_INTERFACE => 'memory.use_hierarchy',
36  
37 # trigger forced move charge to parent
38 FORCE_EMPTY_INTERFACE => 'memory.force_empty',
39  
40 # set memory pressure notifications
41 PRESSURE_LEVEL_INTERFACE => 'memory.pressure_level',
42  
43 # set/show swappiness parameter of vmscan (See sysctl's vm.swappiness)
44 SWAPPINESS_INTERFACE => 'memory.swappiness',
45  
46 # set/show controls of moving charges
47 MOVE_CHARGE_AT_IMMIGRATE_INTERFACE => 'memory.move_charge_at_immigrate',
48  
49 # set/show oom controls.
50 OOM_CONTROL_INTERFACE => 'memory.oom_control',
51  
52 # show the number of memory usage per numa node
53 NUMA_STAT_INTERFACE => 'memory.numa_stat',
54  
55 # set/show hard limit for kernel memory
56 KMEM_LIMIT_INTERFACE => 'memory.kmem.limit_in_bytes',
57  
58 # show current kernel memory allocation
59 KMEM_USAGE_INTERFACE => 'memory.kmem.usage_in_bytes',
60  
61 # show the number of kernel memory usage hits limits
62 KMEM_FAILCNT_INTERFACE => 'memory.kmem.failcnt',
63  
64 # show max kernel memory usage recorded
65 KMEM_MAX_RECORDED_INTERFACE => 'memory.kmem.max_usage_in_bytes',
66  
67 # set/show hard limit for tcp buf memory
68 KMEM_TCP_LIMIT_INTERFACE => 'memory.kmem.tcp.limit_in_bytes',
69  
70 # show current tcp buf memory allocation
71 KMEM_TCP_USAGE_INTERFACE => 'memory.kmem.tcp.usage_in_bytes',
72  
73 # show the number of tcp buf memory usage hits limits
74 KMEM_TCP_FAILCNT_INTERFACE => 'memory.kmem.tcp.failcnt',
75  
76 # show max tcp buf memory usage recorded
77 KMEM_TCP_MAX_USAGE_INTERFACE => 'memory.kmem.tcp.max_usage_in_bytes',
78  
79 15 };
80  
81 0 ▶has cgroup => sub { Mojo::IOLoop::ReadWriteProcess::CGroup::v1->new };
Subroutine __ANON__: not called CC=1 SCAR=1.2
82  
83 1 ▶sub current { shift->cgroup->_list(CURRENT_INTERFACE) }
Subroutine current: called CC=1 SCAR=0.0
Pod undocumented
84 1 ▶sub stat { shift->cgroup->_list(STAT_INTERFACE) }
Subroutine stat: called CC=1 SCAR=0.0
Pod undocumented
85 1 ▶sub swap_current { shift->cgroup->_list(CURRENT_AND_SWAP_INTERFACE) }
Subroutine swap_current: called CC=1 SCAR=0.0
Pod undocumented
86 2 ▶sub limit { shift->cgroup->_setget(LIMIT_INTERFACE, @_) }
Subroutine limit: called CC=1 SCAR=0.0
Pod undocumented
87 1 ▶sub failcnt { shift->cgroup->_list(FAILCNT_INTERFACE) }
Subroutine failcnt: called CC=1 SCAR=0.0
Pod undocumented
88 1 ▶sub observed_max_usage { shift->cgroup->_list(MAX_RECORDED_INTERFACE) }
Subroutine observed_max_usage: called CC=1 SCAR=0.0
Pod undocumented
89  
90 1 ▶sub observed_swap_max_usage {
Subroutine observed_swap_max_usage: called CC=1 SCAR=0.0
Pod undocumented
91 1 shift->cgroup->_list(MAX_RECORDED_AND_SWAP_INTERFACE);
92 }
93 2 ▶sub use_hierarchy { shift->cgroup->_setget(USE_HIERARCHY_INTERFACE, @_) }
Subroutine use_hierarchy: called CC=1 SCAR=0.0
Pod undocumented
94 2 ▶sub soft_limit { shift->cgroup->_setget(SOFT_LIMIT_INTERFACE, @_) }
Subroutine soft_limit: called CC=1 SCAR=0.0
Pod undocumented
95 2 ▶sub force_empty { shift->cgroup->_setget(FORCE_EMPTY_INTERFACE, @_) }
Subroutine force_empty: called CC=1 SCAR=0.0
Pod undocumented
96 2 ▶sub pressure_level { shift->cgroup->_setget(PRESSURE_LEVEL_INTERFACE, @_) }
Subroutine pressure_level: called CC=1 SCAR=0.0
Pod undocumented
97 2 ▶sub swappiness { shift->cgroup->_setget(SWAPPINESS_INTERFACE, @_) }
Subroutine swappiness: called CC=1 SCAR=0.0
Pod undocumented
98  
99 2 ▶sub move_charge {
Subroutine move_charge: called CC=1 SCAR=0.0
Pod undocumented
100 2 shift->cgroup->_setget(MOVE_CHARGE_AT_IMMIGRATE_INTERFACE, @_);
101 }
102 2 ▶sub oom_control { shift->cgroup->_setget(OOM_CONTROL_INTERFACE, @_) }
Subroutine oom_control: called CC=1 SCAR=0.0
Pod undocumented
103 1 ▶sub numa_stat { shift->cgroup->_list(NUMA_STAT_INTERFACE) }
Subroutine numa_stat: called CC=1 SCAR=0.0
Pod undocumented
104 2 ▶sub kmem_limit { shift->cgroup->_setget(KMEM_LIMIT_INTERFACE, @_) }
Subroutine kmem_limit: called CC=1 SCAR=0.0
Pod undocumented
105 1 ▶sub kmem_usage { shift->cgroup->_list(KMEM_USAGE_INTERFACE) }
Subroutine kmem_usage: called CC=1 SCAR=0.0
Pod undocumented
106 1 ▶sub kmem_failcnt { shift->cgroup->_list(KMEM_FAILCNT_INTERFACE) }
Subroutine kmem_failcnt: called CC=1 SCAR=0.0
Pod undocumented
107 1 ▶sub kmem_max_usage { shift->cgroup->_list(KMEM_MAX_RECORDED_INTERFACE) }
Subroutine kmem_max_usage: called CC=1 SCAR=0.0
Pod undocumented
108 2 ▶sub kmem_tcp_limit { shift->cgroup->_setget(KMEM_TCP_LIMIT_INTERFACE, @_) }
Subroutine kmem_tcp_limit: called CC=1 SCAR=0.0
Pod undocumented
109 1 ▶sub kmem_tcp_usage { shift->cgroup->_list(KMEM_TCP_USAGE_INTERFACE) }
Subroutine kmem_tcp_usage: called CC=1 SCAR=0.0
Pod undocumented
110 1 ▶sub kmem_tcp_failcnt { shift->cgroup->_list(KMEM_TCP_FAILCNT_INTERFACE) }
Subroutine kmem_tcp_failcnt: called CC=1 SCAR=0.0
Pod undocumented
111 1 ▶sub kmem_tcp_max_usage { shift->cgroup->_list(KMEM_TCP_MAX_USAGE_INTERFACE) }
Subroutine kmem_tcp_max_usage: called CC=1 SCAR=0.0
Pod undocumented
112  
113 15 1;
114  
115 =encoding utf-8
116  
117 =head1 NAME
118  
119 Mojo::IOLoop::ReadWriteProcess::CGroup::v1::Memory - CGroups v1 Memory Controller
120  
121 =head1 SYNOPSIS
122  
123 use Mojo::IOLoop::ReadWriteProcess::CGroup::v1;
124  
125 my $cgroup = Mojo::IOLoop::ReadWriteProcess::CGroup::v1->new( name => "test" );
126  
127 $cgroup->memory->current;
128  
129 =head1 DESCRIPTION
130  
131 This module uses features that are only available on Linux,
132 and requires cgroups and capability for unshare syscalls to achieve pid isolation.
133  
134 =head1 METHODS
135  
136 L<Mojo::IOLoop::ReadWriteProcess::CGroup::v1::Memory> inherits all methods from L<Mojo::Base> and implements
137 the following new ones.
138  
139 =head1 LICENSE
140  
141 Copyright (C) Ettore Di Giacinto.
142  
143 This library is free software; you can redistribute it and/or modify
144 it under the same terms as Perl itself.
145  
146 =head1 AUTHOR
147  
148 Ettore Di Giacinto E<lt>edigiacinto@suse.comE<gt>
149  
150 =cut
« lib/Mojo/IOLoop/ReadWriteProcess/CGroup/v2/Memory.pm ↑ Summary lib/Mojo/IOLoop/ReadWriteProcess/CGroup/v2.pm »