From: Yang Jihong <yangjihong1@huawei.com>
To: Chen Zhongjin <chenzhongjin@huawei.com>,
<linux-kernel@vger.kernel.org>,
<linux-trace-kernel@vger.kernel.org>
Cc: <naveen.n.rao@linux.ibm.com>, <anil.s.keshavamurthy@intel.com>,
<davem@davemloft.net>, <paulmck@kernel.org>,
<mhiramat@kernel.org>, <akpm@linux-foundation.org>,
<tglx@linutronix.de>, <peterz@infradead.org>, <pmladek@suse.com>,
<dianders@chromium.org>, <npiggin@gmail.com>,
<mpe@ellerman.id.au>, <jkl820.git@gmail.com>,
<juerg.haefliger@canonical.com>, <rick.p.edgecombe@intel.com>,
<eric.devolder@oracle.com>, <mic@digikod.net>
Subject: Re: [RFC PATCH] kprobes: Use synchronize_rcu_tasks_rude in kprobe_optimizer
Date: Tue, 9 Jan 2024 19:28:29 +0800 [thread overview]
Message-ID: <29eaed4d-c4e5-cf9b-113b-da146b719820@huawei.com> (raw)
In-Reply-To: <20240102034024.256326-1-chenzhongjin@huawei.com>
Hello,
PING.
I had a similar problem. Is this solution feasible?
Thanks,
Yang
On 2024/1/2 11:40, Chen Zhongjin wrote:
> There is a deadlock scenario in kprobe_optimizer():
>
> pid A pid B pid C
> kprobe_optimizer() do_exit() perf_kprobe_init()
> mutex_lock(&kprobe_mutex) exit_tasks_rcu_start() mutex_lock(&kprobe_mutex)
> synchronize_rcu_tasks() zap_pid_ns_processes() // waiting kprobe_mutex
> // waiting tasks_rcu_exit_srcu kernel_wait4()
> // waiting pid C exit
>
> To avoid this deadlock loop, use synchronize_rcu_tasks_rude() in kprobe_optimizer()
> rather than synchronize_rcu_tasks(). synchronize_rcu_tasks_rude() can also promise
> that all preempted tasks have scheduled, but it will not wait tasks_rcu_exit_srcu.
>
> Signed-off-by: Chen Zhongjin <chenzhongjin@huawei.com>
> ---
> arch/Kconfig | 2 +-
> kernel/kprobes.c | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/arch/Kconfig b/arch/Kconfig
> index f4b210ab0612..dc6a18854017 100644
> --- a/arch/Kconfig
> +++ b/arch/Kconfig
> @@ -104,7 +104,7 @@ config STATIC_CALL_SELFTEST
> config OPTPROBES
> def_bool y
> depends on KPROBES && HAVE_OPTPROBES
> - select TASKS_RCU if PREEMPTION
> + select TASKS_RUDE_RCU
>
> config KPROBES_ON_FTRACE
> def_bool y
> diff --git a/kernel/kprobes.c b/kernel/kprobes.c
> index d5a0ee40bf66..09056ae50c58 100644
> --- a/kernel/kprobes.c
> +++ b/kernel/kprobes.c
> @@ -623,7 +623,7 @@ static void kprobe_optimizer(struct work_struct *work)
> * Note that on non-preemptive kernel, this is transparently converted
> * to synchronoze_sched() to wait for all interrupts to have completed.
> */
> - synchronize_rcu_tasks();
> + synchronize_rcu_tasks_rude();
>
> /* Step 3: Optimize kprobes after quiesence period */
> do_optimize_kprobes();
>
next prev parent reply other threads:[~2024-01-09 11:28 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-02 3:40 Chen Zhongjin
2024-01-09 11:28 ` Yang Jihong [this message]
2024-01-27 19:22 ` Paul E. McKenney
2024-01-29 0:58 ` Yang Jihong
2024-02-03 22:00 ` Paul E. McKenney
2024-02-04 1:16 ` Yang Jihong
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=29eaed4d-c4e5-cf9b-113b-da146b719820@huawei.com \
--to=yangjihong1@huawei.com \
--cc=akpm@linux-foundation.org \
--cc=anil.s.keshavamurthy@intel.com \
--cc=chenzhongjin@huawei.com \
--cc=davem@davemloft.net \
--cc=dianders@chromium.org \
--cc=eric.devolder@oracle.com \
--cc=jkl820.git@gmail.com \
--cc=juerg.haefliger@canonical.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mhiramat@kernel.org \
--cc=mic@digikod.net \
--cc=mpe@ellerman.id.au \
--cc=naveen.n.rao@linux.ibm.com \
--cc=npiggin@gmail.com \
--cc=paulmck@kernel.org \
--cc=peterz@infradead.org \
--cc=pmladek@suse.com \
--cc=rick.p.edgecombe@intel.com \
--cc=tglx@linutronix.de \
/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®