conf/123222: Add rtprio(1)/idprio(1) support to rc.subr(8).
Norikatsu Shigemura
nork at FreeBSD.org
Tue Apr 29 17:00:07 UTC 2008
>Number: 123222
>Category: conf
>Synopsis: Add rtprio(1)/idprio(1) support to rc.subr(8).
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: change-request
>Submitter-Id: current-users
>Arrival-Date: Tue Apr 29 17:00:06 UTC 2008
>Closed-Date:
>Last-Modified:
>Originator: Norikatsu Shigemura
>Release: FreeBSD 8.0-CURRENT i386
>Organization:
FreeBSD
>Environment:
System: FreeBSD melfina.ninth-nine.com 8.0-CURRENT FreeBSD 8.0-CURRENT #33: Mon Apr 28 06:03:33 JST 2008 nork at melfina.ninth-nine.com:/usr/obj/usr/src/sys/MELFINA i386
>Description:
I want to run some daemons with rtprio(1)/idprio(1) like nice(1).
So I made patches to support rtprio(1)/idprio(1) to rc.subr(8).
Ex.
# /etc/rc.conf
canna_enable="YES"
canna_rtprio="31"
As a result, I got more interactive performance than before.
>How-To-Repeat:
N/A
>Fix:
I made 4 patches for FreeBSD 4 major versions.
rc.subr-8current.diff
src/etc/rc.subr
src/share/man/man8/rc.subr.8
rc.subr-7stable.diff
src/etc/rc.subr
rc.subr-6stable.diff
src/etc/rc.subr
rc.subr-5stable.diff
src/etc/rc.subr
--- rc.subr-8current.diff begins here ---
Index: src/etc/rc.subr
===================================================================
RCS file: /home/ncvs/src/etc/rc.subr,v
retrieving revision 1.80
diff -u -r1.80 rc.subr
--- src/etc/rc.subr 26 Jan 2008 11:22:11 -0000 1.80
+++ src/etc/rc.subr 29 Apr 2008 16:09:07 -0000
@@ -424,6 +424,10 @@
#
# ${name}_nice n Nice level to run ${command} at.
#
+# ${name}_rtprio n Realtime scheduling priority to run ${command} at.
+#
+# ${name}_idprio n Idletime scheduling priority to run ${command} at.
+#
# ${name}_user n User to run ${command} as, using su(1) if not
# using ${name}_chroot.
# Requires /usr to be mounted.
@@ -600,7 +604,8 @@
fi
eval _chdir=\$${name}_chdir _chroot=\$${name}_chroot \
_nice=\$${name}_nice _user=\$${name}_user \
- _group=\$${name}_group _groups=\$${name}_groups
+ _group=\$${name}_group _groups=\$${name}_groups \
+ _rtprio=\$${name}_rtprio _idprio=\$${name}_idprio
if [ -n "$_user" ]; then # unset $_user if running as that user
if [ "$_user" = "$(eval $IDCMD)" ]; then
@@ -677,6 +682,8 @@
if [ -n "$_chroot" ]; then
_doit="\
${_nice:+nice -n $_nice }\
+${_rtprio:+rtprio $_rtprio }\
+${_idprio:+idprio $_idprio }\
chroot ${_user:+-u $_user }${_group:+-g $_group }${_groups:+-G $_groups }\
$_chroot $command $rc_flags $command_args"
else
@@ -686,12 +693,20 @@
if [ -n "$_user" ]; then
_doit="su -m $_user -c 'sh -c \"$_doit\"'"
fi
- if [ -n "$_nice" ]; then
+ if [ -n "$_nice$_rtprio$_idprio" ]; then
if [ -z "$_user" ]; then
_doit="sh -c \"$_doit\""
- fi
+ fi
+ fi
+ if [ -n "$_nice" ]; then
_doit="nice -n $_nice $_doit"
fi
+ if [ -n "$_rtprio" ]; then
+ _doit="rtprio $_rtprio $_doit"
+ fi
+ if [ -n "$_idprio" ]; then
+ _doit="idprio $_idprio $_doit"
+ fi
fi
# run the full command
Index: src/share/man/man8/rc.subr.8
===================================================================
RCS file: /home/ncvs/src/share/man/man8/rc.subr.8,v
retrieving revision 1.20
diff -u -r1.20 rc.subr.8
--- src/share/man/man8/rc.subr.8 31 Mar 2008 14:11:37 -0000 1.20
+++ src/share/man/man8/rc.subr.8 29 Apr 2008 16:30:21 -0000
@@ -607,6 +607,22 @@
Only supported after
.Pa /usr
is mounted.
+.It Va ${name}_rtprio
+.Xr rtprio 1
+priority to run
+.Va command
+as.
+Only supported after
+.Pa /usr
+is mounted.
+.It Va ${name}_idprio
+.Xr idprio 1
+priority to run
+.Va command
+as.
+Only supported after
+.Pa /usr
+is mounted.
.It Va ${name}_program
Full path to the command.
Overrides
--- rc.subr-8current.diff ends here ---
--- rc.subr-7stable.diff begins here ---
Index: rc.subr
===================================================================
RCS file: /home/ncvs/src/etc/rc.subr,v
retrieving revision 1.77
diff -u -r1.77 rc.subr
--- rc.subr 9 Oct 2007 07:20:44 -0000 1.77
+++ rc.subr 29 Apr 2008 16:11:13 -0000
@@ -423,6 +423,10 @@
#
# ${name}_nice n Nice level to run ${command} at.
#
+# ${name}_rtprio n Realtime scheduling priority to run ${command} at.
+#
+# ${name}_idprio n Idletime scheduling priority to run ${command} at.
+#
# ${name}_user n User to run ${command} as, using su(1) if not
# using ${name}_chroot.
# Requires /usr to be mounted.
@@ -591,7 +595,8 @@
fi
eval _chdir=\$${name}_chdir _chroot=\$${name}_chroot \
_nice=\$${name}_nice _user=\$${name}_user \
- _group=\$${name}_group _groups=\$${name}_groups
+ _group=\$${name}_group _groups=\$${name}_groups \
+ _rtprio=\$${name}_rtprio _idprio=\$${name}_idprio
if [ -n "$_user" ]; then # unset $_user if running as that user
if [ "$_user" = "$(eval $IDCMD)" ]; then
@@ -662,6 +667,8 @@
if [ -n "$_chroot" ]; then
_doit="\
${_nice:+nice -n $_nice }\
+${_rtprio:+rtprio $_rtprio }\
+${_idprio:+idprio $_idprio }\
chroot ${_user:+-u $_user }${_group:+-g $_group }${_groups:+-G $_groups }\
$_chroot $command $rc_flags $command_args"
else
@@ -671,12 +678,20 @@
if [ -n "$_user" ]; then
_doit="su -m $_user -c 'sh -c \"$_doit\"'"
fi
- if [ -n "$_nice" ]; then
+ if [ -n "$_nice$_rtprio$_idprio" ]; then
if [ -z "$_user" ]; then
_doit="sh -c \"$_doit\""
- fi
+ fi
+ fi
+ if [ -n "$_nice" ]; then
_doit="nice -n $_nice $_doit"
fi
+ if [ -n "$_rtprio" ]; then
+ _doit="rtprio $_rtprio $_doit"
+ fi
+ if [ -n "$_idprio" ]; then
+ _doit="idprio $_idprio $_doit"
+ fi
fi
# run the full command
--- rc.subr-7stable.diff ends here ---
--- rc.subr-6stable.diff begins here ---
Index: rc.subr
===================================================================
RCS file: /home/ncvs/src/etc/rc.subr,v
retrieving revision 1.34.2.23
diff -u -r1.34.2.23 rc.subr
--- rc.subr 25 Oct 2007 14:04:18 -0000 1.34.2.23
+++ rc.subr 29 Apr 2008 16:12:51 -0000
@@ -423,6 +423,10 @@
#
# ${name}_nice n Nice level to run ${command} at.
#
+# ${name}_rtprio n Realtime scheduling priority to run ${command} at.
+#
+# ${name}_idprio n Idletime scheduling priority to run ${command} at.
+#
# ${name}_user n User to run ${command} as, using su(1) if not
# using ${name}_chroot.
# Requires /usr to be mounted.
@@ -591,7 +595,8 @@
fi
eval _chdir=\$${name}_chdir _chroot=\$${name}_chroot \
_nice=\$${name}_nice _user=\$${name}_user \
- _group=\$${name}_group _groups=\$${name}_groups
+ _group=\$${name}_group _groups=\$${name}_groups \
+ _rtprio=\$${name}_rtprio _idprio=\$${name}_idprio
if [ -n "$_user" ]; then # unset $_user if running as that user
if [ "$_user" = "$(eval $IDCMD)" ]; then
@@ -662,6 +667,8 @@
if [ -n "$_chroot" ]; then
_doit="\
${_nice:+nice -n $_nice }\
+${_rtprio:+rtprio $_rtprio }\
+${_idprio:+idprio $_idprio }\
chroot ${_user:+-u $_user }${_group:+-g $_group }${_groups:+-G $_groups }\
$_chroot $command $rc_flags $command_args"
else
@@ -671,12 +678,20 @@
if [ -n "$_user" ]; then
_doit="su -m $_user -c 'sh -c \"$_doit\"'"
fi
- if [ -n "$_nice" ]; then
+ if [ -n "$_nice$_rtprio$_idprio" ]; then
if [ -z "$_user" ]; then
_doit="sh -c \"$_doit\""
- fi
+ fi
+ fi
+ if [ -n "$_nice" ]; then
_doit="nice -n $_nice $_doit"
fi
+ if [ -n "$_rtprio" ]; then
+ _doit="rtprio $_rtprio $_doit"
+ fi
+ if [ -n "$_idprio" ]; then
+ _doit="idprio $_idprio $_doit"
+ fi
fi
# run the full command
--- rc.subr-6stable.diff ends here ---
--- rc.subr-5stable.diff begins here ---
Index: rc.subr
===================================================================
RCS file: /home/ncvs/src/etc/rc.subr,v
retrieving revision 1.31.2.5
diff -u -r1.31.2.5 rc.subr
--- rc.subr 19 Feb 2006 18:36:20 -0000 1.31.2.5
+++ rc.subr 29 Apr 2008 16:19:49 -0000
@@ -371,6 +371,10 @@
#
# ${name}_nice n Nice level to run ${command} at.
#
+# ${name}_rtprio n Realtime scheduling priority to run ${command} at.
+#
+# ${name}_idprio n Idletime scheduling priority to run ${command} at.
+#
# ${name}_user n User to run ${command} as, using su(1) if not
# using ${name}_chroot.
# Requires /usr to be mounted.
@@ -526,7 +530,8 @@
fi
eval _chdir=\$${name}_chdir _chroot=\$${name}_chroot \
_nice=\$${name}_nice _user=\$${name}_user \
- _group=\$${name}_group _groups=\$${name}_groups
+ _group=\$${name}_group _groups=\$${name}_groups \
+ _rtprio=\$${name}_rtprio _idprio=\$${name}_idprio
if [ -n "$_user" ]; then # unset $_user if running as that user
if [ "$_user" = "$(eval $IDCMD)" ]; then
@@ -652,12 +657,16 @@
if [ -n "$_chroot" ]; then
_doit="\
${_nice:+nice -n $_nice }\
+${_rtprio:+rtprio $_rtprio }\
+${_idprio:+idprio $_idprio }\
chroot ${_user:+-u $_user }${_group:+-g $_group }${_groups:+-G $_groups }\
$_chroot $command $rc_flags $command_args"
else
_doit="\
${_chdir:+cd $_chdir; }\
${_nice:+nice -n $_nice }\
+${_rtprio:+rtprio $_rtprio }\
+${_idprio:+idprio $_idprio }\
$command $rc_flags $command_args"
if [ -n "$_user" ]; then
_doit="su -m $_user -c 'sh -c \"$_doit\"'"
--- rc.subr-5stable.diff ends here ---
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-bugs
mailing list