From lowell@be-well.no-ip.com  Wed Dec 24 17:56:42 2003
Return-Path: <lowell@be-well.no-ip.com>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP
	id BE82C16A4CE; Wed, 24 Dec 2003 17:56:42 -0800 (PST)
Received: from be-well.no-ip.com (lowellg.ne.client2.attbi.com [66.30.200.37])
	by mx1.FreeBSD.org (Postfix) with ESMTP
	id 7B47843D2D; Wed, 24 Dec 2003 17:56:41 -0800 (PST)
	(envelope-from lowell@be-well.no-ip.com)
Received: by be-well.no-ip.com (Postfix, from userid 1147)
	id 11C2C66; Wed, 24 Dec 2003 20:56:41 -0500 (EST)
Message-Id: <20031225015641.11C2C66@be-well.no-ip.com>
Date: Wed, 24 Dec 2003 20:56:41 -0500 (EST)
From: Lowell Gilbert <freebsd-bugs-local@be-well.ilk.org>
To: FreeBSD-gnats-submit@freebsd.org
Cc: silby@freebsd.org
Subject: [PATCH] hitting process limits produces sub-optimal error messages
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         60550
>Category:       kern
>Synopsis:       [kernel] [patch] hitting process limits produces sub-optimal error messages
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    jh
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Wed Dec 24 18:00:31 PST 2003
>Closed-Date:    Mon May 13 14:02:21 UTC 2013
>Last-Modified:  Mon May 13 14:02:21 UTC 2013
>Originator:     Lowell Gilbert
>Release:        FreeBSD 4.9-STABLE i386
>Organization:
>Environment:
System: FreeBSD be-well.ilk.org 4.9-STABLE FreeBSD 4.9-STABLE #59: Sun Dec 21 16:00:19 EST 2003 root@be-well.ilk.org:/usr/src/sys/compile/BE-WELL i386


	
>Description:

Recent changes to the fork code (to control boot-time interrupt
storms) added some error messages for the cases where process limits
are hit.  These list the UID hitting the limit, but not a process ID,
which would be useful also.

>How-To-Repeat:

Set process limits low with ulimit, then run against the limit.
The console will show a message with your UID and no other info.

>Fix:

I have a proposed patch which just adds the current PID to the printf
statement.  However, I wonder whether it might be even better to
remove the printf completely for the case where process limits (as
opposed to maxproc) are being hit.  [If a task hits other process
limits, there are no comparable messages produced.]




*** kern_fork.c.ORIG    Wed Nov 12 10:40:22 2003
--- kern_fork.c Wed Dec 24 18:51:32 2003
***************
*** 239,245 ****
        uid = p1->p_cred->p_ruid;
        if ((nprocs >= maxproc - 10 && uid != 0) || nprocs >= maxproc) {
                if (ppsratecheck(&lastfail, &curfail, 1))
!                       printf("maxproc limit exceeded by uid %d, please see tuning(7) and login.conf(5).\n", uid);
                tsleep(&forksleep, PUSER, "fork", hz / 2);
                return (EAGAIN);
        }
--- 239,245 ----
        uid = p1->p_cred->p_ruid;
        if ((nprocs >= maxproc - 10 && uid != 0) || nprocs >= maxproc) {
                if (ppsratecheck(&lastfail, &curfail, 1))
!                       printf("maxproc limit exceeded by uid %d (pid %d), please see tuning(7) and login.conf(5).\n", uid, p1->p_pid);
                tsleep(&forksleep, PUSER, "fork", hz / 2);
                return (EAGAIN);
        }
***************
*** 261,267 ****
                 */
                nprocs--;
                if (ppsratecheck(&lastfail, &curfail, 1))
!                       printf("maxproc limit exceeded by uid %d, please see tuning(7) and login.conf(5).\n", uid);
                tsleep(&forksleep, PUSER, "fork", hz / 2);
                return (EAGAIN);
        }
--- 261,267 ----
                 */
                nprocs--;
                if (ppsratecheck(&lastfail, &curfail, 1))
!                       printf("maxproc limit exceeded by uid %d (pid %d), please see tuning(7) and login.conf(5).\n", uid, p1->p_pid);
                tsleep(&forksleep, PUSER, "fork", hz / 2);
                return (EAGAIN);
        }


>Release-Note:
>Audit-Trail:

From: Bruce Evans <bde@zeta.org.au>
To: Lowell Gilbert <freebsd-bugs-local@be-well.no-ip.com>
Cc: FreeBSD-gnats-submit@FreeBSD.org, silby@FreeBSD.org,
	freebsd-gnats-submit@FreeBSD.org
Subject: Re: kern/60550: [PATCH] hitting process limits produces sub-optimal
 error messages
Date: Thu, 25 Dec 2003 16:29:59 +1100 (EST)

 On Wed, 24 Dec 2003, Lowell Gilbert wrote:
 
 > >Description:
 >
 > Recent changes to the fork code (to control boot-time interrupt
 > storms) added some error messages for the cases where process limits
 > are hit.  These list the UID hitting the limit, but not a process ID,
 > which would be useful also.
 
 I agree.
 
 > >Fix:
 >
 > I have a proposed patch which just adds the current PID to the printf
 > statement.  However, I wonder whether it might be even better to
 > remove the printf completely for the case where process limits (as
 > opposed to maxproc) are being hit.  [If a task hits other process
 > limits, there are no comparable messages produced.]
 
 Removing the printf() would also decrease the numbers of printf format
 errors and style bugs instead of increasing them.
 
 > *** kern_fork.c.ORIG    Wed Nov 12 10:40:22 2003
 > --- kern_fork.c Wed Dec 24 18:51:32 2003
 > ***************
 > *** 239,245 ****
 >         uid = p1->p_cred->p_ruid;
 >         if ((nprocs >= maxproc - 10 && uid != 0) || nprocs >= maxproc) {
 >                 if (ppsratecheck(&lastfail, &curfail, 1))
 > !                       printf("maxproc limit exceeded by uid %d, please see tuning(7) and login.conf(5).\n", uid);
 >                 tsleep(&forksleep, PUSER, "fork", hz / 2);
 >                 return (EAGAIN);
 >         }
 > --- 239,245 ----
 >         uid = p1->p_cred->p_ruid;
 >         if ((nprocs >= maxproc - 10 && uid != 0) || nprocs >= maxproc) {
 >                 if (ppsratecheck(&lastfail, &curfail, 1))
 > !                       printf("maxproc limit exceeded by uid %d (pid %d), please see tuning(7) and login.conf(5).\n", uid, p1->p_pid);
 >                 tsleep(&forksleep, PUSER, "fork", hz / 2);
 >                 return (EAGAIN);
 >         }
 > ***************
 > *** 261,267 ****
 >                  */
 >                 nprocs--;
 >                 if (ppsratecheck(&lastfail, &curfail, 1))
 > !                       printf("maxproc limit exceeded by uid %d, please see tuning(7) and login.conf(5).\n", uid);
 >                 tsleep(&forksleep, PUSER, "fork", hz / 2);
 >                 return (EAGAIN);
 >         }
 > --- 261,267 ----
 >                  */
 >                 nprocs--;
 >                 if (ppsratecheck(&lastfail, &curfail, 1))
 > !                       printf("maxproc limit exceeded by uid %d (pid %d), please see tuning(7) and login.conf(5).\n", uid, p1->p_pid);
 >                 tsleep(&forksleep, PUSER, "fork", hz / 2);
 >                 return (EAGAIN);
 >         }
 
 New printf format errors (old ones duplicated)
 - unsigned type uid_t printed using signed format %d
 - typedefed type uid_t printf using a format that is only suitable for
   printing ints.  uid_t actually currently has type uint32_t which is
   never int.
 
 New style bugs:
 - source level: too-long lines longer than before.
 - user-visible level: not-too-long lines now too long.  (The lines were
   shorter than 80 columns assuming that PID_MAX is not much larger than
   its current value of 99999.)
 
 I use the following patches for the old printf format errors and style
 bugs in -current.  Almost all of the messages about tuning(7) have the
 same bugs.  The bugs fixed here are:
 
 Printf format:
 - errors as above.
 - %i is a weird style (AAIK, %i is just an archaic spelling of %d).
 
 Style:
 - English error: comma splice.
 - verboseness.  "please" adds nothing and there is not enough space for it.
 - punctuation.  Kernel messages are conventionally not terminated by a "."
   except possibly for multi-sentence messages, but the one here was.
 - indentation.  The continuation indent in KNF is 4, but 8 was used.
 
 %%%
 Index: kern_fork.c
 ===================================================================
 RCS file: /home/ncvs/src/sys/kern/kern_fork.c,v
 retrieving revision 1.208
 diff -u -2 -r1.208 kern_fork.c
 --- kern_fork.c	29 Oct 2003 15:23:09 -0000	1.208
 +++ kern_fork.c	12 Nov 2003 16:05:21 -0000
 @@ -731,9 +749,10 @@
  	return (0);
  fail:
 -	if (ppsratecheck(&lastfail, &curfail, 1))
 -		printf("maxproc limit exceeded by uid %i, please see tuning(7) and login.conf(5).\n",
 -			uid);
  	sx_xunlock(&allproc_lock);
  	uma_zfree(proc_zone, newproc);
 +	if (ppsratecheck(&lastfail, &curfail, 1))
 +		printf(
 +	"maxproc limit exceeded by uid %lu; see tuning(7) and login.conf(5)\n",
 +		    (u_long)uid);
  	if (p1->p_flag & P_SA) {
  		PROC_LOCK(p1);
 %%%
 
 Bruce
Responsible-Changed-From-To: freebsd-bugs->silby 
Responsible-Changed-By: silby 
Responsible-Changed-When: Thu Dec 25 17:13:33 PST 2003 
Responsible-Changed-Why:  
I'll handle this sometime in the next week. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=60550 

From: Mark Linimon <linimon@lonesome.com>
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/60550: [kernel] [patch] hitting process limits produces
 sub-optimal error messages
Date: Thu, 28 Feb 2013 23:37:10 -0600

 ----- Forwarded message from Lowell Gilbert <freebsd-bugs-local@be-well.ilk.org> -----
 
 Date: Thu, 28 Feb 2013 11:44:26 -0500
 From: Lowell Gilbert <freebsd-bugs-local@be-well.ilk.org>
 To: freebsd-bugs@freebsd.org
 Cc: silby@freebsd.org, BDE@freebsd.org
 Subject: Re: kern/60550: [kernel] [patch] hitting process limits produces
 	sub-optimal error messages
 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (berkeley-unix)
 
 This PR is almost ten years old, but I think it's still a good idea
 (with @bde's changes). Any chance of committing it?
 
 ----- End forwarded message -----

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/60550: commit references a PR
Date: Fri, 19 Apr 2013 15:19:42 +0000 (UTC)

 Author: jh
 Date: Fri Apr 19 15:19:29 2013
 New Revision: 249650
 URL: http://svnweb.freebsd.org/changeset/base/249650
 
 Log:
   Include PID in the error message which is printed when the maxproc limit
   is exceeded. Improve formatting of the message while here.
   
   PR:		kern/60550
   Submitted by:	Lowell Gilbert, bde
 
 Modified:
   head/sys/kern/kern_fork.c
 
 Modified: head/sys/kern/kern_fork.c
 ==============================================================================
 --- head/sys/kern/kern_fork.c	Fri Apr 19 13:40:13 2013	(r249649)
 +++ head/sys/kern/kern_fork.c	Fri Apr 19 15:19:29 2013	(r249650)
 @@ -930,8 +930,8 @@ fork1(struct thread *td, int flags, int 
  fail:
  	sx_sunlock(&proctree_lock);
  	if (ppsratecheck(&lastfail, &curfail, 1))
 -		printf("maxproc limit exceeded by uid %i, please see tuning(7) and login.conf(5).\n",
 -		    td->td_ucred->cr_ruid);
 +		printf("maxproc limit exceeded by uid %u (pid %d); see tuning(7) and login.conf(5)\n",
 +		    td->td_ucred->cr_ruid, p1->p_pid);
  	sx_xunlock(&allproc_lock);
  #ifdef MAC
  	mac_proc_destroy(newproc);
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: open->patched 
State-Changed-By: jh 
State-Changed-When: Fri Apr 19 15:24:58 UTC 2013 
State-Changed-Why:  
Patched in head (r249650). 


Responsible-Changed-From-To: silby->jh 
Responsible-Changed-By: jh 
Responsible-Changed-When: Fri Apr 19 15:24:58 UTC 2013 
Responsible-Changed-Why:  
I committed a change. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=60550 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/60550: commit references a PR
Date: Sun, 12 May 2013 09:42:25 +0000 (UTC)

 Author: jh
 Date: Sun May 12 09:42:17 2013
 New Revision: 250558
 URL: http://svnweb.freebsd.org/changeset/base/250558
 
 Log:
   MFC r249650:
   
   Include PID in the error message which is printed when the maxproc limit
   is exceeded. Improve formatting of the message while here.
   
   PR:		kern/60550
 
 Modified:
   stable/9/sys/kern/kern_fork.c
 Directory Properties:
   stable/9/sys/   (props changed)
 
 Modified: stable/9/sys/kern/kern_fork.c
 ==============================================================================
 --- stable/9/sys/kern/kern_fork.c	Sun May 12 09:33:33 2013	(r250557)
 +++ stable/9/sys/kern/kern_fork.c	Sun May 12 09:42:17 2013	(r250558)
 @@ -929,8 +929,8 @@ fork1(struct thread *td, int flags, int 
  fail:
  	sx_sunlock(&proctree_lock);
  	if (ppsratecheck(&lastfail, &curfail, 1))
 -		printf("maxproc limit exceeded by uid %i, please see tuning(7) and login.conf(5).\n",
 -		    td->td_ucred->cr_ruid);
 +		printf("maxproc limit exceeded by uid %u (pid %d); see tuning(7) and login.conf(5)\n",
 +		    td->td_ucred->cr_ruid, p1->p_pid);
  	sx_xunlock(&allproc_lock);
  #ifdef MAC
  	mac_proc_destroy(newproc);
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: patched->closed 
State-Changed-By: jh 
State-Changed-When: Mon May 13 14:02:00 UTC 2013 
State-Changed-Why:  
Committed to head and stable/9. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=60550 
>Unformatted:
