mm: don't call should_failslab() for !CONFIG_FAILSLAB misc-next
authorJens Axboe <axboe@kernel.dk>
Sat, 18 Sep 2021 13:31:07 +0000 (07:31 -0600)
committerJens Axboe <axboe@kernel.dk>
Sat, 9 Oct 2021 17:32:47 +0000 (11:32 -0600)
Allocations can be a very hot path, and this out-of-line function
call is noticeable.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
include/linux/fault-inject.h
mm/slab.h
mm/slab_common.c

index e525f6957c49f5ae7af97042120c33e0fe7ff12e..3128d2c8b3b444ef1311f3ddb32b8f94671ac7a9 100644 (file)
@@ -64,8 +64,8 @@ static inline struct dentry *fault_create_debugfs_attr(const char *name,
 
 struct kmem_cache;
 
-int should_failslab(struct kmem_cache *s, gfp_t gfpflags);
 #ifdef CONFIG_FAILSLAB
+int should_failslab(struct kmem_cache *s, gfp_t gfpflags);
 extern bool __should_failslab(struct kmem_cache *s, gfp_t gfpflags);
 #else
 static inline bool __should_failslab(struct kmem_cache *s, gfp_t gfpflags)
index 58c01a34e5b86b3c7dca26875f95d62e8fac05ca..92fd6fe01877ecc526c4a61b7382281a098788ff 100644 (file)
--- a/mm/slab.h
+++ b/mm/slab.h
@@ -491,8 +491,10 @@ static inline struct kmem_cache *slab_pre_alloc_hook(struct kmem_cache *s,
 
        might_alloc(flags);
 
+#ifdef CONFIG_FAILSLAB
        if (should_failslab(s, flags))
                return NULL;
+#endif
 
        if (!memcg_slab_pre_alloc_hook(s, objcgp, size, flags))
                return NULL;
index ec2bb0beed757cf2b143920b07b43fafeb9169f5..c21bd447f237220fc424a59d7ce27b6e89059a74 100644 (file)
@@ -1323,6 +1323,7 @@ EXPORT_TRACEPOINT_SYMBOL(kmem_cache_alloc_node);
 EXPORT_TRACEPOINT_SYMBOL(kfree);
 EXPORT_TRACEPOINT_SYMBOL(kmem_cache_free);
 
+#ifdef CONFIG_FAILSLAB
 int should_failslab(struct kmem_cache *s, gfp_t gfpflags)
 {
        if (__should_failslab(s, gfpflags))
@@ -1330,3 +1331,4 @@ int should_failslab(struct kmem_cache *s, gfp_t gfpflags)
        return 0;
 }
 ALLOW_ERROR_INJECTION(should_failslab, ERRNO);
+#endif