Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'slab-for-6.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/vbabka/slab

Pull slab fixes from Vlastimil Babka:
"Fixes for issues introduced in this merge window: kobject memory leak,
unsupressed warning and possible lockup in new slub_kunit tests,
misleading code in kvfree_rcu_queue_batch()"

* tag 'slab-for-6.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/vbabka/slab:
slub/kunit: skip test_kfree_rcu when the slub kunit test is built-in
mm, slab: suppress warnings in test_leak_destroy kunit test
rcu/kvfree: Refactor kvfree_rcu_queue_batch()
mm, slab: fix use of SLAB_SUPPORTS_SYSFS in kmem_cache_release()

+30 -15
+5 -4
kernel/rcu/tree.c
··· 3607 3607 } 3608 3608 3609 3609 // One work is per one batch, so there are three 3610 - // "free channels", the batch can handle. It can 3611 - // be that the work is in the pending state when 3612 - // channels have been detached following by each 3613 - // other. 3610 + // "free channels", the batch can handle. Break 3611 + // the loop since it is done with this CPU thus 3612 + // queuing an RCU work is _always_ success here. 3614 3613 queued = queue_rcu_work(system_unbound_wq, &krwp->rcu_work); 3614 + WARN_ON_ONCE(!queued); 3615 + break; 3615 3616 } 3616 3617 } 3617 3618
+12 -6
lib/slub_kunit.c
··· 164 164 165 165 static void test_kfree_rcu(struct kunit *test) 166 166 { 167 - struct kmem_cache *s = test_kmem_cache_create("TestSlub_kfree_rcu", 168 - sizeof(struct test_kfree_rcu_struct), 169 - SLAB_NO_MERGE); 170 - struct test_kfree_rcu_struct *p = kmem_cache_alloc(s, GFP_KERNEL); 167 + struct kmem_cache *s; 168 + struct test_kfree_rcu_struct *p; 169 + 170 + if (IS_BUILTIN(CONFIG_SLUB_KUNIT_TEST)) 171 + kunit_skip(test, "can't do kfree_rcu() when test is built-in"); 172 + 173 + s = test_kmem_cache_create("TestSlub_kfree_rcu", 174 + sizeof(struct test_kfree_rcu_struct), 175 + SLAB_NO_MERGE); 176 + p = kmem_cache_alloc(s, GFP_KERNEL); 171 177 172 178 kfree_rcu(p, rcu); 173 179 kmem_cache_destroy(s); ··· 183 177 184 178 static void test_leak_destroy(struct kunit *test) 185 179 { 186 - struct kmem_cache *s = test_kmem_cache_create("TestSlub_kfree_rcu", 180 + struct kmem_cache *s = test_kmem_cache_create("TestSlub_leak_destroy", 187 181 64, SLAB_NO_MERGE); 188 182 kmem_cache_alloc(s, GFP_KERNEL); 189 183 190 184 kmem_cache_destroy(s); 191 185 192 - KUNIT_EXPECT_EQ(test, 1, slab_errors); 186 + KUNIT_EXPECT_EQ(test, 2, slab_errors); 193 187 } 194 188 195 189 static int test_init(struct kunit *test)
+7 -1
mm/slab.h
··· 310 310 }; 311 311 312 312 #if defined(CONFIG_SYSFS) && !defined(CONFIG_SLUB_TINY) 313 - #define SLAB_SUPPORTS_SYSFS 313 + #define SLAB_SUPPORTS_SYSFS 1 314 314 void sysfs_slab_unlink(struct kmem_cache *s); 315 315 void sysfs_slab_release(struct kmem_cache *s); 316 316 #else ··· 545 545 return s->flags & flags; 546 546 return false; 547 547 } 548 + 549 + #if IS_ENABLED(CONFIG_SLUB_DEBUG) && IS_ENABLED(CONFIG_KUNIT) 550 + bool slab_in_kunit_test(void); 551 + #else 552 + static inline bool slab_in_kunit_test(void) { return false; } 553 + #endif 548 554 549 555 #ifdef CONFIG_SLAB_OBJ_EXT 550 556
+3 -2
mm/slab_common.c
··· 508 508 kasan_cache_shutdown(s); 509 509 510 510 err = __kmem_cache_shutdown(s); 511 - WARN(err, "%s %s: Slab cache still has objects when called from %pS", 512 - __func__, s->name, (void *)_RET_IP_); 511 + if (!slab_in_kunit_test()) 512 + WARN(err, "%s %s: Slab cache still has objects when called from %pS", 513 + __func__, s->name, (void *)_RET_IP_); 513 514 514 515 list_del(&s->list); 515 516
+3 -2
mm/slub.c
··· 827 827 return true; 828 828 } 829 829 830 - static bool slab_in_kunit_test(void) 830 + bool slab_in_kunit_test(void) 831 831 { 832 832 struct kunit_resource *resource; 833 833 ··· 843 843 } 844 844 #else 845 845 static inline bool slab_add_kunit_errors(void) { return false; } 846 - static inline bool slab_in_kunit_test(void) { return false; } 847 846 #endif 848 847 849 848 static inline unsigned int size_from_object(struct kmem_cache *s) ··· 5435 5436 for_each_object(p, s, addr, slab->objects) { 5436 5437 5437 5438 if (!test_bit(__obj_to_index(s, addr, p), object_map)) { 5439 + if (slab_add_kunit_errors()) 5440 + continue; 5438 5441 pr_err("Object 0x%p @offset=%tu\n", p, p - addr); 5439 5442 print_tracking(s, p); 5440 5443 }