Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1625589ybl; Thu, 5 Dec 2019 04:33:52 -0800 (PST) X-Google-Smtp-Source: APXvYqxfBaZjPlpyYOZe+A8ozMEHYjGtYp0a0nskWjfNWyafDc+VWKNRMpN5EKj1PoCAiSvYdRXX X-Received: by 2002:a05:6830:1248:: with SMTP id s8mr6288986otp.202.1575549232515; Thu, 05 Dec 2019 04:33:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575549232; cv=none; d=google.com; s=arc-20160816; b=gGsTkSlO1I7MBeIisaGaE1Ns8IdRIrcGjbFA9Hg3Ubx2ty5nnNlb1Y2KqlDcBmr4me pIMs4l2+L1woG+nStuFqEzHPQBTyKK+rB0u14Wfk/AD0Ybd3o8hPCULqaD1EkOIp7S3E GK6nnsmikxEgIJfAPQMfy55wNzK0Txn9uVjSRigotiLxwFJxLOWDroEPTmiYLzm+GpSC RDfky8VDLMVGZalnKzJN/6/7AJ61Vuvu/cEKNW6C48xFkIIxpf7nWccWJJaC7B52lISP 4NjyDzdBcnWAbLpN4KYTX3jvxroKLunHgXc6A/ASPdsaoE8YVouOhidLiqSGqZ0pdVhh 3GPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:date:from:dkim-signature; bh=WHqFzyKAvPkwY+9Y4I60hULDel9sSa/LgEW57iRWbpc=; b=pZ2WpBnGSdOvQ6bXDbycWz3a5JXlliNgaWEOM4m49I/6/J4gLRQBeMrrvyA/Kq215k PPI+hRtJ2tMuyNUxyiWd+CYyLSTDhsZCVsJNIpBrBPm6WP84rxm+RwJVHLxYf26EXlhN NF1yV5L4FFNp8JPR9ysiWmmE+iWYXOdmf+MajZ3oDrWd2ipQ+1eqZXJ5Kk0cBG2YCabv pQ0DmcA/RPJ3LBuBJvqyF+aPdg7zDe1enO7T/0vuRkBJpF+f8CbkhwhoyjgITyJCsEQt jEF7NdJcmoFGjUqZO1Cg87137xwIXplt33myKUHDMkm8m5zcQG5CqJHHR8eQWfOu0xI1 RKJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="gg/9+xhL"; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j18si4112957otq.275.2019.12.05.04.33.39; Thu, 05 Dec 2019 04:33:52 -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=@gmail.com header.s=20161025 header.b="gg/9+xhL"; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729236AbfLEMdH (ORCPT + 99 others); Thu, 5 Dec 2019 07:33:07 -0500 Received: from mail-vs1-f53.google.com ([209.85.217.53]:34299 "EHLO mail-vs1-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729048AbfLEMdH (ORCPT ); Thu, 5 Dec 2019 07:33:07 -0500 Received: by mail-vs1-f53.google.com with SMTP id g15so2224073vsf.1 for ; Thu, 05 Dec 2019 04:33:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:date:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to; bh=WHqFzyKAvPkwY+9Y4I60hULDel9sSa/LgEW57iRWbpc=; b=gg/9+xhL0MpW2LXnuzsfg6y53YMto3XzzgVWw1lVOhrnhIjfonFgz+VpBIu/5KtKM4 /qZWHZAwfcxA+RXxTXQjKpuNeLwwQ9ae5SgNGkTjQjaGgLMVXan6J15NWUqmYgTryuzA RG+mzmkGQ43o1wNqC0gHr90T1idocUc1ADH465h/F1fuFRMuhTyULfkl6hmbyvs2uK+1 3Zcsc+1nt3kr2VpAXZW1lYYnbqn2uj4y1Y72i0SyQxE8B4IpyWuxMZHoI3jcsgx7jn1G dbqSKpmp1PhtjjeJU7QkKPpC/rJW+n6K9mokbOK7p/evkCOac75txYT88i8hbOT9CL3M Z1/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:date:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=WHqFzyKAvPkwY+9Y4I60hULDel9sSa/LgEW57iRWbpc=; b=ufNOIRxs9wcUeN67JG+vDow6BfGul5Q5tmwGqusnxMP7HFHhQ6BGWEi8+G3jtHgw73 GLuSTJUWvJemn/6Ud8dSqpOWqcwy/AfpGRu3esDrOZf1nYwjFTqNNvp0E3c7ZplCWoDq pG2tHzX/N5rojVS7pg17Tr8wNJicMMBI7AKdodmQis7l9ZQlLiuLjrNFqIEj2D5TaxGk +MtcOK6CaUnqRKXDnvy05EFhiFilp/cSfd5fY3ZJaRZnQwDGJjnQFa+6s4HbhD+Gaw2f stJgFDvJ23O725sh/9myEs/dI7X0kTO2YRjSNiDSihHO1lQyZ6ZVFXWiyraSNsSFTJO9 0XAg== X-Gm-Message-State: APjAAAUz9y8T/1Bh056mRGeScN4weaxD7r0PYLF97wtm8KTjitZlsl76 UNvvvaLy07ANhnvQHYBHuAQ= X-Received: by 2002:a05:6102:243b:: with SMTP id l27mr5339810vsi.230.1575549185367; Thu, 05 Dec 2019 04:33:05 -0800 (PST) Received: from quaco.ghostprotocols.net ([179.97.35.50]) by smtp.gmail.com with ESMTPSA id a6sm3326165vsr.9.2019.12.05.04.33.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Dec 2019 04:33:04 -0800 (PST) From: Arnaldo Carvalho de Melo X-Google-Original-From: Arnaldo Carvalho de Melo Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id 28367405E2; Thu, 5 Dec 2019 09:33:02 -0300 (-03) Date: Thu, 5 Dec 2019 09:33:02 -0300 To: Ivan Babrou Cc: linux-kernel , kernel-team , Jiri Olsa , Peter Zijlstra , Ingo Molnar , Alexander Shishkin , Namhyung Kim , sashal@kernel.org, Kenton Varda Subject: Re: perf not picking up symbols for namespaced processes Message-ID: <20191205123302.GA25750@kernel.org> References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Url: http://acmel.wordpress.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Wed, Dec 04, 2019 at 07:46:10PM -0800, Ivan Babrou escreveu: > 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)─┬─edgeworker/sbox(255716)─┬─edgeworker/zygt(255718) > │ ├─{edgeworker/sbox}(255719) > │ ├─{edgeworker/sbox}(255720) > │ ├─{edgeworker/sbox}(255721) > ├─edgeworker/stry(5803) > ├─edgeworker/stry(63990) > ├─edgeworker/stry(106218) > ├─edgeworker/stry(191905) > ├─edgeworker/stry(255695) > ├─edgeworker/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) = 17 > open("/proc/self/ns/mnt", O_RDONLY) = 5 > open("/proc/255719/ns/mnt", O_RDONLY) = 6 > setns(6, CLONE_NEWNS) = 0 > stat("/usr/local/bin/edgeworker", 0x7ffedb9b3ca0) = -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: That should work for your use case, as you're sure that looking up by pathname only will find, outside the namespace, the binary you want. Even with pathname based looukups being fragile, it works for your usecase, so please consider providing a patch for such fallback, together with a pr_debug() or even pr_warning() if this don't get too noisy, to warn the user. - Arnaldo > * https://elixir.free-electrons.com/linux/v5.4.1/source/tools/perf/util/dso.c#L520 -- - Arnaldo