55
66#include <linux/compiler.h>
77#include <linux/ftrace.h>
8- #include <linux/rethook.h>
8+ #include <linux/rcupdate.h>
9+ #include <linux/refcount.h>
10+ #include <linux/slab.h>
911
1012struct fprobe ;
11-
1213typedef int (* fprobe_entry_cb )(struct fprobe * fp , unsigned long entry_ip ,
1314 unsigned long ret_ip , struct ftrace_regs * regs ,
1415 void * entry_data );
@@ -17,35 +18,57 @@ typedef void (*fprobe_exit_cb)(struct fprobe *fp, unsigned long entry_ip,
1718 unsigned long ret_ip , struct ftrace_regs * regs ,
1819 void * entry_data );
1920
21+ /**
22+ * struct fprobe_hlist_node - address based hash list node for fprobe.
23+ *
24+ * @hlist: The hlist node for address search hash table.
25+ * @addr: One of the probing address of @fp.
26+ * @fp: The fprobe which owns this.
27+ */
28+ struct fprobe_hlist_node {
29+ struct hlist_node hlist ;
30+ unsigned long addr ;
31+ struct fprobe * fp ;
32+ };
33+
34+ /**
35+ * struct fprobe_hlist - hash list nodes for fprobe.
36+ *
37+ * @hlist: The hlist node for existence checking hash table.
38+ * @rcu: rcu_head for RCU deferred release.
39+ * @fp: The fprobe which owns this fprobe_hlist.
40+ * @size: The size of @array.
41+ * @array: The fprobe_hlist_node for each address to probe.
42+ */
43+ struct fprobe_hlist {
44+ struct hlist_node hlist ;
45+ struct rcu_head rcu ;
46+ struct fprobe * fp ;
47+ int size ;
48+ struct fprobe_hlist_node array [] __counted_by (size );
49+ };
50+
2051/**
2152 * struct fprobe - ftrace based probe.
22- * @ops: The ftrace_ops.
53+ *
2354 * @nmissed: The counter for missing events.
2455 * @flags: The status flag.
25- * @rethook: The rethook data structure. (internal data)
2656 * @entry_data_size: The private data storage size.
27- * @nr_maxactive: The max number of active functions.
57+ * @nr_maxactive: The max number of active functions. (*deprecated)
2858 * @entry_handler: The callback function for function entry.
2959 * @exit_handler: The callback function for function exit.
60+ * @hlist_array: The fprobe_hlist for fprobe search from IP hash table.
3061 */
3162struct fprobe {
32- #ifdef CONFIG_FUNCTION_TRACER
33- /*
34- * If CONFIG_FUNCTION_TRACER is not set, CONFIG_FPROBE is disabled too.
35- * But user of fprobe may keep embedding the struct fprobe on their own
36- * code. To avoid build error, this will keep the fprobe data structure
37- * defined here, but remove ftrace_ops data structure.
38- */
39- struct ftrace_ops ops ;
40- #endif
4163 unsigned long nmissed ;
4264 unsigned int flags ;
43- struct rethook * rethook ;
4465 size_t entry_data_size ;
4566 int nr_maxactive ;
4667
4768 fprobe_entry_cb entry_handler ;
4869 fprobe_exit_cb exit_handler ;
70+
71+ struct fprobe_hlist * hlist_array ;
4972};
5073
5174/* This fprobe is soft-disabled. */
@@ -121,4 +144,9 @@ static inline void enable_fprobe(struct fprobe *fp)
121144 fp -> flags &= ~FPROBE_FL_DISABLED ;
122145}
123146
147+ /* The entry data size is 4 bits (=16) * sizeof(long) in maximum */
148+ #define FPROBE_DATA_SIZE_BITS 4
149+ #define MAX_FPROBE_DATA_SIZE_WORD ((1L << FPROBE_DATA_SIZE_BITS) - 1)
150+ #define MAX_FPROBE_DATA_SIZE (MAX_FPROBE_DATA_SIZE_WORD * sizeof(long))
151+
124152#endif
0 commit comments