From owner-svn-src-stable@freebsd.org Tue Mar 13 16:33:42 2018 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 192A7F2FCD3; Tue, 13 Mar 2018 16:33:42 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id BF98B87878; Tue, 13 Mar 2018 16:33:41 +0000 (UTC) (envelope-from hselasky@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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id BA8E21C46C; Tue, 13 Mar 2018 16:33:41 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w2DGXfW3010573; Tue, 13 Mar 2018 16:33:41 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w2DGXfA5010572; Tue, 13 Mar 2018 16:33:41 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201803131633.w2DGXfA5010572@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Tue, 13 Mar 2018 16:33:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r330865 - stable/11/sys/compat/linuxkpi/common/src X-SVN-Group: stable-11 X-SVN-Commit-Author: hselasky X-SVN-Commit-Paths: stable/11/sys/compat/linuxkpi/common/src X-SVN-Commit-Revision: 330865 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 13 Mar 2018 16:33:42 -0000 Author: hselasky Date: Tue Mar 13 16:33:41 2018 New Revision: 330865 URL: https://svnweb.freebsd.org/changeset/base/330865 Log: MFC r330689: Implement proper support for complete_all() in the LinuxKPI. When complete_all() is called there might be multiple waiters. The current implementation could only handle one waiter. Make sure the completion is sticky when complete_all() is called to be compatible with Linux. Found by: Johannes Lundberg Sponsored by: Mellanox Technologies Sponsored by: Limelight Networks Modified: stable/11/sys/compat/linuxkpi/common/src/linux_compat.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/compat/linuxkpi/common/src/linux_compat.c ============================================================================== --- stable/11/sys/compat/linuxkpi/common/src/linux_compat.c Tue Mar 13 16:33:00 2018 (r330864) +++ stable/11/sys/compat/linuxkpi/common/src/linux_compat.c Tue Mar 13 16:33:41 2018 (r330865) @@ -1779,11 +1779,14 @@ linux_complete_common(struct completion *c, int all) int wakeup_swapper; sleepq_lock(c); - c->done++; - if (all) + if (all) { + c->done = UINT_MAX; wakeup_swapper = sleepq_broadcast(c, SLEEPQ_SLEEP, 0, 0); - else + } else { + if (c->done != UINT_MAX) + c->done++; wakeup_swapper = sleepq_signal(c, SLEEPQ_SLEEP, 0, 0); + } sleepq_release(c); if (wakeup_swapper) kick_proc0(); @@ -1825,7 +1828,8 @@ linux_wait_for_common(struct completion *c, int flags) } else sleepq_wait(c, 0); } - c->done--; + if (c->done != UINT_MAX) + c->done--; sleepq_release(c); intr: @@ -1878,7 +1882,8 @@ linux_wait_for_timeout_common(struct completion *c, in goto done; } } - c->done--; + if (c->done != UINT_MAX) + c->done--; sleepq_release(c); /* return how many jiffies are left */ @@ -1894,12 +1899,10 @@ linux_try_wait_for_completion(struct completion *c) { int isdone; - isdone = 1; sleepq_lock(c); - if (c->done) + isdone = (c->done != 0); + if (c->done != 0 && c->done != UINT_MAX) c->done--; - else - isdone = 0; sleepq_release(c); return (isdone); } @@ -1909,10 +1912,8 @@ linux_completion_done(struct completion *c) { int isdone; - isdone = 1; sleepq_lock(c); - if (c->done == 0) - isdone = 0; + isdone = (c->done != 0); sleepq_release(c); return (isdone); }