Hot answers tagged

18

You can't do that as a normal user. But you can setup a cgroup as root, and make it configurable by your user. If you do not already have the default cgroups controllers mounted by e.g. systemd: $ sudo mount -t tmpfs cgroup_root /sys/fs/cgroup $ sudo mkdir /sys/fs/cgroup/cpuset $ sudo mount -t cgroup -o cpuset cpuset /sys/fs/cgroup/cpuset Create a cgroup: ...


16

I have been able to reproduce and solve the issue doing : /bin/echo 0 >/cgroups/test/cpuset.mems /bin/echo 0 >/cgroups/test/cpuset.cpus Seems that CPUs and Memory Nodes' list for the cpuset were created with empty values when the test folder was created. Hope it will work for you also.


15

If you're using systemd-nspawn, start up your container with the --capability=CAP_MKNOD command line switch. This will allow you to create device nodes inside your container. Then create a loop device like this: # mknod /dev/loop0 b 7 0 Remember that this loop device is shared with the host and is called /dev/loop0 there as well. And that it is now ...


13

Using systemd (PID 3378 for example): # systemctl status 3378 | grep CGroup CGroup: /user.slice/user-1000.slice/session-3.scope Using proc: # cat /proc/3378/cgroup 10:memory:/user.slice/user-1000.slice 9:blkio:/user.slice/user-1000.slice 8:net_cls,net_prio:/ 7:cpu,cpuacct:/user.slice/user-1000.slice 6:perf_event:/ 5:freezer:/ 4:cpuset:/ 3:pids:/user....


13

Edit: I'll keep my original answer below, but I'll try to explain what's happening here and provide a general solution for you. Edit 2: Provided another option. The problem that you're hitting here has to do with how the kernel manages I/O. When you make a write to your filesystem, that write isn't immediately committed to disk; that would be incredibly ...


11

I know of only 2 cgroups related to network, net_prio (set the priority of network traffic) and net_cls (tags packets to allow identification by Linux tc). net_prio has been introduced in Linux Kernel 3.3, so it is normal that you do not see it in Ubuntu LTS 12.04 unless you installed the LTS hardware enablement stack (which gets you a Linux Kernel 3.5), ...


9

The OOM killer decided to kill another process. The message did state: Kill process 20911 .... or sacrifice child It decided to kill the child with pid 20977, a shell script that was spawned by the process. If you want Linux to always kill the task which caused the out of memory condition, set the sysctl vm.oom_kill_allocating_task to 1. From the kernel ...


9

Loop devices are provided by a kernel module. Therefore, you need special privileges to access them. You also need them to be exposed into your container, or you need to manually create the device files. The quick answer docker run --privileged=true ... An alternative sudo losetup /dev/loop0 test.img mount /dev/loop0 /mnt docker run -v /mnt:/mnt ... ...


8

Answering my own question. I've used SystemTap to hook into the OOM killer: #!/usr/bin/env stap %{ #include <linux/cgroup.h> %} function find_mem_cgroup:string(task:long) %{ struct cgroup *cgrp; struct task_struct *tsk = (struct task_struct *)((long)THIS->task); /* Initialize with an empty value */ strcpy(THIS->__retvalue, "NULL"); ...


8

The quickest way to view cgroup of a process is by process name, using this bash script: #!/bin/bash THISPID=`ps -eo pid,comm | grep $1 | awk '{print $1}'` cat /proc/$THISPID/cgroup


5

**Note: Undeleting for posterity ** Your problem is here # No alternate memory nodes if the system is not NUMA # On computenodes use all available cores cpuset { cpuset.mems="0"; cpuset.cpus="0-47"; } } You are only ever using one node of memory. You need to set this to use all nodes of memory. I also think the below applies too, ...


5

Seems a duplicate of this: https://stackoverflow.com/questions/33269339/htop-process-viewer-set-column-width In short, in current versions the column width is fixed. You can ask for this enhancement to the devs or implement it yourself :-) You can use ps to find the processes in control groups you're interested in.


5

Please try for example systemctl set-property user-1000.slice CPUShares=100 Assuming you wish to limit the resource for UID 1000 and limit the CPUShares.


5

From the cpusets documentation: Calls to sched_setaffinity are filtered to just those CPUs allowed in that task's cpuset. This implies that CPU affinity masks are intersected with the cpus in the cgroup that the process is a member of. E.g. If the affinity mask of a process includes cores {0, 1, 3} and the process is running on the system cgroup, ...


4

You have to pass an -o to tell it what to mount. mount -t cgroup -o memory cgroup_memory /sys/fs/cgroup/memory And that's assuming that /sys/fs/cgroup is mounted at all. mount -t tmpfs cgroup /sys/fs/cgroup Ubuntu has a package named cgroup-lite which can do all this at boot. It doesn't appear to be in Debian so I'm not sure what the equivalent might be. ...


4

iptables support for -m cgroup has not yet been released, but you can easily build the extension yourself and install it on your system: git clone git://git.netfilter.org/iptables.git cd iptables ./autogen.sh ./configure make -k sudo cp extensions/libxt_cgroup.so /lib/xtables/ sudo chmod -x /lib/xtables/libxt_cgroup.so


4

From RHEL7 and up, and on some other distro's, I find this util helpful: $ systemd-cgtop Before using it, make sure you have DefaultCPUAccounting=yes in /etc/systemd/system.conf. I even made some improvements to Egbert's script that is still useful and used Patrick's suggestion to use pgrep: #!/bin/bash echo "PID SLICE SERVICE" for THISPID in `pgrep $...


4

The very, very bottom of the kernel documentation on blkio controller includes the note: What works Currently only sync IO queues are support. All the buffered writes are still system wide and not per group. Hence we will not see service differentiation between buffered writes between groups. Practically, this means that write operations ...


4

It seems to work if done this way: $ systemd-run --scope --user --unit limit-test.scope -p MemoryAccounting=yes -p MemoryLimit='10M' bash and then checking the status: $ systemctl show --user limit-test.scope | grep Mem MemoryCurrent=18446744073709551615 MemoryAccounting=yes MemoryLimit=10485760 The key being to pass in the property with the -p flag. ...


4

Ok, so the correct answer is that you cannot setup cgroup limits for user processes (at the time of writing this answer, anyway). Ref from systemd-devel mailing list: We simply do not support this right now. Unprivileged users do not get access to the cgroup properties of the various controllers right now, simply because this is unsafe. We can ...


4

You don't have enough RAM to run these 2000 processes. We can see here that you have used all of your 64GB of RAM, and are also using an additional 17GB of swap. Your server is thrashing, trying to swap data in and out, valiantly trying to let each of those 2000 processes do something. But of course it's not working. There are only two solutions here: ...


4

There's a small typo in your GRUB configuration; cgroup not cggroup should do the trick: GRUB_CMDLINE_LINUX_DEFAULT="cgroup_enable=memory swapaccount=1"


4

I was able to freeze and thaw a single process (xeyes) rather easily using these directions: https://www.kernel.org/doc/Documentation/cgroup-v1/freezer-subsystem.txt I know it's the same document that you linked to, but I don't see an issue with doing it this way. You could easily write a script/program to automate this all for you and freeze individual ...


4

Creat a group-name.slice, and set the resource control configuration in the slice unit, such as, CPUShares=, MemoryLimit=. Then set Slice=group-name.slice in the process-name.service. See man systemd.resource-control for details.


3

Lvm volume is a normal block device, so you can configure various process priorities on lvm volume using cgroup, for more information read this doc https://www.kernel.org/doc/Documentation/cgroups/blkio-controller.txt example: lvdisplay -v /dev/vg00/rootvol | grep "Block device" echo "$MAJOR:$MINOR $((1024*250))" > /sys/fs/cgroup/blkio/blkio....


3

It depends on your distribution and kernel version. You can use following script from Docker to test cgroups and container related features: wget https://raw.githubusercontent.com/docker/docker/master/contrib/check-config.sh -O cgroups_check && chmod +x cgroups_check ./cgroups_check


3

Is your file writing to /tmp? If so, it might not be on an actual filesystem but resident on disk. Thus as you write to it, more and more memory is taken away to meed the needs of the file. Eventually, you run out of memory+swap space and your performance deteriorates to the point of utter frustration.


3

Configuration is little different from Ubuntu. You need to add CGROUP_DAEMON=sets:name in /etc/sysconfig/libvirtd. in your case it is CGROUP_DAEMON=memory:/mynamekvm Restart all relavant services that is cgconfig,libvirt and guests. Also make sure selinux is configured properly or try disabling and then restart services.


3

The Centos 6.5 server is a Virtualized server running Virtuozzo (A Media Temple DV). It seems there would need to be some changes in the Virtuozzo provisioning of the server which the hosting company is not prepared to do. Apparently Virtuozzo does support running docker in Centos 7 but that's not something I am going to pursue. More info here. Bottom line ...


3

cgroup controllers can only be mounted in one hierarchy (v1 or v2). If you have a controller mounted on a legacy v1 hierarchy, then it won't show up in the cgroup2 hiearchy. This limitation is documented in cgroup-v2 - Mounting as well as the cgroups(7) manual page: It is not possible to mount the same controller against multiple cgroup hierarchies. ...


Only top voted, non community-wiki answers of a minimum length are eligible