Skip to contentSkip to conversation

docs: fault-injection: document cache-filter feature for failslab

PATCH Applied Breno Leitao 3 participants 5 messages Jul 26, 2024 – Aug 11, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 docs: fault-injection: document cache-filter feature for failslab

The failslab fault injection mechanism has an undocumented capability that provides significant utility in testing and debugging. This feature, introduced in commit 4c13dd3b48fcb ("failslab: add ability to filter slab caches"), allows for targeted error injection into specific slab caches.

However, it was inadvertently left undocumented at the time of its implementation.

Add documentation for the cache-filter feature in the failslab mode description. Also, providing a practical example demonstrating how to use cache-filter to inject failures specifically when allocating socket buffers (skbs).

---
 .../fault-injection/fault-injection.rst       | 20 +++++++++++++++++++
 1 file changed, 20 insertions(+)
Documentation/fault-injection/fault-injection.rst +20 -0
index 70380a2a01b4..07c24710bd21 100644
@@ -141,6 +141,14 @@ configuration of fault-injection capabilities.
 	default is 'Y', setting it to 'N' will also inject failures into
 	highmem/user allocations (__GFP_HIGHMEM allocations).
 
+- /sys/kernel/debug/failslab/cache-filter
+	Format: { 'Y' | 'N' }
+
+        default is 'N', setting it to 'Y' will only inject failures when
+        objects are requests from certain caches.
+
+        Select the cache by writing '1' to /sys/kernel/slab/<cache>/failslab:
+
 - /sys/kernel/debug/failslab/ignore-gfp-wait:
 - /sys/kernel/debug/fail_page_alloc/ignore-gfp-wait:
 
@@ -459,6 +467,18 @@ Application Examples
     losetup -d $DEVICE
     rm testfile.img
 
+------------------------------------------------------------------------------
+
+- Inject only skbuff allocation failures ::
+
+    # mark skbuff_head_cache as faulty
+    echo 1 > /sys/kernel/slab/skbuff_head_cache/failslab
+    # Turn on cache filter (off by default)
+    echo 1 > /sys/kernel/debug/failslab/cache-filter
+    # Turn on fault injection
+    echo 1 > /sys/kernel/debug/failslab/times
+    echo 1 > /sys/kernel/debug/failslab/probability
+
 
 Tool to run command with failslab or fail_page_alloc
 ----------------------------------------------------
Signature · 1 line
2.43.0
maintainer Reviewed-by on v1 1/1
#1 lore raw

2024年7月26日(金) 21:09 Breno Leitao <[email protected]>:

Quoted 47 lines

The failslab fault injection mechanism has an undocumented capability that provides significant utility in testing and debugging. This feature, introduced in commit 4c13dd3b48fcb ("failslab: add ability to filter slab caches"), allows for targeted error injection into specific slab caches.

However, it was inadvertently left undocumented at the time of its implementation.

Add documentation for the cache-filter feature in the failslab mode description. Also, providing a practical example demonstrating how to use cache-filter to inject failures specifically when allocating socket buffers (skbs).

---
 .../fault-injection/fault-injection.rst       | 20 +++++++++++++++++++
 1 file changed, 20 insertions(+)
Documentation/fault-injection/fault-injection.rst +13 -0
index 70380a2a01b4..07c24710bd21 100644
@@ -141,6 +141,14 @@ configuration of fault-injection capabilities.
        default is 'Y', setting it to 'N' will also inject failures into
        highmem/user allocations (__GFP_HIGHMEM allocations).
 
+- /sys/kernel/debug/failslab/cache-filter
+       Format: { 'Y' | 'N' }
+
+        default is 'N', setting it to 'Y' will only inject failures when
+        objects are requests from certain caches.
+
+        Select the cache by writing '1' to /sys/kernel/slab/<cache>/failslab:
+
 - /sys/kernel/debug/failslab/ignore-gfp-wait:
 - /sys/kernel/debug/fail_page_alloc/ignore-gfp-wait:
 
@@ -459,6 +467,18 @@ Application Examples
     losetup -d $DEVICE
     rm testfile.img
 
+------------------------------------------------------------------------------
+
+- Inject only skbuff allocation failures ::
+
+    # mark skbuff_head_cache as faulty

Documentation/fault-injection/fault-injection.rst Application Examples · line 484

Quoted 10 lines
Documentation/fault-injection/fault-injection.rst +7 -0
+    echo 1 > /sys/kernel/slab/skbuff_head_cache/failslab
+    # Turn on cache filter (off by default)
+    echo 1 > /sys/kernel/debug/failslab/cache-filter
+    # Turn on fault injection
+    echo 1 > /sys/kernel/debug/failslab/times
+    echo 1 > /sys/kernel/debug/failslab/probability
+
 
 Tool to run command with failslab or fail_page_alloc
 ----------------------------------------------------

Looks good.

maintainer Applied
#2 lore raw
In reply to Breno Leitao
Quoted 13 lines · Breno Leitao

The failslab fault injection mechanism has an undocumented capability that provides significant utility in testing and debugging. This feature, introduced in commit 4c13dd3b48fcb ("failslab: add ability to filter slab caches"), allows for targeted error injection into specific slab caches.

However, it was inadvertently left undocumented at the time of its implementation.

Add documentation for the cache-filter feature in the failslab mode description. Also, providing a practical example demonstrating how to use cache-filter to inject failures specifically when allocating socket buffers (skbs).

Quoted 4 lines
---
 .../fault-injection/fault-injection.rst       | 20 +++++++++++++++++++
 1 file changed, 20 insertions(+)

I've applied this, thanks.

It seems to me that the fault-injection docs should really move under dev-tools; does anybody object to that?

Thanks,

jon

#3 lore raw
Quoted 20 lines · Jonathan Corbet
Quoted 13 lines · Breno Leitao

The failslab fault injection mechanism has an undocumented capability that provides significant utility in testing and debugging. This feature, introduced in commit 4c13dd3b48fcb ("failslab: add ability to filter slab caches"), allows for targeted error injection into specific slab caches.

However, it was inadvertently left undocumented at the time of its implementation.

Add documentation for the cache-filter feature in the failslab mode description. Also, providing a practical example demonstrating how to use cache-filter to inject failures specifically when allocating socket buffers (skbs).

Quoted 4 lines
---
 .../fault-injection/fault-injection.rst       | 20 +++++++++++++++++++
 1 file changed, 20 insertions(+)
Quoted 4 lines

I've applied this, thanks.

It seems to me that the fault-injection docs should really move under dev-tools; does anybody object to that?

I don't object at all. This doc should be inside dev-tools.

Thanks Jonathan,
--breno

maintainer
#4 lore raw

2024年8月8日(木) 16:41 Breno Leitao <[email protected]>:

Quoted 22 lines · Jonathan Corbet
Quoted 20 lines
Quoted 17 lines · Breno Leitao

The failslab fault injection mechanism has an undocumented capability that provides significant utility in testing and debugging. This feature, introduced in commit 4c13dd3b48fcb ("failslab: add ability to filter slab caches"), allows for targeted error injection into specific slab caches.

However, it was inadvertently left undocumented at the time of its implementation.

Add documentation for the cache-filter feature in the failslab mode description. Also, providing a practical example demonstrating how to use cache-filter to inject failures specifically when allocating socket buffers (skbs).

---
 .../fault-injection/fault-injection.rst       | 20 +++++++++++++++++++
 1 file changed, 20 insertions(+)
Quoted 6 lines
Quoted 4 lines

I've applied this, thanks.

It seems to me that the fault-injection docs should really move under dev-tools; does anybody object to that?

I don't object at all. This doc should be inside dev-tools.

I also agree with moving the document.