swap test for cgroups

Mulyadi Santosa mulyadi.santosa at gmail.com
Mon Feb 1 03:42:57 EST 2016


On Sun, Jan 31, 2016 at 3:18 PM, Kevin Wilson <wkevils at gmail.com> wrote:
> Hi,
>
> I had tried to perform the following test according to:
> http://lxr.free-electrons.com/source/Documentation/cgroups/memcg_test.txt#L211
> mkdir /sys/fs/cgroup/memory/group1
>
> echo $$ > /sys/fs/cgroup/memory/group1/cgroup.procs

Hi...

maybe you should test with "echo 0" like mentioned in the example?

IMHO, echo $$ will yield PID of your current PID of task invocation in
bash, and I think that's different with the PID of malloc program you
ran. hence the result you saw

>
> echo 40M >  /sys/fs/cgroup/memory/group1/memory.limit_in_bytes
>
> Run a process which is a very short program, allocating 100MB:
> int main() {
> // Allocate 100 MB
>   void *mem = malloc(1024*1024*100);
>   if (mem)
>       printf("malloc is ok\n");
>   pause();
> }
>
>
> VmSize seems a bit larger than 100MB, and this seems ok, when adding
> the overhead of running a process:
> cat /proc/$$/status | grep VmSize
> VmSize:   116920 kB
>
>
>
> cat   /sys/fs/cgroup/memory/group1/memory.stat  | grep swap
> swap 0
> total_swap 0
>
> cat /proc/$$/status | grep  -i swap
> VmSwap:        0 kB
>
>
> I would expect that the swap will be 60M according to the link to the
> memcg_test.txt mentioned earlier.
>
> Any ideas ?
>
> Regards,
> Kevin
>
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies



-- 
regards,

Mulyadi Santosa
Freelance Linux trainer and consultant

blog: the-hydra.blogspot.com
training: mulyaditraining.blogspot.com<div
id="DDB4FAA8-2DD7-40BB-A1B8-4E2AA1F9FDF2"><table style="border-top:
1px solid #aaabb6; margin-top: 30px;">
	<tr>
		<td style="width: 105px; padding-top: 15px;">
			<a href="https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail"
target="_blank"><img
src="https://ipmcdn.avast.com/images/logo-avast-v1.png" style="width:
90px; height:33px;"/></a>
		</td>
		<td style="width: 470px; padding-top: 20px; color: #41424e;
font-size: 13px; font-family: Arial, Helvetica, sans-serif;
line-height: 18px;">This email has been sent from a virus-free
computer protected by Avast. <br /><a
href="https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail"
target="_blank" style="color: #4453ea;">www.avast.com</a>
		</td>
	</tr>
</table><a href="#DDB4FAA8-2DD7-40BB-A1B8-4E2AA1F9FDF2" width="1"
height="1"></a></div>



More information about the Kernelnewbies mailing list