Thread (16 messages) 16 messages, 3 authors, 2024-06-26

Re: [PATCH v2 6/7] mm, slab: add static key for should_failslab()

From: Vlastimil Babka <hidden>
Date: 2024-06-25 17:53:47
Also in: bpf, linux-mm, lkml

On 6/25/24 7:12 PM, Alexei Starovoitov wrote:
On Tue, Jun 25, 2024 at 7:24 AM Vlastimil Babka [off-list ref] wrote:
quoted
On 6/20/24 12:49 AM, Vlastimil Babka wrote:
quoted
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -3874,13 +3874,37 @@ static __always_inline void maybe_wipe_obj_freeptr(struct kmem_cache *s,
                      0, sizeof(void *));
 }

-noinline int should_failslab(struct kmem_cache *s, gfp_t gfpflags)
+#if defined(CONFIG_FUNCTION_ERROR_INJECTION) || defined(CONFIG_FAILSLAB)
+DEFINE_STATIC_KEY_FALSE(should_failslab_active);
+
+#ifdef CONFIG_FUNCTION_ERROR_INJECTION
+noinline
+#else
+static inline
+#endif
+int should_failslab(struct kmem_cache *s, gfp_t gfpflags)
Note that it has been found that (regardless of this series) gcc may clone
this to a should_failslab.constprop.0 in case the function is empty because
__should_failslab is compiled out (CONFIG_FAILSLAB=n). The "noinline"
doesn't help - the original function stays but only the clone is actually
being called, thus overriding the original function achieves nothing, see:
https://github.com/bpftrace/bpftrace/issues/3258

So we could use __noclone to prevent that, and I was thinking by adding
something this to error-injection.h:

#ifdef CONFIG_FUNCTION_ERROR_INJECTION
#define __error_injectable(alternative)         noinline __noclone
To prevent such compiler transformations we typically use
__used noinline

We didn't have a need for __noclone yet. If __used is enough I'd stick to that.
__used made no difference here (gcc 13.3), __noclone did
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help