From owner-svn-src-head@freebsd.org Thu May 18 18:35:15 2017 Return-Path: Delivered-To: svn-src-head@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 A1C46D712F8; Thu, 18 May 2017 18:35:15 +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 5952F8CD; Thu, 18 May 2017 18:35:15 +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 v4IIZE6a067064; Thu, 18 May 2017 18:35:14 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v4IIZEbq067062; Thu, 18 May 2017 18:35:14 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201705181835.v4IIZEbq067062@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Thu, 18 May 2017 18:35:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r318478 - in head/sys: compat/linuxkpi/common/src dev/drm2/ttm X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 18 May 2017 18:35:15 -0000 Author: markj Date: Thu May 18 18:35:14 2017 New Revision: 318478 URL: https://svnweb.freebsd.org/changeset/base/318478 Log: Fix a few uses of kern_yield() in the TTM and the LinuxKPI. kern_yield(0) effectively causes the calling thread to be rescheduled immediately since it resets the thread's priority to the highest possible value. This can cause livelocks when the pattern "while (!trylock()) kern_yield(0);" is used since the thread holding the lock may linger on the runqueue for the CPU on which the looping thread is running. MFC after: 1 week Modified: head/sys/compat/linuxkpi/common/src/linux_compat.c head/sys/dev/drm2/ttm/ttm_bo_vm.c Modified: head/sys/compat/linuxkpi/common/src/linux_compat.c ============================================================================== --- head/sys/compat/linuxkpi/common/src/linux_compat.c Thu May 18 18:33:33 2017 (r318477) +++ head/sys/compat/linuxkpi/common/src/linux_compat.c Thu May 18 18:35:14 2017 (r318478) @@ -435,7 +435,7 @@ linux_cdev_pager_populate(vm_object_t vm err = vmap->vm_ops->fault(vmap, &vmf); while (vmap->vm_pfn_count == 0 && err == VM_FAULT_NOPAGE) { - kern_yield(0); + kern_yield(PRI_USER); err = vmap->vm_ops->fault(vmap, &vmf); } } Modified: head/sys/dev/drm2/ttm/ttm_bo_vm.c ============================================================================== --- head/sys/dev/drm2/ttm/ttm_bo_vm.c Thu May 18 18:33:33 2017 (r318477) +++ head/sys/dev/drm2/ttm/ttm_bo_vm.c Thu May 18 18:35:14 2017 (r318478) @@ -126,7 +126,7 @@ reserve: ret = ttm_bo_reserve(bo, false, false, false, 0); if (unlikely(ret != 0)) { if (ret == -EBUSY) { - kern_yield(0); + kern_yield(PRI_USER); goto reserve; } } @@ -139,7 +139,7 @@ reserve: case -EBUSY: case -ERESTARTSYS: case -EINTR: - kern_yield(0); + kern_yield(PRI_USER); goto reserve; default: retval = VM_PAGER_ERROR;