From 4a675f93b9f8a51e6d48f1e2914ec1ef94990020 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Mon, 23 Jan 2023 00:11:43 -0500 Subject: [PATCH] asahi: Omit extra call to clock_gettime It's cheap but it isn't free. Signed-off-by: Alyssa Rosenzweig Part-of: --- src/asahi/lib/agx_device.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/asahi/lib/agx_device.c b/src/asahi/lib/agx_device.c index a9104456065..59b451c9965 100644 --- a/src/asahi/lib/agx_device.c +++ b/src/asahi/lib/agx_device.c @@ -247,11 +247,8 @@ agx_bo_cache_fetch(struct agx_device *dev, size_t size, uint32_t flags, } static void -agx_bo_cache_evict_stale_bos(struct agx_device *dev) +agx_bo_cache_evict_stale_bos(struct agx_device *dev, unsigned tv_sec) { - struct timespec time; - - clock_gettime(CLOCK_MONOTONIC, &time); list_for_each_entry_safe(struct agx_bo, entry, &dev->bo_cache.lru, lru_link) { /* We want all entries that have been used more than 1 sec ago to be @@ -261,7 +258,7 @@ agx_bo_cache_evict_stale_bos(struct agx_device *dev) * seconds old, but we don't really care, as long as unused BOs are * dropped at some point. */ - if (time.tv_sec - entry->last_used <= 2) + if (tv_sec - entry->last_used <= 2) break; agx_bo_cache_remove_locked(dev, entry); @@ -299,7 +296,7 @@ agx_bo_cache_put_locked(struct agx_bo *bo) bo->label = "Unused (BO cache)"; /* Let's do some cleanup in the BO cache while we hold the lock. */ - agx_bo_cache_evict_stale_bos(dev); + agx_bo_cache_evict_stale_bos(dev, time.tv_sec); } /* Tries to add a BO to the cache. Returns if it was successful */