Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1212511ybl; Wed, 4 Dec 2019 19:48:31 -0800 (PST) X-Google-Smtp-Source: APXvYqw+xNrXJspPju3VMgVwRMgim7jHI9DSAFGDUusaRV+gWVpK/ZD88cShEReDRkTb4fLXNQ6d X-Received: by 2002:a9d:6d10:: with SMTP id o16mr5405018otp.28.1575517711321; Wed, 04 Dec 2019 19:48:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575517711; cv=none; d=google.com; s=arc-20160816; b=wlwgZGjiZooLdTcU3CuFJM1z5+SBhlZpAnb6idaR31bbzfHy7Jh9Hn6yGKhUeQPL0D ufnFzaIOruOvsON7EjkUx6tNXtOlngZG1nwMXr13i0zEJNa9kicT42yUa3mxT8Xlu8Ra DeYaz45KhHrt7v/iKE149X3h4ZN4RA2rLdmZY/emVndkN2fboLc747qlkrItkWhj6xsQ 9KDYFqGPTjnh3wHFgwa36c1O2z9SNXnppG8ObYCtcLrGOdP7TnX1NzSJuQ0ZUnHjdOru Cr+VXEZckouSF7HqvExViYaWt2aF0Y7oXynlMTfNORN+mef0xuaYwJhpFRl4vXIMFlDe 38iA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:mime-version:dkim-signature; bh=ORECt6z+ycDjfptUtQ2najrif2bAPibjEeq++PAuMhg=; b=ooGFjY2NKA3Pme+32CxHZjRVjmTVU7Glo1SHCriW3M6xvEPyUhldT1oyh0n/ojvFxF Y1uRo+0z6tZVI09/pZ/vCeWiKqbtnGq/USENJc/pX/lcGbHnmlBU0HFn9V3xRd4IUvhW 9yatvv2qv9jAHhUnjiDlB/2fR80CswaCAIUHwWi3JzdDFTfWm1OmKlFNeq5mZ2uVnvog lio4xusquvmjV+tLjdZGfsfKOEncbUtipZQ9hsvhhf7LvEYwtguVo5VdTM21yKE9rAus dC96/D4tgdFTcsCKmA5e3pSYKrz2tG+z9FoqEaJkqXdCEiUcUIXjLi6gHc8JMHfF3in5 GkSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cloudflare.com header.s=google header.b=Ny1hHF6G; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=cloudflare.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o12si4410590otk.323.2019.12.04.19.48.18; Wed, 04 Dec 2019 19:48:31 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@cloudflare.com header.s=google header.b=Ny1hHF6G; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=cloudflare.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728746AbfLEDqW (ORCPT + 99 others); Wed, 4 Dec 2019 22:46:22 -0500 Received: from mail-qt1-f195.google.com ([209.85.160.195]:44073 "EHLO mail-qt1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728132AbfLEDqW (ORCPT ); Wed, 4 Dec 2019 22:46:22 -0500 Received: by mail-qt1-f195.google.com with SMTP id b5so2133875qtt.11 for ; Wed, 04 Dec 2019 19:46:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloudflare.com; s=google; h=mime-version:from:date:message-id:subject:to:cc :content-transfer-encoding; bh=ORECt6z+ycDjfptUtQ2najrif2bAPibjEeq++PAuMhg=; b=Ny1hHF6G+OWWdUUeOmHg6E8RMSsl645UfKNGSn/v31VjPXZJ9nNaR6qEfddBubtJDT z88BHtZ+QKUYENeT4cWi+9cUSV5alAgAZ0PdiZ8tWKgOIZyA0jCACAz+gQqqVXkLIVhZ EZIbVMoqhO8pHjdw0I3D9VuRW47bSgbOLPKH8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to:cc :content-transfer-encoding; bh=ORECt6z+ycDjfptUtQ2najrif2bAPibjEeq++PAuMhg=; b=saykqQ/ZQ/sLyx0Yo9I8dCH1BZFMqLpHD8MtPjkxUDkDqvbnpGSuqCw9PNI0lfasg9 Gdcbzk4YYeAgcHPoCFQlUVe0+oSdoFFfGFVWpiW2rgZXEbA5eus/wJV5e2YTjn7ZYbzJ p+o6sp9l3ULZIk5vMeM/z+XGlQh6aExOudPH3TZIsXf7hsZQRcxNJS/NMiY22S0sI+AU vOgbjaimomIz3c0QheQANAhblJ4jyfY39IKCi/JUWw0niVpnj+kMGnjFxaH0vCMWjPN8 /GSQyetgnk2j41i5P77e2Fvaq6I9qwrW8xxQKqSmT5M/PLsvxwOKJQ63vAdS3loD1oxF IKWA== X-Gm-Message-State: APjAAAWzNHpC6NfpCAz94QL72NBTqNGwwgb4ydGVckf3QlAL4EzuQMez P4osG2aofUsaeFUPkIwiwvsjNxqnEfWXeHc5tLDSMpqJKZo67g== X-Received: by 2002:ac8:7609:: with SMTP id t9mr5893105qtq.341.1575517581012; Wed, 04 Dec 2019 19:46:21 -0800 (PST) MIME-Version: 1.0 From: Ivan Babrou Date: Wed, 4 Dec 2019 19:46:10 -0800 Message-ID: Subject: perf not picking up symbols for namespaced processes To: linux-kernel Cc: kernel-team , Jiri Olsa , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Alexander Shishkin , Namhyung Kim , sashal@kernel.org, Kenton Varda Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We have a service that forks a child process in a namespace-based sandbox where the mount namespace is intentionally designed to reflect a totally empty filesystem. Our use case is very similar to Chrome's sandbox, for example, but on a server. Within the sandbox, not even the service's own binary is present in the mount namespace. Process tree looks like this: $ sudo pstree -psc 63989 edgeworker(63989)=E2=94=80=E2=94=AC=E2=94=80edgeworker/sbox(255716)=E2=94= =80=E2=94=AC=E2=94=80edgeworker/zygt(255718) =E2=94=82 =E2=94=9C=E2=94=80{edg= eworker/sbox}(255719) =E2=94=82 =E2=94=9C=E2=94=80{edg= eworker/sbox}(255720) =E2=94=82 =E2=94=9C=E2=94=80{edg= eworker/sbox}(255721) =E2=94=9C=E2=94=80edgeworker/stry(5803) =E2=94=9C=E2=94=80edgeworker/stry(63990) =E2=94=9C=E2=94=80edgeworker/stry(106218) =E2=94=9C=E2=94=80edgeworker/stry(191905) =E2=94=9C=E2=94=80edgeworker/stry(255695) =E2=94=9C=E2=94=80edgeworker/supr(255717) Here sbox processes do actual work living in an empty mount namespaces and stry is a helper process for error reporting. All tasks come from the same binary that lives in the root mount namespace, launched by systemd. During "perf script" run on a trace obtained from the system there are these possible outcomes: 1. The first pid to be processed is a non-namespaced helper and symbols are present. 2. The first pid is not found and symbols are present. 3. The first pid is a sandboxed task and symbols are missing. Symbols are missing, because "perf script" tries to jump into an empty sandbox and find a binary there, when in fact it lives outside: getcwd("/state/home/ivan", 4096) =3D 17 open("/proc/self/ns/mnt", O_RDONLY) =3D 5 open("/proc/255719/ns/mnt", O_RDONLY) =3D 6 setns(6, CLONE_NEWNS) =3D 0 stat("/usr/local/bin/edgeworker", 0x7ffedb9b3ca0) =3D -1 ENOENT (No such file or directory) In the second outcome we don't have a PID to figure out the namespace to jump into, so this doesn't happen. It's a good fallback, but it was a bit confusing during debugging. It's not entirely clear to me why sometimes a helper PID is picked, even though it's not the first sample in the recorded trace (at least not in the output). This happens deterministically, or at least appears so. In my process tree it's 255695. I think perf should try to fallback to the default namespace to look up symbols if they are not found inside to cover our case. Relevant piece of logic is here: * https://elixir.free-electrons.com/linux/v5.4.1/source/tools/perf/util/dso= .c#L520