|
|
6da96d |
From cdfa74f35910421e807d7e1deb212a5bca138413 Mon Sep 17 00:00:00 2001
|
|
|
6da96d |
From: =?UTF-8?q?Mauricio=20V=C3=A1squez?= <mauricio@kinvolk.io>
|
|
|
6da96d |
Date: Thu, 21 May 2020 11:50:52 -0500
|
|
|
6da96d |
Subject: [PATCH 1/3] Fix KFUNC_PROBE return value
|
|
|
6da96d |
MIME-Version: 1.0
|
|
|
6da96d |
Content-Type: text/plain; charset=UTF-8
|
|
|
6da96d |
Content-Transfer-Encoding: 8bit
|
|
|
6da96d |
|
|
|
6da96d |
The KFUNC_PROBE macro is using "void" as return type, this is causing problems
|
|
|
6da96d |
in some tools that have a filtering enable that returns 0.
|
|
|
6da96d |
|
|
|
6da96d |
Reproducer: (Notice that it requires BTF support)
|
|
|
6da96d |
|
|
|
6da96d |
```
|
|
|
6da96d |
$ python opensnoop.py --pid 5
|
|
|
6da96d |
/virtual/main.c:33:21: error: void function '____kretfunc__do_sys_open' should not return a value [-Wreturn-type]
|
|
|
6da96d |
if (pid != 5) { return 0; }
|
|
|
6da96d |
^ ~
|
|
|
6da96d |
1 error generated.
|
|
|
6da96d |
...
|
|
|
6da96d |
```
|
|
|
6da96d |
|
|
|
6da96d |
Signed-off-by: Mauricio Vásquez <mauricio@kinvolk.io>
|
|
|
6da96d |
---
|
|
|
6da96d |
src/cc/export/helpers.h | 4 ++--
|
|
|
6da96d |
tools/klockstat.py | 6 +++---
|
|
|
6da96d |
tools/opensnoop.py | 2 ++
|
|
|
6da96d |
3 files changed, 7 insertions(+), 5 deletions(-)
|
|
|
6da96d |
|
|
|
6da96d |
diff --git a/src/cc/export/helpers.h b/src/cc/export/helpers.h
|
|
|
6da96d |
index b38b3f20..c6edc9cd 100644
|
|
|
6da96d |
--- a/src/cc/export/helpers.h
|
|
|
6da96d |
+++ b/src/cc/export/helpers.h
|
|
|
6da96d |
@@ -998,7 +998,7 @@ int raw_tracepoint__##event(struct bpf_raw_tracepoint_args *ctx)
|
|
|
6da96d |
#define BPF_PROG(name, args...) \
|
|
|
6da96d |
int name(unsigned long long *ctx); \
|
|
|
6da96d |
__attribute__((always_inline)) \
|
|
|
6da96d |
-static void ____##name(unsigned long long *ctx, ##args); \
|
|
|
6da96d |
+static int ____##name(unsigned long long *ctx, ##args); \
|
|
|
6da96d |
int name(unsigned long long *ctx) \
|
|
|
6da96d |
{ \
|
|
|
6da96d |
_Pragma("GCC diagnostic push") \
|
|
|
6da96d |
@@ -1007,7 +1007,7 @@ int name(unsigned long long *ctx) \
|
|
|
6da96d |
_Pragma("GCC diagnostic pop") \
|
|
|
6da96d |
return 0; \
|
|
|
6da96d |
} \
|
|
|
6da96d |
-static void ____##name(unsigned long long *ctx, ##args)
|
|
|
6da96d |
+static int ____##name(unsigned long long *ctx, ##args)
|
|
|
6da96d |
|
|
|
6da96d |
#define KFUNC_PROBE(event, args...) \
|
|
|
6da96d |
BPF_PROG(kfunc__ ## event, args)
|
|
|
6da96d |
diff --git a/tools/klockstat.py b/tools/klockstat.py
|
|
|
6da96d |
index 540dd4e7..7cb15ad3 100755
|
|
|
6da96d |
--- a/tools/klockstat.py
|
|
|
6da96d |
+++ b/tools/klockstat.py
|
|
|
6da96d |
@@ -352,17 +352,17 @@ int mutex_lock_enter(struct pt_regs *ctx)
|
|
|
6da96d |
program_kfunc = """
|
|
|
6da96d |
KFUNC_PROBE(mutex_unlock, void *lock)
|
|
|
6da96d |
{
|
|
|
6da96d |
- do_mutex_unlock_enter();
|
|
|
6da96d |
+ return do_mutex_unlock_enter();
|
|
|
6da96d |
}
|
|
|
6da96d |
|
|
|
6da96d |
KRETFUNC_PROBE(mutex_lock, void *lock, int ret)
|
|
|
6da96d |
{
|
|
|
6da96d |
- do_mutex_lock_return();
|
|
|
6da96d |
+ return do_mutex_lock_return();
|
|
|
6da96d |
}
|
|
|
6da96d |
|
|
|
6da96d |
KFUNC_PROBE(mutex_lock, void *lock)
|
|
|
6da96d |
{
|
|
|
6da96d |
- do_mutex_lock_enter(ctx, 3);
|
|
|
6da96d |
+ return do_mutex_lock_enter(ctx, 3);
|
|
|
6da96d |
}
|
|
|
6da96d |
|
|
|
6da96d |
"""
|
|
|
6da96d |
diff --git a/tools/opensnoop.py b/tools/opensnoop.py
|
|
|
6da96d |
index b28d7d55..9a526625 100755
|
|
|
6da96d |
--- a/tools/opensnoop.py
|
|
|
6da96d |
+++ b/tools/opensnoop.py
|
|
|
6da96d |
@@ -197,6 +197,8 @@ KRETFUNC_PROBE(do_sys_open, int dfd, const char *filename, int flags, int mode,
|
|
|
6da96d |
data.ret = ret;
|
|
|
6da96d |
|
|
|
6da96d |
events.perf_submit(ctx, &data, sizeof(data));
|
|
|
6da96d |
+
|
|
|
6da96d |
+ return 0:
|
|
|
6da96d |
}
|
|
|
6da96d |
"""
|
|
|
6da96d |
|
|
|
6da96d |
--
|
|
|
6da96d |
2.25.4
|
|
|
6da96d |
|