summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2021-09-18 07:31:07 -0600
committerJens Axboe <axboe@kernel.dk>2021-10-09 11:32:47 -0600
commitf1b1f5ae2af5a20c01d4f9e8cce6bc867e8718b3 (patch)
tree560eb5c1a89bc7eab1b7e047a50528dba995a700
parent42f0579b08cb17e1ad6221a895c45c7cc9c5d8be (diff)
mm: don't call should_failslab() for !CONFIG_FAILSLABmisc-next
Allocations can be a very hot path, and this out-of-line function call is noticeable. Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r--include/linux/fault-inject.h2
-rw-r--r--mm/slab.h2
-rw-r--r--mm/slab_common.c2
3 files changed, 5 insertions, 1 deletions
diff --git a/include/linux/fault-inject.h b/include/linux/fault-inject.h
index e525f6957c49..3128d2c8b3b4 100644
--- a/include/linux/fault-inject.h
+++ b/include/linux/fault-inject.h
@@ -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)
diff --git a/mm/slab.h b/mm/slab.h
index 58c01a34e5b8..92fd6fe01877 100644
--- 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;
diff --git a/mm/slab_common.c b/mm/slab_common.c
index ec2bb0beed75..c21bd447f237 100644
--- a/mm/slab_common.c
+++ b/mm/slab_common.c
@@ -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