From owner-svn-src-all@FreeBSD.ORG Fri Dec 19 16:08:41 2008 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 38A1A1065673; Fri, 19 Dec 2008 16:08:41 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 28E968FC1B; Fri, 19 Dec 2008 16:08:41 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id mBJG8f6A076592; Fri, 19 Dec 2008 16:08:41 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id mBJG8f4l076591; Fri, 19 Dec 2008 16:08:41 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <200812191608.mBJG8f4l076591@svn.freebsd.org> From: Konstantin Belousov Date: Fri, 19 Dec 2008 16:08:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-releng@freebsd.org X-SVN-Group: releng MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r186328 - in releng/7.1/sys: . contrib/pf dev/cxgb kern X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 19 Dec 2008 16:08:41 -0000 Author: kib Date: Fri Dec 19 16:08:40 2008 New Revision: 186328 URL: http://svn.freebsd.org/changeset/base/186328 Log: MFC r185983: The userland_sysctl() function retries sysctl_root() until returned error is not EAGAIN. Several sysctls that inspect another process use p_candebug() for checking access right for the curproc. p_candebug() returns EAGAIN for some reasons, in particular, for the process doing exec() now. If execing process tries to lock Giant, we get a livelock, because sysctl handlers are covered by Giant, and often do not sleep. Break the livelock by dropping Giant and allowing other threads to execute in the EAGAIN loop. This commit does not merge the following change, as was discussed with jhb: [Also, do not return EAGAIN from p_candebug() when process is executing, use more appropriate EBUSY error.] MFC r185987: Uio_yield() already does DROP_GIANT/PICKUP_GIANT, no need to repeat this around the call. Approved by: re (kensmith) Modified: releng/7.1/sys/ (props changed) releng/7.1/sys/contrib/pf/ (props changed) releng/7.1/sys/dev/cxgb/ (props changed) releng/7.1/sys/kern/kern_sysctl.c Modified: releng/7.1/sys/kern/kern_sysctl.c ============================================================================== --- releng/7.1/sys/kern/kern_sysctl.c Fri Dec 19 16:03:20 2008 (r186327) +++ releng/7.1/sys/kern/kern_sysctl.c Fri Dec 19 16:08:40 2008 (r186328) @@ -52,6 +52,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include @@ -1395,11 +1396,14 @@ userland_sysctl(struct thread *td, int * SYSCTL_LOCK(); - do { + for (;;) { req.oldidx = 0; req.newidx = 0; error = sysctl_root(0, name, namelen, &req); - } while (error == EAGAIN); + if (error != EAGAIN) + break; + uio_yield(); + } if (req.lock == REQ_WIRED && req.validlen > 0) vsunlock(req.oldptr, req.validlen);