From owner-svn-src-all@freebsd.org Wed Apr 19 16:12:03 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9D285D45738; Wed, 19 Apr 2017 16:12:03 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 51C4A150A; Wed, 19 Apr 2017 16:12:03 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v3JGC2E7081757; Wed, 19 Apr 2017 16:12:02 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v3JGC2j1081756; Wed, 19 Apr 2017 16:12:02 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201704191612.v3JGC2j1081756@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Wed, 19 Apr 2017 16:12:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r317148 - head/sys/compat/linuxkpi/common/src X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 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: Wed, 19 Apr 2017 16:12:03 -0000 Author: markj Date: Wed Apr 19 16:12:02 2017 New Revision: 317148 URL: https://svnweb.freebsd.org/changeset/base/317148 Log: Drop Giant before sleeping in linux_wait_for_{timeout_,}common(). Reported and tested by: Pete Wright Reviewed by: hselasky (previous version) MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D10414 Modified: head/sys/compat/linuxkpi/common/src/linux_compat.c Modified: head/sys/compat/linuxkpi/common/src/linux_compat.c ============================================================================== --- head/sys/compat/linuxkpi/common/src/linux_compat.c Wed Apr 19 15:59:16 2017 (r317147) +++ head/sys/compat/linuxkpi/common/src/linux_compat.c Wed Apr 19 16:12:02 2017 (r317148) @@ -1321,28 +1321,38 @@ linux_complete_common(struct completion long linux_wait_for_common(struct completion *c, int flags) { + long error; + if (SCHEDULER_STOPPED()) return (0); + DROP_GIANT(); + if (flags != 0) flags = SLEEPQ_INTERRUPTIBLE | SLEEPQ_SLEEP; else flags = SLEEPQ_SLEEP; + error = 0; for (;;) { sleepq_lock(c); if (c->done) break; sleepq_add(c, NULL, "completion", flags, 0); if (flags & SLEEPQ_INTERRUPTIBLE) { - if (sleepq_wait_sig(c, 0) != 0) - return (-ERESTARTSYS); + if (sleepq_wait_sig(c, 0) != 0) { + error = -ERESTARTSYS; + goto intr; + } } else sleepq_wait(c, 0); } c->done--; sleepq_release(c); - return (0); +intr: + PICKUP_GIANT(); + + return (error); } /* @@ -1351,18 +1361,22 @@ linux_wait_for_common(struct completion long linux_wait_for_timeout_common(struct completion *c, long timeout, int flags) { - long end = jiffies + timeout; + long end = jiffies + timeout, error; + int ret; if (SCHEDULER_STOPPED()) return (0); + DROP_GIANT(); + if (flags != 0) flags = SLEEPQ_INTERRUPTIBLE | SLEEPQ_SLEEP; else flags = SLEEPQ_SLEEP; - for (;;) { - int ret; + error = 0; + ret = 0; + for (;;) { sleepq_lock(c); if (c->done) break; @@ -1375,16 +1389,20 @@ linux_wait_for_timeout_common(struct com if (ret != 0) { /* check for timeout or signal */ if (ret == EWOULDBLOCK) - return (0); + error = 0; else - return (-ERESTARTSYS); + error = -ERESTARTSYS; + goto intr; } } c->done--; sleepq_release(c); +intr: + PICKUP_GIANT(); + /* return how many jiffies are left */ - return (linux_timer_jiffies_until(end)); + return (ret != 0 ? error : linux_timer_jiffies_until(end)); } int