mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Song Liu <songliubraving@fb.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: Song Liu <song@kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"mingo@redhat.com" <mingo@redhat.com>,
	Kernel Team <Kernel-team@fb.com>,
	"stable@vger.kernel.org" <stable@vger.kernel.org>
Subject: Re: [PATCH] ftrace: clean up hash direct_functions on register failures
Date: Tue, 24 May 2022 15:33:36 +0000	[thread overview]
Message-ID: <5992B5A2-090D-49AB-8CF1-B9B2A6B15350@fb.com> (raw)
In-Reply-To: <20220524104527.3a07878d@gandalf.local.home>



> On May 24, 2022, at 7:45 AM, Steven Rostedt <rostedt@goodmis.org> wrote:
> 
> On Thu, 12 May 2022 15:08:08 -0700
> Song Liu <song@kernel.org> wrote:
> 
>> --- a/kernel/trace/ftrace.c
>> +++ b/kernel/trace/ftrace.c
>> @@ -4465,7 +4465,7 @@ int ftrace_func_mapper_add_ip(struct ftrace_func_mapper *mapper,
>>  * @ip: The instruction pointer address to remove the data from
>>  *
>>  * Returns the data if it is found, otherwise NULL.
>> - * Note, if the data pointer is used as the data itself, (see 
>> + * Note, if the data pointer is used as the data itself, (see
>>  * ftrace_func_mapper_find_ip(), then the return value may be meaningless,
>>  * if the data pointer was set to zero.
>>  */
>> @@ -5200,8 +5200,10 @@ int register_ftrace_direct(unsigned long ip, unsigned long addr)
>> 
>> 	if (!ret && !(direct_ops.flags & FTRACE_OPS_FL_ENABLED)) {
>> 		ret = register_ftrace_function(&direct_ops);
>> -		if (ret)
>> +		if (ret) {
>> 			ftrace_set_filter_ip(&direct_ops, ip, 1, 0);
>> +			remove_hash_entry(direct_functions, entry);
>> +		}
>> 	}
>> 
>> 	if (ret) {
> 
> Perhaps something like this is more robust?

Yeah, this does look better. Do I need to send v2 with this version?

Thanks,
Song

> 
> -- Steve
> 
> diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
> index 4f1d2f5e7263..cd38ad490174 100644
> --- a/kernel/trace/ftrace.c
> +++ b/kernel/trace/ftrace.c
> @@ -5195,8 +5195,6 @@ int register_ftrace_direct(unsigned long ip, unsigned long addr)
> 		goto out_unlock;
> 
> 	ret = ftrace_set_filter_ip(&direct_ops, ip, 0, 0);
> -	if (ret)
> -		remove_hash_entry(direct_functions, entry);
> 
> 	if (!ret && !(direct_ops.flags & FTRACE_OPS_FL_ENABLED)) {
> 		ret = register_ftrace_function(&direct_ops);
> @@ -5205,6 +5203,7 @@ int register_ftrace_direct(unsigned long ip, unsigned long addr)
> 	}
> 
> 	if (ret) {
> +		remove_hash_entry(direct_functions, entry);
> 		kfree(entry);
> 		if (!direct->count) {
> 			list_del_rcu(&direct->next);
> 


  reply	other threads:[~2022-05-24 15:33 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-12 22:08 Song Liu
2022-05-23 18:57 ` Song Liu
2022-05-24  2:13   ` Steven Rostedt
2022-05-24 14:45 ` Steven Rostedt
2022-05-24 15:33   ` Song Liu [this message]
2022-05-24 15:51     ` Steven Rostedt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5992B5A2-090D-49AB-8CF1-B9B2A6B15350@fb.com \
    --to=songliubraving@fb.com \
    --cc=Kernel-team@fb.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=rostedt@goodmis.org \
    --cc=song@kernel.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®