Bug 123222

Summary: [patch] Add rtprio(1)/idprio(1) support to rc.subr(8).
Product: Base System Reporter: Norikatsu Shigemura <nork>
Component: confAssignee: freebsd-bugs (Nobody) <bugs>
Status: Open ---    
Severity: Affects Only Me Keywords: patch
Priority: Normal    
Version: 8.0-CURRENT   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
rc.subr-8current.diff
none
rc.subr-6stable.diff
none
file.diff none

Description Norikatsu Shigemura freebsd_committer freebsd_triage 2008-04-29 18:00:06 UTC
	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.

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

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 ---
How-To-Repeat: 	N/A
Comment 1 Norikatsu Shigemura freebsd_committer freebsd_triage 2008-04-29 18:07:25 UTC
Responsible Changed
From-To: freebsd-bugs->freebsd-rc

Over to rc.subr(8) maintainers.
Comment 2 Kris Kennaway freebsd_committer freebsd_triage 2008-04-30 09:14:59 UTC
Norikatsu Shigemura wrote:

>> 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).

idprio is dangerous and should not be used unless you are sure you know 
what you're doing (it can cause deadlocks from priority inversion). 
There might be similar issues with rtprio.

Kris
Comment 3 Eitan Adler freebsd_committer freebsd_triage 2017-12-31 07:59:15 UTC
For bugs matching the following criteria:

Status: In Progress Changed: (is less than) 2014-06-01

Reset to default assignee and clear in-progress tags.

Mail being skipped
Comment 4 Graham Perrin freebsd_committer freebsd_triage 2022-10-17 12:39:39 UTC
Keyword: 

    patch
or  patch-ready

– in lieu of summary line prefix: 

    [patch]

* bulk change for the keyword
* summary lines may be edited manually (not in bulk). 

Keyword descriptions and search interface: 

    <https://bugs.freebsd.org/bugzilla/describekeywords.cgi>