Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp4922507ybv; Tue, 11 Feb 2020 06:00:25 -0800 (PST) X-Google-Smtp-Source: APXvYqw3gteMo64VVhfj4QEHZozdeI1rS3AQC+/Jd5xUeHbVUTPZnbTTcH51ZWSthDKWr84ZUkxo X-Received: by 2002:a9d:75da:: with SMTP id c26mr5357238otl.40.1581429625487; Tue, 11 Feb 2020 06:00:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581429625; cv=none; d=google.com; s=arc-20160816; b=JDaYT9/k9Tn1G4e3eUurL5nbStwUjuuwE7z9mV8bgMlP5EHkZqnUaoItktr96+biLK lHonRycdrNDOUmyNtFPjvUSJUhJWSx9sOIZRWbqsp2qm8I10/2IL7uZ3ThlShCbsahfN 1z52H0PzIlsIhQL5HPIJ8Zn3VG1ox+s0/Lq6yOa0MjAmXNpyBvvqeYUoskyLQYZTizNU GDaEjKRFuuYnyL+Qjr46+gFywJ9ZARji/M1gtbNVhjx2Yw+vaEZzv2YYyTi3+Q3z0tm4 zTfOcpNu82yGUYlkeiZT9kL99GURgsWA80kNgSqkPTkE/vhvjK50eGogaeBnRtZCp09F IBrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=kUEK8TJG3HW4/QEJnT3xYjJ/ktutD7806Zzni08iMh0=; b=QmsgD9Xu0BTXMfEX4oQGBa1TQMc6ls0Urgj284zVC1lHryzOhi9MQ1h2cz+/q0OmGR bgyJyGQtEjEcjdwy1Aan+DPEkJEpApcp8Ti4wblA8QnRhOZlOX/XntZ6poZWcbz8p3Ng zeo1SfrSFGczKOtpxftcYrlqed05D0K5+tfUsJKiUUepaENcyCcjYwwX31qAV+hbAb1d 6JjFtW6EGTrG3OGEKv8D2wlGAxmPfJd5GnpkGqIzG7M1oWv0dGkBfiHQfe/wrxshPdcs NBZ9VnhLYcCnZm0tfz+qXxbt/pQMwaB4eHMhkFCY68GTmRUIKRgcp+UvWO5i6agociII xZKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cloudflare.com header.s=google header.b=QPIcUPlj; 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 m19si2007132otq.40.2020.02.11.06.00.13; Tue, 11 Feb 2020 06:00:25 -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=QPIcUPlj; 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 S1729786AbgBKNys (ORCPT + 99 others); Tue, 11 Feb 2020 08:54:48 -0500 Received: from mail-qk1-f196.google.com ([209.85.222.196]:34323 "EHLO mail-qk1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729072AbgBKNyq (ORCPT ); Tue, 11 Feb 2020 08:54:46 -0500 Received: by mail-qk1-f196.google.com with SMTP id c20so4104010qkm.1 for ; Tue, 11 Feb 2020 05:54:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloudflare.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=kUEK8TJG3HW4/QEJnT3xYjJ/ktutD7806Zzni08iMh0=; b=QPIcUPljLhySpgzdyvXe84XApk9o0l4drWX96OHa66NRIGTCepjhS1dN+xCMvSjy5M q1i5UGJaxPLnvjACynnW5g2BAF0QUsh0vplMCzf2OpO1q7ckggJyTaFNZCrV9/GTmEo2 KZnBd5XO2WEn6KiqDhtCkdoifhNFHADuWBUJc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=kUEK8TJG3HW4/QEJnT3xYjJ/ktutD7806Zzni08iMh0=; b=blbJqxwxkBkoLFVTGdo4Rqq6l5H5baizahZ7BtR372Tr5JVDAQHn+ZKuEf6xCuv+fh TBqb2EAihzad4+9Bcit5k0tmiUsiMighi1lmXoJ9is6iYSuDBiiTUEpxVQSF/Zbrnj0U ec3FB7FqBJJ7wfrfXpafdEchJbZDneYn6jJ1GHrTucpAut9lo60z/mDALBwmFrBz8KfC uAlVv7v5W+6VkAOewRQgVUHyuOnNypxVgGFShT+dAtvUZxjM217RBCkuF25HhAlpn48A vfad14Zpe0V1eD4XAX9QCcfKr8HaiHBqJ30DaQBUb+XJMHB+DOuHlQ4pFJGaJ3PTJSOI 4Olg== X-Gm-Message-State: APjAAAVTTF+5C4VFhBmMqp7zo/bEVRyoQYC/XnPHlm0h66vTazXrUabG l2QwvVKv/48133KLmf6KRrc3MkonhOJKDomaA/hOjQ== X-Received: by 2002:a37:ad4:: with SMTP id 203mr2827671qkk.235.1581429285007; Tue, 11 Feb 2020 05:54:45 -0800 (PST) MIME-Version: 1.0 References: <20191205123302.GA25750@kernel.org> <20200204192657.GB1554679@krava> <20200211134624.GA32066@kernel.org> In-Reply-To: <20200211134624.GA32066@kernel.org> From: Marek Majkowski Date: Tue, 11 Feb 2020 13:54:33 +0000 Message-ID: Subject: Re: perf not picking up symbols for namespaced processes To: Arnaldo Carvalho de Melo Cc: Jiri Olsa , Ivan Babrou , kernel-team , linux-kernel , Peter Zijlstra , Ingo Molnar , Alexander Shishkin , Namhyung Kim , sashal@kernel.org, Kenton Varda Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Feb 11, 2020 at 1:46 PM Arnaldo Carvalho de Melo wrote: > > Em Tue, Feb 11, 2020 at 10:06:35AM +0000, Marek Majkowski escreveu: > > Jirka, > > > > On Tue, Feb 4, 2020 at 7:27 PM Jiri Olsa wrote: > > > > 11913 openat(AT_FDCWD, "/proc/9512/ns/mnt", O_RDONLY) = 197 > > > > 11913 setns(197, CLONE_NEWNS) = 0 > > > > 11913 stat("/home/marek/bin/runsc-debug", 0x7fffffff8480) = -1 ENOENT > > > > (No such file or directory) > > > > 11913 setns(196, CLONE_NEWNS) = 0 > > > > > > hi, > > > could you guys please share more details on what you run exactly, > > > and perhaps that change you mentioned? > > > > I was debugging gvisor (runsc), which does execve(/proc/self/exe), and > > then messes up with its mount namespace. The effect is that the binary > > running doesn't exist in the mount namespace. This confuses perf, > > which fails to load symbols for that process. > > > > To my understanding, by default, perf looks for the binary in the > > process mount namespace. In this case clearly the binary wasn't there. > > Ivan wrote a rough patch [1], which I just confirmed works. The patch > > attempts, after a failure to load binary from pids mount namespace, to > > load binary from the default mount namespace (the one running perf). > > > > [1] https://lkml.org/lkml/2019/12/5/878 > > That is a fallback that works in this specific case, and, with a warning > or some explicitely specified option makes perf work with this specific > usecase, but either a warning ("fallback to root namespace binary > /foo/bar") or the explicit option, please, is that what that patch does? You got it right, custom patch, to do something custom (look up in top mount ns) yet on failure. I'm not sure how to make it more generic. Furthermore, there is one more use case this patch doesn't support: namely a situation when the binary is reachable in some mount namespace, but not under sensible path. This can happen when we launch a command under gvisor. Gvisor-sandbox runs under empty mount namespace, the binary is delivered over 9p from gvisor-gofer process, from potentially arbitrary path. In that scenario we have three mount namespaces: the empty one running process, another one with access to the binary, and host one. I have two ideas how to solve the symbol discovery here: (a) give perf an explicit link (potentially including mount namespace pid) to the binary (b) supply perf with /tmp/perf-.map file with symbols, extracted via some external helper. I tried (b) but failed, I'm not sure how to produce perf-pid.map from a proper binary, using basic tools like readelf.