public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "William Hubbs" <williamh@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/openrc:master commit in: sh/, etc/
Date: Mon, 12 Nov 2012 17:00:43 +0000 (UTC)	[thread overview]
Message-ID: <1352739480.4f19c2f512d9a08599b6bdf1129f508fc9a4e055.WilliamH@OpenRC> (raw)

commit:     4f19c2f512d9a08599b6bdf1129f508fc9a4e055
Author:     Alexander Vershilov <alexander.vershilov <AT> gmail <DOT> com>
AuthorDate: Fri Oct 26 05:05:41 2012 +0000
Commit:     William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Mon Nov 12 16:58:00 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=4f19c2f5

Support cpu usage management for Linux

This commit was modified by William Hubbs as follows:

- The paths in the cgroup fs were put into variables to ease
  maintenance.
- Documentation was added to rc.conf.Linux.
- The services were added originally to openrc/svcname cgroups under the
  controller cgroups, but this left an "openrc" cgroup which was unused.
  Now they are added to individual cgroups with the name openrc_${RC_SVCNAME}.

---
 etc/rc.conf.Linux  |   17 ++++++++++++++---
 sh/runscript.sh.in |   21 +++++++++++++++++----
 2 files changed, 31 insertions(+), 7 deletions(-)

diff --git a/etc/rc.conf.Linux b/etc/rc.conf.Linux
index 909e6a9..6285bde 100644
--- a/etc/rc.conf.Linux
+++ b/etc/rc.conf.Linux
@@ -20,10 +20,21 @@
 # consolefont, numlock, etc ...)
 rc_tty_number=12
 
+##############################################################################
+# CGROUPS RESOURCE MANAGEMENT
+
 # If you have cgroups turned on in your kernel, this switch controls
 # whether or not a group for each controler is mounted under
 # /sys/fs/cgroup.
-# Support for process management by cgroups is planned in the future,
-# so if you turn this off, be aware that you may not be able to use that
-# feature.
+# None of the other options in this section work if this is set to "NO".
 #rc_controller_cgroups="YES"
+
+# These options can be set globally in this file; however, if you do
+# this, the same setting will apply to all of your services.
+# If you want different settings for each service, place the settings in
+# /etc/conf.d/foo for service foo.
+
+# This is the number of CPU shares a service is allowed to use. The
+# default value, set by the kernel, is 1024.
+# Also, this setting is not preserved if you suspend your computer.
+#rc_cgroup_cpu_shares=1024

diff --git a/sh/runscript.sh.in b/sh/runscript.sh.in
index d53d70d..21ff39a 100644
--- a/sh/runscript.sh.in
+++ b/sh/runscript.sh.in
@@ -193,11 +193,24 @@ unset _conf_d
 # Load any system overrides
 sourcex -e "@SYSCONFDIR@/rc.conf"
 
-if [ "$RC_UNAME" = "Linux" -a "$1" = "start" ]; then
-	if [ -d /sys/fs/cgroup/openrc ]; then
-		mkdir -p /sys/fs/cgroup/openrc/${RC_SVCNAME}
-		echo $$ > /sys/fs/cgroup/openrc/${RC_SVCNAME}/tasks
+if [ "$RC_UNAME" = "Linux" -a "$RC_SYS" != "PREFIX" -a "$1" = "start" ]; then
+	openrc_cgroup=/sys/fs/cgroup/openrc
+	if [ -d ${openrc_cgroup} ]; then
+		cgroup=${openrc_cgroup}/${RC_SVCNAME}
+		mkdir -p ${cgroup}
+		[ -f "${cgroup}"/tasks ] && echo 0 > "${cgroup}"/tasks
 	fi
+
+	shares="${rc_cgroup_cpu_shares:-$RC_CGROUP_CPU_SHARES}"
+	if [ -n "${shares}" -a -d /sys/fs/cgroup/cpu ]; then
+		cgroup=/sys/fs/cgroup/cpu/openrc_${RC_SVCNAME}
+		if [ ! -d ${cgroup} ]; then
+			mkdir -p ${cgroup}
+		fi
+		[ -f "${cgroup}"/cpu.shares ] && echo ${shares} > "${cgroup}"/cpu.shares
+		[ -f "${cgroup}"/tasks ] && echo 0 >> "${cgroup}"/tasks
+	fi
+
 	#todo: add processes to cgroups based on settings in conf.d
 fi
 


             reply	other threads:[~2012-11-12 17:00 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-12 17:00 William Hubbs [this message]
  -- strict thread matches above, loose matches on Subject: below --
2017-09-15 18:31 [gentoo-commits] proj/openrc:master commit in: sh/, etc/ William Hubbs
2016-12-17 22:57 William Hubbs
2015-10-06 21:34 William Hubbs
2015-05-08 17:11 William Hubbs
2013-04-25 22:02 William Hubbs
2013-03-12 18:10 William Hubbs
2013-02-19 23:11 William Hubbs
2011-11-17 22:46 William Hubbs
2011-11-17 22:36 William Hubbs

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1352739480.4f19c2f512d9a08599b6bdf1129f508fc9a4e055.WilliamH@OpenRC \
    --to=williamh@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox