Avi Zana
Avi Zana

Reputation: 89

Can't remove kernel driver after enabling tracepoint

I added a new trace point to a kernel module that I built. A few seconds after insmod, my driver refcnt stays on 1 and from this point I can't unload my module.

I've followed the instructions on https://lwn.net/Articles/383362/.

Running on Ubuntu 18.04.4 - kernel 4.15.0-rc4.

I enabled traces to check what is using my module and it looks like the trace point code (perf_trace_init) is "holding" my module.

Any idea what I'm doing wrong?

Code snippet:

#undef TRACE_SYSTEM
#define TRACE_SYSTEM dummy

#if !defined(_DUMMY_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
#define _DUMMY_TRACE_H

#include <linux/tracepoint.h>

TRACE_EVENT(dummy_trace,

        TP_PROTO(int bytes),

        TP_ARGS(bytes),

        TP_STRUCT__entry(
                __field(int, bytes)
            ),

        TP_fast_assign(
                __entry->bytes = bytes;
            ),

        TP_printk("bytes = %d", __entry->bytes)
);

#endif /* _DUMMY_TRACE_H */

/* This part must be outside protection */
#undef TRACE_INCLUDE_PATH
#define TRACE_INCLUDE_PATH /home/user/dummy/
#define TRACE_INCLUDE_FILE dummy_trace
#include <trace/define_trace.h>

then in one of my C source files I just called trace_dummy_trace with bytes parameter.

Upvotes: 0

Views: 97

Answers (0)

Related Questions