diff options
author | Jonathan Gray <jsg@cvs.openbsd.org> | 2014-09-23 05:57:15 +0000 |
---|---|---|
committer | Jonathan Gray <jsg@cvs.openbsd.org> | 2014-09-23 05:57:15 +0000 |
commit | 768dc05770c3e337f396a52b0b5132d13a81ef40 (patch) | |
tree | 698e9dc806bb9c2ee86c7d1cbd3ca925e917c4e7 /sys/dev/pci/drm | |
parent | 170602103b2c1a12ea3b41e533796d91c7c0a527 (diff) |
Make use of the red-black tree as the original Linux code did instead
of interating over the tree like a list. From Andriy Gapon in FreeBSD.
ok kettenis@
Diffstat (limited to 'sys/dev/pci/drm')
-rw-r--r-- | sys/dev/pci/drm/ttm/ttm_bo_vm.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/sys/dev/pci/drm/ttm/ttm_bo_vm.c b/sys/dev/pci/drm/ttm/ttm_bo_vm.c index 552fdf457ab..c1fb614475b 100644 --- a/sys/dev/pci/drm/ttm/ttm_bo_vm.c +++ b/sys/dev/pci/drm/ttm/ttm_bo_vm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ttm_bo_vm.c,v 1.1 2013/08/12 04:11:53 jsg Exp $ */ +/* $OpenBSD: ttm_bo_vm.c,v 1.2 2014/09/23 05:57:14 jsg Exp $ */ /************************************************************************** * * Copyright (c) 2006-2009 VMware, Inc., Palo Alto, CA., USA @@ -69,13 +69,16 @@ ttm_bo_vm_lookup_rb(struct ttm_bo_device *bdev, 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)) |