Message ID | 20210609212959.471209-5-jason@jlekstrand.net (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | dma-fence, i915: Stop allowing SLAB_TYPESAFE_BY_RCU for dma_fence | expand |
Hi Jason, Thank you for the patch! Perhaps something to improve: [auto build test WARNING on drm-intel/for-linux-next] [also build test WARNING on drm-tip/drm-tip drm-exynos/exynos-drm-next tegra-drm/drm/tegra/for-next linus/master v5.13-rc6 next-20210615] [cannot apply to drm/drm-next] [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/0day-ci/linux/commits/Jason-Ekstrand/dma-fence-i915-Stop-allowing-SLAB_TYPESAFE_BY_RCU-for-dma_fence/20210616-154432 base: git://anongit.freedesktop.org/drm-intel for-linux-next config: sparc-randconfig-s032-20210615 (attached as .config) compiler: sparc-linux-gcc (GCC) 9.3.0 reproduce: wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # apt-get install sparse # sparse version: v0.6.3-341-g8af24329-dirty # https://github.com/0day-ci/linux/commit/c889567ea79d1ce55ff8868bae789bbb3223503d git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review Jason-Ekstrand/dma-fence-i915-Stop-allowing-SLAB_TYPESAFE_BY_RCU-for-dma_fence/20210616-154432 git checkout c889567ea79d1ce55ff8868bae789bbb3223503d # save the attached .config to linux build tree COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' W=1 ARCH=sparc If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot <lkp@intel.com> sparse warnings: (new ones prefixed by >>) >> drivers/dma-buf/st-dma-fence.c:457:57: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected struct dma_fence *fence @@ got struct dma_fence [noderef] __rcu * @@ drivers/dma-buf/st-dma-fence.c:457:57: sparse: expected struct dma_fence *fence drivers/dma-buf/st-dma-fence.c:457:57: sparse: got struct dma_fence [noderef] __rcu * vim +457 drivers/dma-buf/st-dma-fence.c 434 435 static int thread_signal_callback(void *arg) 436 { 437 const struct race_thread *t = arg; 438 unsigned long pass = 0; 439 unsigned long miss = 0; 440 int err = 0; 441 442 while (!err && !kthread_should_stop()) { 443 struct dma_fence *f1, *f2; 444 struct simple_cb cb; 445 446 f1 = mock_fence(); 447 if (!f1) { 448 err = -ENOMEM; 449 break; 450 } 451 452 rcu_assign_pointer(t->fences[t->id], f1); 453 smp_wmb(); 454 455 rcu_read_lock(); 456 do { > 457 f2 = dma_fence_get_rcu(t->fences[!t->id]); 458 } while (!f2 && !kthread_should_stop()); 459 rcu_read_unlock(); 460 461 if (t->before) 462 dma_fence_signal(f1); 463 464 smp_store_mb(cb.seen, false); 465 if (!f2 || 466 dma_fence_add_callback(f2, &cb.cb, simple_callback)) { 467 miss++; 468 cb.seen = true; 469 } 470 471 if (!t->before) 472 dma_fence_signal(f1); 473 474 if (!cb.seen) { 475 dma_fence_wait(f2, false); 476 __wait_for_callbacks(f2); 477 } 478 479 if (!READ_ONCE(cb.seen)) { 480 pr_err("Callback not seen on thread %d, pass %lu (%lu misses), signaling %s add_callback; fence signaled? %s\n", 481 t->id, pass, miss, 482 t->before ? "before" : "after", 483 dma_fence_is_signaled(f2) ? "yes" : "no"); 484 err = -EINVAL; 485 } 486 487 dma_fence_put(f2); 488 489 rcu_assign_pointer(t->fences[t->id], NULL); 490 smp_wmb(); 491 492 dma_fence_put(f1); 493 494 pass++; 495 } 496 497 pr_info("%s[%d] completed %lu passes, %lu misses\n", 498 __func__, t->id, pass, miss); 499 return err; 500 } 501 --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
diff --git a/drivers/dma-buf/st-dma-fence-chain.c b/drivers/dma-buf/st-dma-fence-chain.c index 9525f7f561194..73010184559fe 100644 --- a/drivers/dma-buf/st-dma-fence-chain.c +++ b/drivers/dma-buf/st-dma-fence-chain.c @@ -19,36 +19,27 @@ #define CHAIN_SZ (4 << 10) -static struct kmem_cache *slab_fences; - -static inline struct mock_fence { +struct mock_fence { struct dma_fence base; spinlock_t lock; -} *to_mock_fence(struct dma_fence *f) { - return container_of(f, struct mock_fence, base); -} +}; static const char *mock_name(struct dma_fence *f) { return "mock"; } -static void mock_fence_release(struct dma_fence *f) -{ - kmem_cache_free(slab_fences, to_mock_fence(f)); -} - static const struct dma_fence_ops mock_ops = { .get_driver_name = mock_name, .get_timeline_name = mock_name, - .release = mock_fence_release, + .release = dma_fence_free, }; static struct dma_fence *mock_fence(void) { struct mock_fence *f; - f = kmem_cache_alloc(slab_fences, GFP_KERNEL); + f = kmalloc(sizeof(*f), GFP_KERNEL); if (!f) return NULL; @@ -701,14 +692,7 @@ int dma_fence_chain(void) pr_info("sizeof(dma_fence_chain)=%zu\n", sizeof(struct dma_fence_chain)); - slab_fences = KMEM_CACHE(mock_fence, - SLAB_TYPESAFE_BY_RCU | - SLAB_HWCACHE_ALIGN); - if (!slab_fences) - return -ENOMEM; - ret = subtests(tests, NULL); - kmem_cache_destroy(slab_fences); return ret; } diff --git a/drivers/dma-buf/st-dma-fence.c b/drivers/dma-buf/st-dma-fence.c index c8a12d7ad71ab..ca98cb0b9525b 100644 --- a/drivers/dma-buf/st-dma-fence.c +++ b/drivers/dma-buf/st-dma-fence.c @@ -14,25 +14,16 @@ #include "selftest.h" -static struct kmem_cache *slab_fences; - -static struct mock_fence { +struct mock_fence { struct dma_fence base; struct spinlock lock; -} *to_mock_fence(struct dma_fence *f) { - return container_of(f, struct mock_fence, base); -} +}; static const char *mock_name(struct dma_fence *f) { return "mock"; } -static void mock_fence_release(struct dma_fence *f) -{ - kmem_cache_free(slab_fences, to_mock_fence(f)); -} - struct wait_cb { struct dma_fence_cb cb; struct task_struct *task; @@ -77,14 +68,14 @@ static const struct dma_fence_ops mock_ops = { .get_driver_name = mock_name, .get_timeline_name = mock_name, .wait = mock_wait, - .release = mock_fence_release, + .release = dma_fence_free, }; static struct dma_fence *mock_fence(void) { struct mock_fence *f; - f = kmem_cache_alloc(slab_fences, GFP_KERNEL); + f = kmalloc(sizeof(*f), GFP_KERNEL); if (!f) return NULL; @@ -463,7 +454,7 @@ static int thread_signal_callback(void *arg) rcu_read_lock(); do { - f2 = dma_fence_get_rcu_safe(&t->fences[!t->id]); + f2 = dma_fence_get_rcu(t->fences[!t->id]); } while (!f2 && !kthread_should_stop()); rcu_read_unlock(); @@ -563,15 +554,7 @@ int dma_fence(void) pr_info("sizeof(dma_fence)=%zu\n", sizeof(struct dma_fence)); - slab_fences = KMEM_CACHE(mock_fence, - SLAB_TYPESAFE_BY_RCU | - SLAB_HWCACHE_ALIGN); - if (!slab_fences) - return -ENOMEM; - ret = subtests(tests, NULL); - kmem_cache_destroy(slab_fences); - return ret; }
The only real-world user of SLAB_TYPESAFE_BY_RCU was i915 and it doesn't use that anymore so there's no need to be testing it in selftests. Signed-off-by: Jason Ekstrand <jason@jlekstrand.net> Cc: Daniel Vetter <daniel.vetter@ffwll.ch> Cc: Christian König <christian.koenig@amd.com> Cc: Matthew Auld <matthew.auld@intel.com> Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com> --- drivers/dma-buf/st-dma-fence-chain.c | 24 ++++-------------------- drivers/dma-buf/st-dma-fence.c | 27 +++++---------------------- 2 files changed, 9 insertions(+), 42 deletions(-)