Re: [PATCH v3 11/15] drm/shmem-helper: Add generic memory shrinker

From: kernel test robot
Date: Mon Apr 11 2022 - 23:36:36 EST


Hi Dmitry,

I love your patch! Perhaps something to improve:

[auto build test WARNING on next-20220411]
[cannot apply to drm/drm-next v5.18-rc2 v5.18-rc1 v5.17 v5.18-rc2]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url: https://github.com/intel-lab-lkp/linux/commits/Dmitry-Osipenko/Add-generic-memory-shrinker-to-VirtIO-GPU-and-Panfrost-DRM-drivers/20220412-060325
base: d12d7e1cfe38e0c36d28c7a9fbbc436ad0d17c14
config: arc-buildonly-randconfig-r002-20220411 (https://download.01.org/0day-ci/archive/20220412/202204121135.zXHzC28U-lkp@xxxxxxxxx/config)
compiler: arc-elf-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/683ba8a9d72ba7770a61a9266a2b33949f3874f2
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Dmitry-Osipenko/Add-generic-memory-shrinker-to-VirtIO-GPU-and-Panfrost-DRM-drivers/20220412-060325
git checkout 683ba8a9d72ba7770a61a9266a2b33949f3874f2
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=arc SHELL=/bin/bash drivers/gpu/drm/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>

All warnings (new ones prefixed by >>):

drivers/gpu/drm/drm_gem_shmem_helper.c: In function 'drm_gem_shmem_shrinker_run_objects_scan':
>> drivers/gpu/drm/drm_gem_shmem_helper.c:1358:56: warning: implicit conversion from 'enum <anonymous>' to 'enum dma_resv_usage' [-Wenum-conversion]
1358 | if (!dma_resv_test_signaled(obj->resv, true))
| ^~~~


vim +1358 drivers/gpu/drm/drm_gem_shmem_helper.c

1299
1300 static unsigned long
1301 drm_gem_shmem_shrinker_run_objects_scan(struct shrinker *shrinker,
1302 unsigned long nr_to_scan,
1303 bool *lock_contention,
1304 bool evict)
1305 {
1306 struct drm_gem_shmem_shrinker *gem_shrinker = to_drm_shrinker(shrinker);
1307 struct drm_gem_shmem_object *shmem;
1308 struct list_head still_in_list;
1309 struct drm_gem_object *obj;
1310 unsigned long freed = 0;
1311 struct list_head *lru;
1312 size_t page_count;
1313
1314 INIT_LIST_HEAD(&still_in_list);
1315
1316 mutex_lock(&gem_shrinker->lock);
1317
1318 if (evict)
1319 lru = &gem_shrinker->lru_evictable;
1320 else
1321 lru = &gem_shrinker->lru_purgeable;
1322
1323 while (freed < nr_to_scan) {
1324 shmem = list_first_entry_or_null(lru, typeof(*shmem), madv_list);
1325 if (!shmem)
1326 break;
1327
1328 obj = &shmem->base;
1329 page_count = obj->size >> PAGE_SHIFT;
1330 list_move_tail(&shmem->madv_list, &still_in_list);
1331
1332 if (evict && get_nr_swap_pages() < page_count)
1333 continue;
1334
1335 /*
1336 * If it's in the process of being freed, gem_object->free()
1337 * may be blocked on lock waiting to remove it. So just
1338 * skip it.
1339 */
1340 if (!kref_get_unless_zero(&obj->refcount))
1341 continue;
1342
1343 mutex_unlock(&gem_shrinker->lock);
1344
1345 /* prevent racing with job-submission code paths */
1346 if (!dma_resv_trylock(obj->resv)) {
1347 *lock_contention |= true;
1348 goto shrinker_lock;
1349 }
1350
1351 /* prevent racing with the dma-buf exporting */
1352 if (!mutex_trylock(&gem_shrinker->dev->object_name_lock)) {
1353 *lock_contention |= true;
1354 goto resv_unlock;
1355 }
1356
1357 /* check whether h/w uses this object */
> 1358 if (!dma_resv_test_signaled(obj->resv, true))
1359 goto object_name_unlock;
1360
1361 /* GEM may've become unpurgeable while shrinker was unlocked */
1362 if (evict) {
1363 if (!drm_gem_shmem_is_evictable(shmem))
1364 goto object_name_unlock;
1365 } else {
1366 if (!drm_gem_shmem_is_purgeable(shmem))
1367 goto object_name_unlock;
1368 }
1369
1370 if (evict)
1371 freed += obj->funcs->evict(obj);
1372 else
1373 freed += obj->funcs->purge(obj);
1374 object_name_unlock:
1375 mutex_unlock(&gem_shrinker->dev->object_name_lock);
1376 resv_unlock:
1377 dma_resv_unlock(obj->resv);
1378 shrinker_lock:
1379 drm_gem_object_put(&shmem->base);
1380 mutex_lock(&gem_shrinker->lock);
1381 }
1382
1383 list_splice_tail(&still_in_list, lru);
1384
1385 mutex_unlock(&gem_shrinker->lock);
1386
1387 return freed;
1388 }
1389

--
0-DAY CI Kernel Test Service
https://01.org/lkp