Cgroup memory.usage_in_bytes shows incorrect valueWhy is machine.slice shown as using memory, when it does not contain any processes?How to limit application memory usage?Need explanation on Resident Set Size/Virtual Sizecpu time measurement with wait4 vs. cpuacct cgroupDiscrepancy between reported used memory and sum of application memory usageWhat does hierarchy support do in cgroup?cgroup memory.usage_in_bytes always zero for some tasksHigh memory usage but no process is using it-/+ buffers/cache & Swapcgroups memory limit - write error: Device or resource busyWhere else could memory be used other than process, cache and tmpfs?
Where does the Z80 processor start executing from?
Fine Tuning of the Universe
Failed to fetch jessie backports repository
Pole-zeros of a real-valued causal FIR system
What happens if you roll doubles 3 times then land on "Go to jail?"
Type int? vs type int
Hostile work environment after whistle-blowing on coworker and our boss. What do I do?
What is the best translation for "slot" in the context of multiplayer video games?
How do we know the LHC results are robust?
How to write papers efficiently when English isn't my first language?
How does buying out courses with grant money work?
Short story about space worker geeks who zone out by 'listening' to radiation from stars
How do I find the solutions of the following equation?
Go Pregnant or Go Home
Would a high gravity rocky planet be guaranteed to have an atmosphere?
Applicability of Single Responsibility Principle
Purchasing a ticket for someone else in another country?
Term for the "extreme-extension" version of a straw man fallacy?
Proof of work - lottery approach
How can I get through very long and very dry, but also very useful technical documents when learning a new tool?
Balance Issues for a Custom Sorcerer Variant
Is there a good way to store credentials outside of a password manager?
How to check is there any negative term in a large list?
How did Arya survive the stabbing?
Cgroup memory.usage_in_bytes shows incorrect value
Why is machine.slice shown as using memory, when it does not contain any processes?How to limit application memory usage?Need explanation on Resident Set Size/Virtual Sizecpu time measurement with wait4 vs. cpuacct cgroupDiscrepancy between reported used memory and sum of application memory usageWhat does hierarchy support do in cgroup?cgroup memory.usage_in_bytes always zero for some tasksHigh memory usage but no process is using it-/+ buffers/cache & Swapcgroups memory limit - write error: Device or resource busyWhere else could memory be used other than process, cache and tmpfs?
I created a Cgroup on my Linux device and noticed that the value of memory.usage_in_bytes (4325376) is bigger than the sum of RSS, CACHE and SWAP (4194304).
I read in a reliable documentation, the memory.usage_in_bytes doesn't show the exact value of memory (and swap) usage. If you want to know more exact memory usage, you should use RSS+CACHE(+SWAP) value in memory.stat.
Does anyone have idea about this? Should I use the value of memory.usage_in_bytes?
memory cgroups
add a comment |
I created a Cgroup on my Linux device and noticed that the value of memory.usage_in_bytes (4325376) is bigger than the sum of RSS, CACHE and SWAP (4194304).
I read in a reliable documentation, the memory.usage_in_bytes doesn't show the exact value of memory (and swap) usage. If you want to know more exact memory usage, you should use RSS+CACHE(+SWAP) value in memory.stat.
Does anyone have idea about this? Should I use the value of memory.usage_in_bytes?
memory cgroups
A related question is unix.stackexchange.com/questions/449911 .
– JdeBP
Jun 22 '18 at 10:16
add a comment |
I created a Cgroup on my Linux device and noticed that the value of memory.usage_in_bytes (4325376) is bigger than the sum of RSS, CACHE and SWAP (4194304).
I read in a reliable documentation, the memory.usage_in_bytes doesn't show the exact value of memory (and swap) usage. If you want to know more exact memory usage, you should use RSS+CACHE(+SWAP) value in memory.stat.
Does anyone have idea about this? Should I use the value of memory.usage_in_bytes?
memory cgroups
I created a Cgroup on my Linux device and noticed that the value of memory.usage_in_bytes (4325376) is bigger than the sum of RSS, CACHE and SWAP (4194304).
I read in a reliable documentation, the memory.usage_in_bytes doesn't show the exact value of memory (and swap) usage. If you want to know more exact memory usage, you should use RSS+CACHE(+SWAP) value in memory.stat.
Does anyone have idea about this? Should I use the value of memory.usage_in_bytes?
memory cgroups
memory cgroups
asked Jun 22 '18 at 8:36
DOAN MINH HUNGDOAN MINH HUNG
1
1
A related question is unix.stackexchange.com/questions/449911 .
– JdeBP
Jun 22 '18 at 10:16
add a comment |
A related question is unix.stackexchange.com/questions/449911 .
– JdeBP
Jun 22 '18 at 10:16
A related question is unix.stackexchange.com/questions/449911 .
– JdeBP
Jun 22 '18 at 10:16
A related question is unix.stackexchange.com/questions/449911 .
– JdeBP
Jun 22 '18 at 10:16
add a comment |
2 Answers
2
active
oldest
votes
usage_in_bytes
For efficiency, as other kernel components, memory cgroup uses some optimization
to avoid unnecessary cacheline false sharing. usage_in_bytes is affected by the
method and doesn't show 'exact' value of memory (and swap) usage, it's a fuzz
value for efficient access. (Of course, when necessary, it's synchronized.)
If you want to know more exact memory usage, you should use RSS+CACHE(+SWAP)
value in memory.stat(see 5.2).
If you are reading the accurate files repeatedly, and you have measured your system performance as being limited by cpu usage, you might consider sampling memory_usage instead.
I don't know how it works. However as an LWN.net reader, this sounds similar to a situation where there can be multiple counters which are kept local to where they are used, and where somehow reading usage_in_bytes does not force an immediate synchronization and summary of these counters.
Over the years, kernel developers have made increasing use of per-CPU data in an effort to minimize memory contention and its associated performance penalties. As a simple example, consider the disk operation statistics maintained by the block layer. Incrementing a global counter for every disk operation would cause the associated cache line to bounce continually between processors; disk operations are frequent enough that the performance cost would be measurable. So each CPU maintains its own set of counters locally; it never has to contend with any other CPU to increment one of those counters. When a total count is needed, all of the per-CPU counters are added up. Given that the counters are queried far more rarely than they are modified, storing them in per-CPU form yields a significant performance improvement.
-- https://lwn.net/Articles/258238/
If you have a small system - not a large number of cpus, and not maintaining a large number of cgroups - the overhead doesn't sound very significant. It doesn't cost very much to bounce a few cache lines between cpus. But the efficiency might be useful if you are Google and running thousands of containers on a system :), or if you have some system with thousands of cpus.
add a comment |
I think I am seeing inconsistency when viewing memory.usage_in_bytes when the process under the two scenarios.
Scenario1: Process created directly under a cgroup
Memory usage shown looks correct.
# cgexec -g memory:mem128 sleep 30 &
[2] 18339
# cat /sys/fs/cgroup/memory/mem128/memory.usage_in_bytes
135168
Scenario2: Process created separately and then assigned to a cgroup.
Memory usage shown is incorrect. 36864 seems incorrect. Sometimes is shows 0
as well. Why is this different than the scenario 1 shown above?
# sleep 90 &
[2] 18937
# cgclassify -g memory:/mem128 18937
# cat /sys/fs/cgroup/memory/mem128/memory.usage_in_bytes
36864
New contributor
user7681939 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f451252%2fcgroup-memory-usage-in-bytes-shows-incorrect-value%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
usage_in_bytes
For efficiency, as other kernel components, memory cgroup uses some optimization
to avoid unnecessary cacheline false sharing. usage_in_bytes is affected by the
method and doesn't show 'exact' value of memory (and swap) usage, it's a fuzz
value for efficient access. (Of course, when necessary, it's synchronized.)
If you want to know more exact memory usage, you should use RSS+CACHE(+SWAP)
value in memory.stat(see 5.2).
If you are reading the accurate files repeatedly, and you have measured your system performance as being limited by cpu usage, you might consider sampling memory_usage instead.
I don't know how it works. However as an LWN.net reader, this sounds similar to a situation where there can be multiple counters which are kept local to where they are used, and where somehow reading usage_in_bytes does not force an immediate synchronization and summary of these counters.
Over the years, kernel developers have made increasing use of per-CPU data in an effort to minimize memory contention and its associated performance penalties. As a simple example, consider the disk operation statistics maintained by the block layer. Incrementing a global counter for every disk operation would cause the associated cache line to bounce continually between processors; disk operations are frequent enough that the performance cost would be measurable. So each CPU maintains its own set of counters locally; it never has to contend with any other CPU to increment one of those counters. When a total count is needed, all of the per-CPU counters are added up. Given that the counters are queried far more rarely than they are modified, storing them in per-CPU form yields a significant performance improvement.
-- https://lwn.net/Articles/258238/
If you have a small system - not a large number of cpus, and not maintaining a large number of cgroups - the overhead doesn't sound very significant. It doesn't cost very much to bounce a few cache lines between cpus. But the efficiency might be useful if you are Google and running thousands of containers on a system :), or if you have some system with thousands of cpus.
add a comment |
usage_in_bytes
For efficiency, as other kernel components, memory cgroup uses some optimization
to avoid unnecessary cacheline false sharing. usage_in_bytes is affected by the
method and doesn't show 'exact' value of memory (and swap) usage, it's a fuzz
value for efficient access. (Of course, when necessary, it's synchronized.)
If you want to know more exact memory usage, you should use RSS+CACHE(+SWAP)
value in memory.stat(see 5.2).
If you are reading the accurate files repeatedly, and you have measured your system performance as being limited by cpu usage, you might consider sampling memory_usage instead.
I don't know how it works. However as an LWN.net reader, this sounds similar to a situation where there can be multiple counters which are kept local to where they are used, and where somehow reading usage_in_bytes does not force an immediate synchronization and summary of these counters.
Over the years, kernel developers have made increasing use of per-CPU data in an effort to minimize memory contention and its associated performance penalties. As a simple example, consider the disk operation statistics maintained by the block layer. Incrementing a global counter for every disk operation would cause the associated cache line to bounce continually between processors; disk operations are frequent enough that the performance cost would be measurable. So each CPU maintains its own set of counters locally; it never has to contend with any other CPU to increment one of those counters. When a total count is needed, all of the per-CPU counters are added up. Given that the counters are queried far more rarely than they are modified, storing them in per-CPU form yields a significant performance improvement.
-- https://lwn.net/Articles/258238/
If you have a small system - not a large number of cpus, and not maintaining a large number of cgroups - the overhead doesn't sound very significant. It doesn't cost very much to bounce a few cache lines between cpus. But the efficiency might be useful if you are Google and running thousands of containers on a system :), or if you have some system with thousands of cpus.
add a comment |
usage_in_bytes
For efficiency, as other kernel components, memory cgroup uses some optimization
to avoid unnecessary cacheline false sharing. usage_in_bytes is affected by the
method and doesn't show 'exact' value of memory (and swap) usage, it's a fuzz
value for efficient access. (Of course, when necessary, it's synchronized.)
If you want to know more exact memory usage, you should use RSS+CACHE(+SWAP)
value in memory.stat(see 5.2).
If you are reading the accurate files repeatedly, and you have measured your system performance as being limited by cpu usage, you might consider sampling memory_usage instead.
I don't know how it works. However as an LWN.net reader, this sounds similar to a situation where there can be multiple counters which are kept local to where they are used, and where somehow reading usage_in_bytes does not force an immediate synchronization and summary of these counters.
Over the years, kernel developers have made increasing use of per-CPU data in an effort to minimize memory contention and its associated performance penalties. As a simple example, consider the disk operation statistics maintained by the block layer. Incrementing a global counter for every disk operation would cause the associated cache line to bounce continually between processors; disk operations are frequent enough that the performance cost would be measurable. So each CPU maintains its own set of counters locally; it never has to contend with any other CPU to increment one of those counters. When a total count is needed, all of the per-CPU counters are added up. Given that the counters are queried far more rarely than they are modified, storing them in per-CPU form yields a significant performance improvement.
-- https://lwn.net/Articles/258238/
If you have a small system - not a large number of cpus, and not maintaining a large number of cgroups - the overhead doesn't sound very significant. It doesn't cost very much to bounce a few cache lines between cpus. But the efficiency might be useful if you are Google and running thousands of containers on a system :), or if you have some system with thousands of cpus.
usage_in_bytes
For efficiency, as other kernel components, memory cgroup uses some optimization
to avoid unnecessary cacheline false sharing. usage_in_bytes is affected by the
method and doesn't show 'exact' value of memory (and swap) usage, it's a fuzz
value for efficient access. (Of course, when necessary, it's synchronized.)
If you want to know more exact memory usage, you should use RSS+CACHE(+SWAP)
value in memory.stat(see 5.2).
If you are reading the accurate files repeatedly, and you have measured your system performance as being limited by cpu usage, you might consider sampling memory_usage instead.
I don't know how it works. However as an LWN.net reader, this sounds similar to a situation where there can be multiple counters which are kept local to where they are used, and where somehow reading usage_in_bytes does not force an immediate synchronization and summary of these counters.
Over the years, kernel developers have made increasing use of per-CPU data in an effort to minimize memory contention and its associated performance penalties. As a simple example, consider the disk operation statistics maintained by the block layer. Incrementing a global counter for every disk operation would cause the associated cache line to bounce continually between processors; disk operations are frequent enough that the performance cost would be measurable. So each CPU maintains its own set of counters locally; it never has to contend with any other CPU to increment one of those counters. When a total count is needed, all of the per-CPU counters are added up. Given that the counters are queried far more rarely than they are modified, storing them in per-CPU form yields a significant performance improvement.
-- https://lwn.net/Articles/258238/
If you have a small system - not a large number of cpus, and not maintaining a large number of cgroups - the overhead doesn't sound very significant. It doesn't cost very much to bounce a few cache lines between cpus. But the efficiency might be useful if you are Google and running thousands of containers on a system :), or if you have some system with thousands of cpus.
answered Jun 22 '18 at 11:25
sourcejedisourcejedi
25.5k445110
25.5k445110
add a comment |
add a comment |
I think I am seeing inconsistency when viewing memory.usage_in_bytes when the process under the two scenarios.
Scenario1: Process created directly under a cgroup
Memory usage shown looks correct.
# cgexec -g memory:mem128 sleep 30 &
[2] 18339
# cat /sys/fs/cgroup/memory/mem128/memory.usage_in_bytes
135168
Scenario2: Process created separately and then assigned to a cgroup.
Memory usage shown is incorrect. 36864 seems incorrect. Sometimes is shows 0
as well. Why is this different than the scenario 1 shown above?
# sleep 90 &
[2] 18937
# cgclassify -g memory:/mem128 18937
# cat /sys/fs/cgroup/memory/mem128/memory.usage_in_bytes
36864
New contributor
user7681939 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
I think I am seeing inconsistency when viewing memory.usage_in_bytes when the process under the two scenarios.
Scenario1: Process created directly under a cgroup
Memory usage shown looks correct.
# cgexec -g memory:mem128 sleep 30 &
[2] 18339
# cat /sys/fs/cgroup/memory/mem128/memory.usage_in_bytes
135168
Scenario2: Process created separately and then assigned to a cgroup.
Memory usage shown is incorrect. 36864 seems incorrect. Sometimes is shows 0
as well. Why is this different than the scenario 1 shown above?
# sleep 90 &
[2] 18937
# cgclassify -g memory:/mem128 18937
# cat /sys/fs/cgroup/memory/mem128/memory.usage_in_bytes
36864
New contributor
user7681939 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
I think I am seeing inconsistency when viewing memory.usage_in_bytes when the process under the two scenarios.
Scenario1: Process created directly under a cgroup
Memory usage shown looks correct.
# cgexec -g memory:mem128 sleep 30 &
[2] 18339
# cat /sys/fs/cgroup/memory/mem128/memory.usage_in_bytes
135168
Scenario2: Process created separately and then assigned to a cgroup.
Memory usage shown is incorrect. 36864 seems incorrect. Sometimes is shows 0
as well. Why is this different than the scenario 1 shown above?
# sleep 90 &
[2] 18937
# cgclassify -g memory:/mem128 18937
# cat /sys/fs/cgroup/memory/mem128/memory.usage_in_bytes
36864
New contributor
user7681939 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
I think I am seeing inconsistency when viewing memory.usage_in_bytes when the process under the two scenarios.
Scenario1: Process created directly under a cgroup
Memory usage shown looks correct.
# cgexec -g memory:mem128 sleep 30 &
[2] 18339
# cat /sys/fs/cgroup/memory/mem128/memory.usage_in_bytes
135168
Scenario2: Process created separately and then assigned to a cgroup.
Memory usage shown is incorrect. 36864 seems incorrect. Sometimes is shows 0
as well. Why is this different than the scenario 1 shown above?
# sleep 90 &
[2] 18937
# cgclassify -g memory:/mem128 18937
# cat /sys/fs/cgroup/memory/mem128/memory.usage_in_bytes
36864
New contributor
user7681939 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
edited yesterday
Archemar
20.4k93973
20.4k93973
New contributor
user7681939 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
answered yesterday
user7681939user7681939
1
1
New contributor
user7681939 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
user7681939 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
user7681939 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f451252%2fcgroup-memory-usage-in-bytes-shows-incorrect-value%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
A related question is unix.stackexchange.com/questions/449911 .
– JdeBP
Jun 22 '18 at 10:16