@@ -297,6 +297,32 @@ static int __init do_kmem_cache_rcu_persistent(int size, int *total_failures)
297297 return 1 ;
298298}
299299
300+ static int __init do_kmem_cache_size_bulk (int size , int * total_failures )
301+ {
302+ struct kmem_cache * c ;
303+ int i , iter , maxiter = 1024 ;
304+ int num , bytes ;
305+ bool fail = false;
306+ void * objects [10 ];
307+
308+ c = kmem_cache_create ("test_cache" , size , size , 0 , NULL );
309+ for (iter = 0 ; (iter < maxiter ) && !fail ; iter ++ ) {
310+ num = kmem_cache_alloc_bulk (c , GFP_KERNEL , ARRAY_SIZE (objects ),
311+ objects );
312+ for (i = 0 ; i < num ; i ++ ) {
313+ bytes = count_nonzero_bytes (objects [i ], size );
314+ if (bytes )
315+ fail = true;
316+ fill_with_garbage (objects [i ], size );
317+ }
318+
319+ if (num )
320+ kmem_cache_free_bulk (c , num , objects );
321+ }
322+ * total_failures += fail ;
323+ return 1 ;
324+ }
325+
300326/*
301327 * Test kmem_cache allocation by creating caches of different sizes, with and
302328 * without constructors, with and without SLAB_TYPESAFE_BY_RCU.
@@ -318,6 +344,7 @@ static int __init test_kmemcache(int *total_failures)
318344 num_tests += do_kmem_cache_size (size , ctor , rcu , zero ,
319345 & failures );
320346 }
347+ num_tests += do_kmem_cache_size_bulk (size , & failures );
321348 }
322349 REPORT_FAILURES_IN_FN ();
323350 * total_failures += failures ;
0 commit comments