All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH -next] ftrace: Fix build error whithout CONFIG_MODULES
@ 2022-07-26 11:35 WangJingjin
  2022-07-26 15:39 ` Steven Rostedt
  2022-08-01  8:47 ` [PATCH v2 " Wang Jingjin
  0 siblings, 2 replies; 3+ messages in thread
From: WangJingjin @ 2022-07-26 11:35 UTC (permalink / raw)
  To: rostedt, mingo, daniel, song
  Cc: linux-kernel, zhengbin13, gaochao49, wangjingjin1

Fix build errors on kernel/trace/ftrace.c:
    ‘ops_references_rec’ defined but not used.

Fixes: 53cd885bc5c3 ("ftrace: Allow IPMODIFY and DIRECT ops on the same function")
Signed-off-by: Wang Jingjin <wangjingjin1@huawei.com>
---
 kernel/trace/ftrace.c | 30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index bc921a3f7ea8..16d3d3884e17 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -1861,8 +1861,6 @@ static void ftrace_hash_rec_enable_modify(struct ftrace_ops *ops,
 	ftrace_hash_rec_update_modify(ops, filter_hash, 1);
 }

-static bool ops_references_ip(struct ftrace_ops *ops, unsigned long ip);
-
 /*
  * Try to update IPMODIFY flag on each ftrace_rec. Return 0 if it is OK
  * or no-needed to update, -EBUSY if it detects a conflict of the flag
@@ -3108,6 +3106,7 @@ static inline int ops_traces_mod(struct ftrace_ops *ops)
 		ftrace_hash_empty(ops->func_hash->notrace_hash);
 }

+#if defined(CONFIG_DYNAMIC_FTRACE_WITH_DIRECT_CALLS) || defined(CONFIG_MODULES)
 /*
  * Check if the current ops references the given ip.
  *
@@ -3137,19 +3136,7 @@ ops_references_ip(struct ftrace_ops *ops, unsigned long ip)

 	return true;
 }
-
-/*
- * Check if the current ops references the record.
- *
- * If the ops traces all functions, then it was already accounted for.
- * If the ops does not trace the current record function, skip it.
- * If the ops ignores the function via notrace filter, skip it.
- */
-static bool
-ops_references_rec(struct ftrace_ops *ops, struct dyn_ftrace *rec)
-{
-	return ops_references_ip(ops, rec->ip);
-}
+#endif

 static int ftrace_update_code(struct module *mod, struct ftrace_page *new_pgs)
 {
@@ -6818,6 +6805,19 @@ static int ftrace_get_trampoline_kallsym(unsigned int symnum,

 static LIST_HEAD(ftrace_mod_maps);

+/*
+ * Check if the current ops references the record.
+ *
+ * If the ops traces all functions, then it was already accounted for.
+ * If the ops does not trace the current record function, skip it.
+ * If the ops ignores the function via notrace filter, skip it.
+ */
+static bool
+ops_references_rec(struct ftrace_ops *ops, struct dyn_ftrace *rec)
+{
+	return ops_references_ip(ops, rec->ip);
+}
+
 static int referenced_filters(struct dyn_ftrace *rec)
 {
 	struct ftrace_ops *ops;
--
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH -next] ftrace: Fix build error whithout CONFIG_MODULES
  2022-07-26 11:35 [PATCH -next] ftrace: Fix build error whithout CONFIG_MODULES WangJingjin
@ 2022-07-26 15:39 ` Steven Rostedt
  2022-08-01  8:47 ` [PATCH v2 " Wang Jingjin
  1 sibling, 0 replies; 3+ messages in thread
From: Steven Rostedt @ 2022-07-26 15:39 UTC (permalink / raw)
  To: WangJingjin; +Cc: mingo, daniel, song, linux-kernel, zhengbin13, gaochao49

On Tue, 26 Jul 2022 19:35:38 +0800
WangJingjin <wangjingjin1@huawei.com> wrote:

> Fix build errors on kernel/trace/ftrace.c:
>     ‘ops_references_rec’ defined but not used.
> 
> Fixes: 53cd885bc5c3 ("ftrace: Allow IPMODIFY and DIRECT ops on the same function")
> Signed-off-by: Wang Jingjin <wangjingjin1@huawei.com>
> ---
>  kernel/trace/ftrace.c | 30 +++++++++++++++---------------
>  1 file changed, 15 insertions(+), 15 deletions(-)
> 
> diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
> index bc921a3f7ea8..16d3d3884e17 100644
> --- a/kernel/trace/ftrace.c
> +++ b/kernel/trace/ftrace.c
> @@ -1861,8 +1861,6 @@ static void ftrace_hash_rec_enable_modify(struct ftrace_ops *ops,
>  	ftrace_hash_rec_update_modify(ops, filter_hash, 1);
>  }
> 
> -static bool ops_references_ip(struct ftrace_ops *ops, unsigned long ip);
> -
>  /*
>   * Try to update IPMODIFY flag on each ftrace_rec. Return 0 if it is OK
>   * or no-needed to update, -EBUSY if it detects a conflict of the flag
> @@ -3108,6 +3106,7 @@ static inline int ops_traces_mod(struct ftrace_ops *ops)
>  		ftrace_hash_empty(ops->func_hash->notrace_hash);
>  }
> 
> +#if defined(CONFIG_DYNAMIC_FTRACE_WITH_DIRECT_CALLS) || defined(CONFIG_MODULES)

Honesly, this block needs to be moved down to closer to where it is
first used (just above the #ifdef CONFIG_MODULES).

>  /*
>   * Check if the current ops references the given ip.
>   *
> @@ -3137,19 +3136,7 @@ ops_references_ip(struct ftrace_ops *ops, unsigned long ip)
> 
>  	return true;
>  }
> -
> -/*
> - * Check if the current ops references the record.
> - *
> - * If the ops traces all functions, then it was already accounted for.
> - * If the ops does not trace the current record function, skip it.
> - * If the ops ignores the function via notrace filter, skip it.
> - */
> -static bool
> -ops_references_rec(struct ftrace_ops *ops, struct dyn_ftrace *rec)
> -{
> -	return ops_references_ip(ops, rec->ip);
> -}
> +#endif
> 
>  static int ftrace_update_code(struct module *mod, struct ftrace_page *new_pgs)
>  {
> @@ -6818,6 +6805,19 @@ static int ftrace_get_trampoline_kallsym(unsigned int symnum,
> 
>  static LIST_HEAD(ftrace_mod_maps);
> 
> +/*
> + * Check if the current ops references the record.
> + *
> + * If the ops traces all functions, then it was already accounted for.
> + * If the ops does not trace the current record function, skip it.
> + * If the ops ignores the function via notrace filter, skip it.
> + */
> +static bool
> +ops_references_rec(struct ftrace_ops *ops, struct dyn_ftrace *rec)
> +{
> +	return ops_references_ip(ops, rec->ip);
> +}

And we should just nuke this function, and call the ops_references_ip()
directly, as it is only used in one location.

 static int referenced_filters(struct dyn_ftrace *rec)
 {
        struct ftrace_ops *ops;
        int cnt = 0;
 
        for (ops = ftrace_ops_list; ops != &ftrace_list_end; ops = ops->next) {
-               if (ops_references_rec(ops, rec)) {
+               if (ops_references_ip(ops, rec->ip)) {
                        if (WARN_ON_ONCE(ops->flags & FTRACE_OPS_FL_DIRECT))
                                continue;
                        if (WARN_ON_ONCE(ops->flags & FTRACE_OPS_FL_IPMODIFY))


-- Steve

> +
>  static int referenced_filters(struct dyn_ftrace *rec)
>  {
>  	struct ftrace_ops *ops;
> --
> 2.25.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH v2 -next] ftrace: Fix build error whithout CONFIG_MODULES
  2022-07-26 11:35 [PATCH -next] ftrace: Fix build error whithout CONFIG_MODULES WangJingjin
  2022-07-26 15:39 ` Steven Rostedt
@ 2022-08-01  8:47 ` Wang Jingjin
  1 sibling, 0 replies; 3+ messages in thread
From: Wang Jingjin @ 2022-08-01  8:47 UTC (permalink / raw)
  To: rostedt
  Cc: daniel, gaochao49, linux-kernel, mingo, song, wangjingjin1,
	zhengbin13, cj.chengjian

Fix build errors on kernel/trace/ftrace.c:
    ‘ops_references_rec’ defined but not used.

Fixes: 53cd885bc5c3 ("ftrace: Allow IPMODIFY and DIRECT ops on the same function")
Signed-off-by: Wang Jingjin <wangjingjin1@huawei.com>
---
v2:
- delete function - ops_references_rec
- move function - ops_references_ip above the "#ifdef CONFIG_MODULES"
 kernel/trace/ftrace.c | 79 ++++++++++++++++++-------------------------
 1 file changed, 33 insertions(+), 46 deletions(-)

diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index bc921a3f7ea8..aa5e29e40da8 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -1861,8 +1861,6 @@ static void ftrace_hash_rec_enable_modify(struct ftrace_ops *ops,
 	ftrace_hash_rec_update_modify(ops, filter_hash, 1);
 }

-static bool ops_references_ip(struct ftrace_ops *ops, unsigned long ip);
-
 /*
  * Try to update IPMODIFY flag on each ftrace_rec. Return 0 if it is OK
  * or no-needed to update, -EBUSY if it detects a conflict of the flag
@@ -3108,49 +3106,6 @@ static inline int ops_traces_mod(struct ftrace_ops *ops)
 		ftrace_hash_empty(ops->func_hash->notrace_hash);
 }

-/*
- * Check if the current ops references the given ip.
- *
- * If the ops traces all functions, then it was already accounted for.
- * If the ops does not trace the current record function, skip it.
- * If the ops ignores the function via notrace filter, skip it.
- */
-static bool
-ops_references_ip(struct ftrace_ops *ops, unsigned long ip)
-{
-	/* If ops isn't enabled, ignore it */
-	if (!(ops->flags & FTRACE_OPS_FL_ENABLED))
-		return false;
-
-	/* If ops traces all then it includes this function */
-	if (ops_traces_mod(ops))
-		return true;
-
-	/* The function must be in the filter */
-	if (!ftrace_hash_empty(ops->func_hash->filter_hash) &&
-	    !__ftrace_lookup_ip(ops->func_hash->filter_hash, ip))
-		return false;
-
-	/* If in notrace hash, we ignore it too */
-	if (ftrace_lookup_ip(ops->func_hash->notrace_hash, ip))
-		return false;
-
-	return true;
-}
-
-/*
- * Check if the current ops references the record.
- *
- * If the ops traces all functions, then it was already accounted for.
- * If the ops does not trace the current record function, skip it.
- * If the ops ignores the function via notrace filter, skip it.
- */
-static bool
-ops_references_rec(struct ftrace_ops *ops, struct dyn_ftrace *rec)
-{
-	return ops_references_ip(ops, rec->ip);
-}
-
 static int ftrace_update_code(struct module *mod, struct ftrace_page *new_pgs)
 {
 	bool init_nop = ftrace_need_init_nop();
@@ -6812,6 +6767,38 @@ static int ftrace_get_trampoline_kallsym(unsigned int symnum,
 	return -ERANGE;
 }

+#if defined(CONFIG_DYNAMIC_FTRACE_WITH_DIRECT_CALLS) || defined(CONFIG_MODULES)
+/*
+ * Check if the current ops references the given ip.
+ *
+ * If the ops traces all functions, then it was already accounted for.
+ * If the ops does not trace the current record function, skip it.
+ * If the ops ignores the function via notrace filter, skip it.
+ */
+static bool
+ops_references_ip(struct ftrace_ops *ops, unsigned long ip)
+{
+	/* If ops isn't enabled, ignore it */
+	if (!(ops->flags & FTRACE_OPS_FL_ENABLED))
+		return false;
+
+	/* If ops traces all then it includes this function */
+	if (ops_traces_mod(ops))
+		return true;
+
+	/* The function must be in the filter */
+	if (!ftrace_hash_empty(ops->func_hash->filter_hash) &&
+	    !__ftrace_lookup_ip(ops->func_hash->filter_hash, ip))
+		return false;
+
+	/* If in notrace hash, we ignore it too */
+	if (ftrace_lookup_ip(ops->func_hash->notrace_hash, ip))
+		return false;
+
+	return true;
+}
+#endif
+
 #ifdef CONFIG_MODULES

 #define next_to_ftrace_page(p) container_of(p, struct ftrace_page, next)
@@ -6824,7 +6811,7 @@ static int referenced_filters(struct dyn_ftrace *rec)
 	int cnt = 0;

 	for (ops = ftrace_ops_list; ops != &ftrace_list_end; ops = ops->next) {
-		if (ops_references_rec(ops, rec)) {
+		if (ops_references_ip(ops, rec->ip)) {
 			if (WARN_ON_ONCE(ops->flags & FTRACE_OPS_FL_DIRECT))
 				continue;
 			if (WARN_ON_ONCE(ops->flags & FTRACE_OPS_FL_IPMODIFY))
--
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-08-01  8:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-26 11:35 [PATCH -next] ftrace: Fix build error whithout CONFIG_MODULES WangJingjin
2022-07-26 15:39 ` Steven Rostedt
2022-08-01  8:47 ` [PATCH v2 " Wang Jingjin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.