From owner-svn-src-all@freebsd.org Fri Nov 27 18:19:13 2015 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 0D0ACA3A75D; Fri, 27 Nov 2015 18:19:13 +0000 (UTC) (envelope-from zbb@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 CD51817DB; Fri, 27 Nov 2015 18:19:12 +0000 (UTC) (envelope-from zbb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id tARIJBNT019143; Fri, 27 Nov 2015 18:19:11 GMT (envelope-from zbb@FreeBSD.org) Received: (from zbb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id tARIJB9e019142; Fri, 27 Nov 2015 18:19:11 GMT (envelope-from zbb@FreeBSD.org) Message-Id: <201511271819.tARIJB9e019142@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: zbb set sender to zbb@FreeBSD.org using -f From: Zbigniew Bodek Date: Fri, 27 Nov 2015 18:19:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r291403 - head/sys/boot/kshim 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.20 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, 27 Nov 2015 18:19:13 -0000 Author: zbb Date: Fri Nov 27 18:19:11 2015 New Revision: 291403 URL: https://svnweb.freebsd.org/changeset/base/291403 Log: Run callouts during infinite waiting inside cv_wait During cv_wait we may be waiting for an event triggered by callout. Run callbacks here to avoid code blocking. Reviewed by: hselasky Submitted by: Wojciech Macek Obtained from: Semihalf Sponsored by: Juniper Networks Inc. Differential Revision: https://reviews.freebsd.org/D4144 Modified: head/sys/boot/kshim/bsd_kernel.c Modified: head/sys/boot/kshim/bsd_kernel.c ============================================================================== --- head/sys/boot/kshim/bsd_kernel.c Fri Nov 27 18:17:53 2015 (r291402) +++ head/sys/boot/kshim/bsd_kernel.c Fri Nov 27 18:19:11 2015 (r291403) @@ -138,6 +138,7 @@ cv_timedwait(struct cv *cv, struct mtx * { int start = ticks; int delta; + int time = 0; if (cv->sleeping) return (EWOULDBLOCK); /* not allowed */ @@ -154,6 +155,14 @@ cv_timedwait(struct cv *cv, struct mtx * usb_idle(); + if (++time >= (1000000 / hz)) { + time = 0; + callout_process(1); + } + + /* Sleep for 1 us */ + delay(1); + mtx_lock(mtx); }