svn commit: r259612 - head/sys/dev/drm2/ttm

Andriy Gapon avg at FreeBSD.org
Thu Dec 19 12:00:48 UTC 2013


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))


More information about the svn-src-all mailing list