Date: Fri, 13 Sep 2013 06:39:11 +0000 (UTC) From: Konstantin Belousov <kib@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r255509 - head/sys/kern Message-ID: <201309130639.r8D6dBnC053663@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: kib Date: Fri Sep 13 06:39:10 2013 New Revision: 255509 URL: http://svnweb.freebsd.org/changeset/base/255509 Log: Reduce the scope of the proctree_lock. If several processes cause continuous calls to the uprintf(9), the proctree_lock could be shared-locked for indefinite amount of time, starving exclusive requests. Since proctree_lock is needed for fork() and exit(), this effectively stops the machine. While there, do the similar reduction for tprintf(9). Reported and tested by: pho Reviewed by: ed Sponsored by: The FreeBSD Foundation MFC after: 1 week Approved by: re (glebius) Modified: head/sys/kern/subr_prf.c Modified: head/sys/kern/subr_prf.c ============================================================================== --- head/sys/kern/subr_prf.c Fri Sep 13 06:18:33 2013 (r255508) +++ head/sys/kern/subr_prf.c Fri Sep 13 06:39:10 2013 (r255509) @@ -151,26 +151,25 @@ uprintf(const char *fmt, ...) PROC_LOCK(p); if ((p->p_flag & P_CONTROLT) == 0) { PROC_UNLOCK(p); - retval = 0; - goto out; + sx_sunlock(&proctree_lock); + return (0); } SESS_LOCK(p->p_session); pca.tty = p->p_session->s_ttyp; SESS_UNLOCK(p->p_session); PROC_UNLOCK(p); if (pca.tty == NULL) { - retval = 0; - goto out; + sx_sunlock(&proctree_lock); + return (0); } pca.flags = TOTTY; pca.p_bufr = NULL; va_start(ap, fmt); tty_lock(pca.tty); + sx_sunlock(&proctree_lock); retval = kvprintf(fmt, putchar, &pca, 10, ap); tty_unlock(pca.tty); va_end(ap); -out: - sx_sunlock(&proctree_lock); return (retval); } @@ -219,13 +218,13 @@ vtprintf(struct proc *p, int pri, const pca.p_bufr = NULL; if (pca.tty != NULL) tty_lock(pca.tty); + sx_sunlock(&proctree_lock); kvprintf(fmt, putchar, &pca, 10, ap); if (pca.tty != NULL) tty_unlock(pca.tty); if (sess != NULL) sess_release(sess); msgbuftrigger = 1; - sx_sunlock(&proctree_lock); } /*
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201309130639.r8D6dBnC053663>