From: Xiao Yang <yangx.jy@cn.fujitsu.com>
To: Joel Fernandes <joel@joelfernandes.org>
Cc: <linux-kernel@vger.kernel.org>,
Steven Rostedt <rostedt@goodmis.org>,
Ingo Molnar <mingo@redhat.com>
Subject: Re: [PATCH] kernel/trace: Stop and wait for kthread on preempt irq module unload
Date: Wed, 29 Apr 2020 19:47:57 +0800 [thread overview]
Message-ID: <5EA9696D.9020505@cn.fujitsu.com> (raw)
In-Reply-To: <20200428141505.GA141102@google.com>
On 2020/4/28 22:15, Joel Fernandes wrote:
> I am wondering if it is because in your test, the kthread exits too quickly.
> We have these comments in kthread_stop():
> * If threadfn() may call do_exit() itself, the caller must ensure
> * task_struct can't go away.
>
> Does the below diff on top of the previous patch help?
>
> ---8<-----------------------
>
> diff --git a/kernel/trace/preemptirq_delay_test.c b/kernel/trace/preemptirq_delay_test.c
> index 1c28ca20e30b6..8051946a18989 100644
> --- a/kernel/trace/preemptirq_delay_test.c
> +++ b/kernel/trace/preemptirq_delay_test.c
> @@ -152,6 +152,8 @@ static int __init preemptirq_delay_init(void)
> int retval;
>
> test_task = preemptirq_start_test();
> + get_task_struct(test_task);
> +
> retval = PTR_ERR_OR_ZERO(test_task);
> if (retval != 0)
> return retval;
> @@ -172,8 +174,10 @@ static void __exit preemptirq_delay_exit(void)
> {
> kobject_put(preemptirq_delay_kobj);
>
> - if (test_task)
> + if (test_task) {
> kthread_stop(test_task);
> + put_task_struct(test_task);
> + }
> }
Hi Joel,
Thanks for your additional patch.
First, We have to avoid kbuild error by including <linux/sched/task.h>
---------------------------------------
kernel/trace/preemptirq_delay_test.c: In function ‘preemptirq_delay_init’:
kernel/trace/preemptirq_delay_test.c:155:2: error: implicit declaration
of function ‘get_task_struct’; did you mean ‘set_task_cpu’?
[-Werror=implicit-function-declaration]
get_task_struct(test_task);
^~~~~~~~~~~~~~~
set_task_cpu
kernel/trace/preemptirq_delay_test.c: In function ‘preemptirq_delay_exit’:
kernel/trace/preemptirq_delay_test.c:179:3: error: implicit declaration
of function ‘put_task_struct’; did you mean ‘set_task_cpu’?
[-Werror=implicit-function-declaration]
put_task_struct(test_task);
^~~~~~~~~~~~~~~
set_task_cpu
cc1: some warnings being treated as errors
---------------------------------------
Second, I used the following steps to do test and didn't get any
warning/panic after applying your additional patch:
---------------------------------------
for i in $(seq 1 100); do modprobe preemptirq_delay_test test_mode=irq
delay=500000; rmmod preemptirq_delay_test; done
for i in $(seq 1 100); do modprobe preemptirq_delay_test
test_mode=preempt delay=500000; rmmod preemptirq_delay_test; done
---------------------------------------
Thanks,
Xiao Yang
next prev parent reply other threads:[~2020-04-29 11:48 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-24 22:36 [PATCH] kernel/trace: Stop and wait for kthread on preempt irq module unload Joel Fernandes (Google)
2020-04-28 10:19 ` Xiao Yang
2020-04-28 14:15 ` Joel Fernandes
2020-04-29 11:47 ` Xiao Yang [this message]
2020-04-28 14:44 ` Steven Rostedt
2020-04-28 14:45 ` Steven Rostedt
2020-04-29 11:54 ` Xiao Yang
2020-04-29 16:31 ` Steven Rostedt
2020-04-29 19:12 ` Joel Fernandes
2020-05-06 13:38 ` Steven Rostedt
2020-05-06 14:30 ` [PATCH] tracing: Wait for preempt irq delay thread to finish Steven Rostedt
2020-05-07 10:05 ` Xiao Yang
2020-05-07 12:29 ` joel
2020-04-29 11:37 ` [PATCH] kernel/trace: Stop and wait for kthread on preempt irq module unload Xiao Yang
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=5EA9696D.9020505@cn.fujitsu.com \
--to=yangx.jy@cn.fujitsu.com \
--cc=joel@joelfernandes.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=rostedt@goodmis.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;
as well as URLs for NNTP newsgroup(s).