From: sashiko-bot@kernel.org
To: "Namhyung Kim" <namhyung@kernel.org>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH v2 07/11] perf tools: Check thread liveness when accessing /proc
Date: Mon, 16 Nov 2026 06:38:46 +0000 [thread overview]
Message-ID: <sashiko-outbox-216287@kernel.org> (raw)
In-Reply-To: <20261116055731.707164-8-namhyung@kernel.org>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] perf tools: nsinfo__check_proc() in
dso__filename_with_chroot() inside mntns
- [Medium] perf tools: thread__init_maps() marks pipe-mode threads
exited in perf inject
--
commit e4d060b6fbe7a9b1256d33ec34cd9b157fb2e968
Author: Namhyung Kim <namhyung@kernel.org>
perf tools: Check thread liveness when accessing /proc
This commit adds thread__exited() and thread__is_alive() to track thread
liveness and propagates thread exit and boot ID mismatches to nsinfo so
/proc accesses can be skipped for exited or offline threads.
> diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
> index ce98613868e7d..0a3e40aeadbbb 100644
> --- a/tools/perf/util/dso.c
> +++ b/tools/perf/util/dso.c
> @@ -587,7 +587,12 @@ static int do_open(char *name) EXCLUSIVE_LOCKS_REQUIRED(_dso__data_open_lock)
>
> char *dso__filename_with_chroot(const struct dso *dso, const char *filename)
> {
> - return filename_with_chroot(nsinfo__pid(dso__nsinfo_const(dso)), filename);
> + struct nsinfo *nsi = (struct nsinfo *)dso__nsinfo_const(dso);
> +
> + if (!nsinfo__check_proc(nsi))
> + return NULL;
> +
> + return filename_with_chroot(nsinfo__pid(nsi), filename);
> }
[Severity: Medium]
Can calling nsinfo__check_proc(nsi) here mark a live container thread's
nsinfo as exited when dso__filename_with_chroot() runs inside the
container's mount namespace?
dso__load() and dso__get_filename() call dso__filename_with_chroot()
between nsinfo__mountns_enter() and nsinfo__mountns_exit(). When
dso__load() probes distro debuginfo paths that do not exist before
reaching DSO_BINARY_TYPE__SYSTEM_PATH_DSO, nsinfo__check_proc() looks up
/proc/<host_pid>/task/<host_tid>/status inside the container's mount
namespace. If the container has its own /proc mount for a PID namespace,
that host PID lookup fails or matches a different task, so
nsinfo__check_proc() calls nsinfo__set_exited(nsi). Because dso->nsinfo
is shared with thread->nsinfo, this clears need_setns and breaks
subsequent mount namespace entry and DSO loading for the live thread.
> diff --git a/tools/perf/util/thread.c b/tools/perf/util/thread.c
> index 5d1c886add3e6..fda718ea5d7e6 100644
> --- a/tools/perf/util/thread.c
> +++ b/tools/perf/util/thread.c
> @@ -37,6 +37,16 @@ int thread__init_maps(struct thread *thread, struct machine *machine)
> }
> }
>
> + if (thread__pid(thread) != 0 || thread__tid(thread) != 0) {
> + if (!machine || !machine__is_host(machine) ||
> + !perf_env__is_same_boot(machine->env)) {
> + struct nsinfo *nsi = thread__get_nsinfo(thread);
> +
> + nsinfo__set_exited(nsi);
> + nsinfo__put(nsi);
> + }
> + }
> +
> return thread__maps(thread) ? 0 : -1;
> }
[Severity: Medium]
Does checking !perf_env__is_same_boot(machine->env) here (and in
__thread__reset_nsinfo(), thread__is_alive(), and
machine__update_thread_pid()) mark all threads as exited during live
pipe-mode sessions such as "perf record -o - | perf inject -b"?
When __perf_session__new() opens a read-mode pipe, it sets
session->header.env.offline = true and perf_session__read_header()
returns before reading any feature records. In cmd_inject(),
inject.tool.feature is set to perf_event__repipe_op2_synth rather than
perf_event__process_feature(), so HEADER_BOOT_ID is never populated in
machine->env->boot_id. perf_env__is_same_boot(machine->env) then returns
false for every thread, disabling mount namespace entry, chroot
resolution, and /proc lookups during pipe-mode build-id and JIT
injection.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261116055731.707164-1-namhyung@kernel.org?part=7
next prev parent reply other threads:[~2026-11-16 6:38 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-16 5:57 [PATCH v2 00/11] perf tools: Enhance namespace and chroot handling Namhyung Kim
2026-11-16 5:57 ` [PATCH v2 01/11] perf tools: Add HEADER_BOOT_ID feature Namhyung Kim
2026-11-16 6:09 ` sashiko-bot
2026-11-16 5:57 ` [PATCH v2 02/11] perf tools: Add perf_env__is_same_boot() Namhyung Kim
2026-11-16 6:02 ` sashiko-bot
2026-11-16 5:57 ` [PATCH v2 03/11] perf tools: Add nsinfo__new_thread() to track tid Namhyung Kim
2026-11-16 6:16 ` sashiko-bot
2026-11-16 5:57 ` [PATCH v2 04/11] perf tools: Add lock to struct nsinfo Namhyung Kim
2026-11-16 6:17 ` sashiko-bot
2026-11-16 5:57 ` [PATCH v2 05/11] perf tools: Defer /proc lookup until nsinfo is used Namhyung Kim
2026-11-16 6:11 ` sashiko-bot
2026-11-16 5:57 ` [PATCH v2 06/11] perf tools: Verify thread status and mount namespace inode Namhyung Kim
2026-11-16 6:14 ` sashiko-bot
2026-11-16 5:57 ` [PATCH v2 07/11] perf tools: Check thread liveness when accessing /proc Namhyung Kim
2026-11-16 6:38 ` sashiko-bot [this message]
2026-11-16 5:57 ` [PATCH v2 08/11] perf tools: Export filename__read_build_id_ns() Namhyung Kim
2026-11-16 6:16 ` sashiko-bot
2026-11-16 5:57 ` [PATCH v2 09/11] perf tools: Only enter mount namespace if necessary Namhyung Kim
2026-11-16 6:34 ` sashiko-bot
2026-11-16 5:57 ` [PATCH v2 10/11] perf tools: Scope mount namespace entry in dso__load() Namhyung Kim
2026-11-16 6:16 ` sashiko-bot
2026-11-16 5:57 ` [PATCH v2 11/11] perf tests: Add namespace, nsinfo, and boot ID tests Namhyung Kim
2026-11-16 6:24 ` sashiko-bot
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=sashiko-outbox-216287@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=namhyung@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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