[Devel] [PATCH RHEL9 COMMIT] ms/mm/slub: Make failslab writable again

Konstantin Khorenko khorenko at virtuozzo.com
Mon Oct 17 16:48:46 MSK 2022


The commit is pushed to "branch-rh9-5.14.0-70.22.1.vz9.17.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh9-5.14.0-70.22.1.vz9.17.8
------>
commit 4f539a37759c01a46899be1b48932d7f9e5d0448
Author: Alexander Atanasov <alexander.atanasov at virtuozzo.com>
Date:   Fri Oct 14 19:33:45 2022 +0300

    ms/mm/slub: Make failslab writable again
    
    In 060807f841ac ("mm, slub: make remaining slub_debug related attributes
    read-only") failslab was made read-only.
    I think it became a collateral victim to the two other options for which
    the reasons are perfectly valid.
    
    Here is why:
         - sanity_checks and trace are slab internal debug options,
           failslab is used for fault injection.
         - for fault injections, which by presumption are random, it
           does not matter if it is not set atomically. And you need to
           set atleast one more option to trigger fault injection.
         - in a testing scenario you may need to change it at runtime
           example: module loading - you test all allocations limited
           by the space option. Then you move to test only your module's
           own slabs.
         - when set by command line flags it effectively disables all
           cache merges.
    
    Accepted in mainstream:
    https://git.kernel.org/pub/scm/linux/kernel/git/vbabka/slab.git/log/?h=for-6.2/slub-sysfs
    
    https://jira.sw.ru/browse/PSBM-141315
    Signed-off-by: Alexander Atanasov <alexander.atanasov at virtuozzo.com>
    
    Feature: fix ms/mm
---
 mm/slub.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/mm/slub.c b/mm/slub.c
index da515f247553..bb1f47f3e803 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -5595,7 +5595,21 @@ static ssize_t failslab_show(struct kmem_cache *s, char *buf)
 {
 	return sysfs_emit(buf, "%d\n", !!(s->flags & SLAB_FAILSLAB));
 }
-SLAB_ATTR_RO(failslab);
+
+static ssize_t failslab_store(struct kmem_cache *s, const char *buf,
+				size_t length)
+{
+	if (s->refcount > 1)
+		return -EINVAL;
+
+	if (buf[0] == '1')
+		WRITE_ONCE(s->flags, s->flags | SLAB_FAILSLAB);
+	else
+		WRITE_ONCE(s->flags, s->flags & ~SLAB_FAILSLAB);
+
+	return length;
+}
+SLAB_ATTR(failslab);
 #endif
 
 static ssize_t shrink_show(struct kmem_cache *s, char *buf)


More information about the Devel mailing list