[Mesa-dev] [PATCH 1/9] i965/drm: Use list_for_each_entry_safe in a couple of cases.
Daniel Vetter
daniel at ffwll.ch
Mon Apr 10 07:55:25 UTC 2017
On Mon, Apr 10, 2017 at 12:18:46AM -0700, Kenneth Graunke wrote:
> Suggested by Chris Wilson. A tiny bit simpler.
Reviewed-by: Daniel Vetter <daniel.vetter at ffwll.ch>
> ---
> src/mesa/drivers/dri/i965/brw_bufmgr.c | 14 +++-----------
> 1 file changed, 3 insertions(+), 11 deletions(-)
>
> This applies on top of my 'bacondrm' rework. You can see the whole branch
> in the 'bacondrm-2' branch of ~kwg/mesa.
>
> diff --git a/src/mesa/drivers/dri/i965/brw_bufmgr.c b/src/mesa/drivers/dri/i965/brw_bufmgr.c
> index 08634468256..b12cd3acfc3 100644
> --- a/src/mesa/drivers/dri/i965/brw_bufmgr.c
> +++ b/src/mesa/drivers/dri/i965/brw_bufmgr.c
> @@ -236,10 +236,7 @@ static void
> brw_bo_cache_purge_bucket(struct brw_bufmgr *bufmgr,
> struct bo_cache_bucket *bucket)
> {
> - while (!list_empty(&bucket->head)) {
> - struct brw_bo *bo;
> -
> - bo = LIST_ENTRY(struct brw_bo, bucket->head.next, head);
> + list_for_each_entry_safe(struct brw_bo, bo, &bucket->head, head) {
> if (brw_bo_madvise(bo, I915_MADV_DONTNEED))
> break;
>
> @@ -596,10 +593,7 @@ cleanup_bo_cache(struct brw_bufmgr *bufmgr, time_t time)
> for (i = 0; i < bufmgr->num_buckets; i++) {
> struct bo_cache_bucket *bucket = &bufmgr->cache_bucket[i];
>
> - while (!list_empty(&bucket->head)) {
> - struct brw_bo *bo;
> -
> - bo = LIST_ENTRY(struct brw_bo, bucket->head.next, head);
> + list_for_each_entry_safe(struct brw_bo, bo, &bucket->head, head) {
> if (time - bo->free_time <= 1)
> break;
>
> @@ -1096,10 +1090,8 @@ brw_bufmgr_destroy(struct brw_bufmgr *bufmgr)
> /* Free any cached buffer objects we were going to reuse */
> for (int i = 0; i < bufmgr->num_buckets; i++) {
> struct bo_cache_bucket *bucket = &bufmgr->cache_bucket[i];
> - struct brw_bo *bo;
>
> - while (!list_empty(&bucket->head)) {
> - bo = LIST_ENTRY(struct brw_bo, bucket->head.next, head);
> + list_for_each_entry_safe(struct brw_bo, bo, &bucket->head, head) {
> list_del(&bo->head);
>
> bo_free(bo);
> --
> 2.12.1
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
More information about the mesa-dev
mailing list