Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Discussion & Documentation Documentation, Tips & Tricks
  • Search

Google-chrome & control groups

Unofficial documentation for various parts of Gentoo Linux. Note: This is not a support forum.
Post Reply
Advanced search
1 post • Page 1 of 1
Author
Message
Kollin
Veteran
Veteran
User avatar
Posts: 1139
Joined: Sat Feb 25, 2006 12:42 am
Location: Sofia/Bulgaria

Google-chrome & control groups

  • Quote

Post by Kollin » Sun Feb 15, 2015 1:20 pm

I'm going to forget what i did learn about the control groups so I'm posting it here. Use it at your own risk!

I fed up Chrome eating all my memory so i put in a cage... the control groups way.

My kernel config diff:

diff -y ".config.cgroups" ".config" > diff_configcgroups_config1

http://pastebin.com/sAxdRNGa

the short version:

diff -y --suppress-common-lines ".config.cgroups" ".config" > diff_configcgroups_config2

http://pastebin.com/vAjeY8q1

Don't forget to enable control groups in openrc file:///etc/rc.conf:

Code: Select all

rc_controller_cgroups="YES"
You should install dev-libs/libcgroup also.

and:

Code: Select all

rc-update add cgred boot
control group configs in /etc/cgroup/

file:///etc/cgroup/cgconfig.conf:

Code: Select all

#
#  Copyright IBM Corporation. 2007
#
#  Authors:	Balbir Singh <balbir@linux.vnet.ibm.com>
#  This program is free software; you can redistribute it and/or modify it
#  under the terms of version 2.1 of the GNU Lesser General Public License
#  as published by the Free Software Foundation.
#
#  This program is distributed in the hope that it would be useful, but
#  WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
#group daemons/www {
#	perm {
#		task {
#			uid = root;
#			gid = webmaster;
#		}
#		admin {
#			uid = root;
#			gid = root;
#		}
#	}
#	cpu {
#		cpu.shares = 1000;
#	}
#}
#
#group daemons/ftp {
#	perm {
#		task {
#			uid = root;
#			gid = ftpmaster;
#		}
#		admin {
#			uid = root;
#			gid = root;
#		}
#	}
#	cpu {
#		cpu.shares = 500;
#	}
#}
#

# Prevent Chromium from taking all memory
group chromium {
    perm {
        admin {
            uid = kollin;
        }
        task {
            uid = kollin;
        }
    }
    cpu {
#       Set the relative share of CPU resources equal to 25%
        cpu.shares = "256";
}
    cpuset {
        cpuset.mems="0";
        cpuset.cpus="0-0";
}
    memory {
# 1 GiB (1073741824 bytes) and total memory of 11G limit
        memory.limit_in_bytes = 1G;
        memory.memsw.limit_in_bytes = 11G;
        memory.oom_control= 0;
    }
}


mount {
        cpuset  = /cgroup/cpuset;
        cpu     = /cgroup/cpu;
        cpuacct = /cgroup/cpuacct;
        memory  = /cgroup/memory;
        devices = /cgroup/devices;
        freezer = /cgroup/freezer;
        #blkio   = /cgroup/blkio;
        "name=openrc" = /cgroup/blkio;
}
blkio is commented out because it refused to mount.
memory.limit_in_bytes = 1G; - i'm limiting physical memory usage to 1G
memory.memsw.limit_in_bytes = 11G; all available memory for Chrome will be 11G physical+swap, then comes
memory.oom_control= 0; which will kill Chrome if exceeds the limit of 11G total
cpuset.cpus="0-0"; means that Chrome will be run only at core0 of my CPU.
cpu.shares = "256"; means that Chrome will not use more than 1/4 of CPU time compared to other processes

file:///etc/cgroup/cgrules.conf (here you decide what control groups will be available for Chrome)

Code: Select all

# /etc/cgrules.conf
#The format of this file is described in cgrules.conf(5)
#manual page.
#
# Example:
#<user>		<controllers>	<destination>
#@student	cpu,memory	usergroup/student/
#peter		cpu		test1/
#%		memory		test2/
kollin:/usr/bin/google-chrome-stable		cpuset,cpu,memory		chromium
kollin:/opt/google/chrome/google-chrome		cpuset,cpu,memory		chromium
kollin:/opt/google/chrome/chrome		cpuset,cpu,memory		chromium
#kollin:/usr/bin/google-chrome-stable		cpuset,memory		chromium
#kollin:/opt/google/chrome/google-chrome	cpuset,memory		chromium
#kollin:/opt/google/chrome/chrome		cpuset,memory		chromium
#kollin:/usr/bin/google-chrome-stable		cpu,memory		chromium
#kollin:/opt/google/chrome/google-chrome	cpu,memory		chromium
#kollin:/opt/google/chrome/chrome		cpu,memory		chromium
# End of file
How to start Chrome in a cage:

Code: Select all

cgexec -g memory:/chromium --sticky /usr/bin/google-chrome-stable %U
or

Code: Select all

cgexec -g memory,cpu:/chromium --sticky /usr/bin/google-chrome-stable %U
or

Code: Select all

cgexec -g memory,cpu,cpuset:/chromium --sticky /usr/bin/google-chrome-stable %U
depending on the cgroup you want it to be started in: memory cgroup only, memory+cpu, or memmory+cpu+cpuset
--sticky makes it sure that no child process can escape out of the control group.

The bottom line:
It worked, but Chrome becomes unusable that way, it gets very slooooooowwwwwww and hogs the hard drive.

So, good bye Chrome welcome Firefox again!
"Dear Enemy: may the Lord hate you and all your kind, may you be turned orange in hue, and may your head fall off at an awkward moment."
"Linux is like a wigwam - no windows, no gates, apache inside..."
Top
Post Reply
1 post • Page 1 of 1

Return to “Documentation, Tips & Tricks”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy

 

 

magic