Blame SOURCES/bcc-0.16.0-slabratetop-Add-memcg_cache_params-struct-def.patch

bed121
From fe1f2189326a54e3496b2fcfdc1b08839f3165b4 Mon Sep 17 00:00:00 2001
bed121
From: Daniel Rank <dwrank@gmail.com>
bed121
Date: Sun, 27 Sep 2020 16:55:22 -0700
bed121
Subject: [PATCH] slabratetop: Add memcg_cache_params struct def
bed121
bed121
struct memcg_cache_params moved from include/linux/slab.h to
bed121
mm/slab.h in kernel v5.4, causing a compiler error when including
bed121
slub_def.h or slab_def.h in slabratetop's bpf program.
bed121
bed121
It has been removed completely from kernel version 5.9.
bed121
bed121
Add an empty memcg_cache_params struct in slabratetop's bpf
bed121
program so it will compile with kernel versions 5.4 to 5.8.
bed121
---
bed121
 tools/slabratetop.py | 8 +++++++-
bed121
 1 file changed, 7 insertions(+), 1 deletion(-)
bed121
bed121
diff --git a/tools/slabratetop.py b/tools/slabratetop.py
bed121
index 066f79d6..182dbd1d 100755
bed121
--- a/tools/slabratetop.py
bed121
+++ b/tools/slabratetop.py
bed121
@@ -62,7 +62,13 @@ loadavg = "/proc/loadavg"
bed121
 bpf_text = """
bed121
 #include <uapi/linux/ptrace.h>
bed121
 #include <linux/mm.h>
bed121
-#include <linux/slab.h>
bed121
+
bed121
+// memcg_cache_params is a part of kmem_cache, but is not publicly exposed in
bed121
+// kernel versions 5.4 to 5.8.  Define an empty struct for it here to allow the
bed121
+// bpf program to compile.  It has been completely removed in kernel version
bed121
+// 5.9, but it does not hurt to have it here for versions 5.4 to 5.8.
bed121
+struct memcg_cache_params {};
bed121
+
bed121
 #ifdef CONFIG_SLUB
bed121
 #include <linux/slub_def.h>
bed121
 #else
bed121
-- 
bed121
2.29.2
bed121