Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 19 Dec 2013 12:00:48 +0000 (UTC)
From:      Andriy Gapon <avg@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r259612 - head/sys/dev/drm2/ttm
Message-ID:  <201312191200.rBJC0mXm001223@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: avg
Date: Thu Dec 19 12:00:48 2013
New Revision: 259612
URL: http://svnweb.freebsd.org/changeset/base/259612

Log:
  ttm_bo_vm_lookup_rb: actually make use of the red-black tree
  
  Previously the code would just iterate over the whole tree as if it were
  just a list.
  
  Without this change I would observe X server becoming more and more
  jerky over time.
  
  MFC after:	5 days

Modified:
  head/sys/dev/drm2/ttm/ttm_bo_vm.c

Modified: head/sys/dev/drm2/ttm/ttm_bo_vm.c
==============================================================================
--- head/sys/dev/drm2/ttm/ttm_bo_vm.c	Thu Dec 19 10:28:54 2013	(r259611)
+++ head/sys/dev/drm2/ttm/ttm_bo_vm.c	Thu Dec 19 12:00:48 2013	(r259612)
@@ -76,13 +76,16 @@ static struct ttm_buffer_object *ttm_bo_
 	struct ttm_buffer_object *bo;
 	struct ttm_buffer_object *best_bo = NULL;
 
-	RB_FOREACH(bo, ttm_bo_device_buffer_objects, &bdev->addr_space_rb) {
+	bo = RB_ROOT(&bdev->addr_space_rb);
+	while (bo != NULL) {
 		cur_offset = bo->vm_node->start;
 		if (page_start >= cur_offset) {
 			best_bo = bo;
 			if (page_start == cur_offset)
 				break;
-		}
+			bo = RB_RIGHT(bo, vm_rb);
+		} else
+			bo = RB_LEFT(bo, vm_rb);
 	}
 
 	if (unlikely(best_bo == NULL))



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201312191200.rBJC0mXm001223>