Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp2622683imm; Sun, 14 Oct 2018 00:43:18 -0700 (PDT) X-Google-Smtp-Source: ACcGV63aYynsAetz30YXHN8PfDbwx4QauG33bO0As3jjiOS5CYPBGQYz9n0osv/eYQ0DHbU9LzYw X-Received: by 2002:a62:41d6:: with SMTP id g83-v6mr12770120pfd.44.1539502998374; Sun, 14 Oct 2018 00:43:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539502998; cv=none; d=google.com; s=arc-20160816; b=wYirNBFAK54l+RaWw3QdDise3lzSZiZ2GyvrJWmnKFExqnNg6gYjx6KMV5iqnFBkE3 a2zXn0f6MUTwoJNKxmqviGvUfouEx1VKwDjcLsxEM8vSCjmHdxM2Ja6d51JabmBZK+SA NSPAoes3WG67W3mMm07tkWZ8QzSJVxtw6Ac1hY/1PgKXv2v/CqGEUQNh+cc+pAiTshHN 5WZbCPMUgLX8+IaDmbQM1cF3iAGw0qd5/Bz8qssfvfzBIGnlRMHC1lkDRVpwo6To2AJw zCL2/FO6TADy1j3yBfLF+wNMO9QUVh7RbHF7QVtMW8l+l1PiTi6VRryDxB1JDmAumaV2 MFIA== 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:mime-version :from:subject:cc:to:message-id:date; bh=CpezpLOWtiwJw8rpjhDnnTiL4yCnv/hjAIXEAJhYiBQ=; b=IqaGYKf1vX9HszAxzwUVvviSWzAItLhbcE2/GQ/fwRG8nNnJyOFipOASoAj7sftXR9 Xn2iwZw6rkwlb8qb8Bx5fRuIZ6AEc3PhSXGw3NT3Ca15toaZ9FLrXZAFSFHAQsOf5M4y N63rJMdzNcZ5LnYbqJOqnzO7PiTpoLt5IXTvX+Q7VImpLPUZNoEak4AWlHfH0gukOWmb WRxKQD+x2z5hnOHzW6BSgJT9B/LN8JCi4MwmGzXA7oc1idrQ8dewyhxeYrEp545CZetx XutUrIWUia72TZJdA8NvY0VycTCqa4e344koKQ5I51cZ/0paklo2DCEpfsA+eB5SlVhY iEDw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y8-v6si6414981plt.271.2018.10.14.00.43.03; Sun, 14 Oct 2018 00:43:18 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726363AbeJNPWt (ORCPT + 99 others); Sun, 14 Oct 2018 11:22:49 -0400 Received: from shards.monkeyblade.net ([23.128.96.9]:41396 "EHLO shards.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726115AbeJNPWt (ORCPT ); Sun, 14 Oct 2018 11:22:49 -0400 Received: from localhost (c-67-183-62-245.hsd1.wa.comcast.net [67.183.62.245]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) (Authenticated sender: davem-davemloft) by shards.monkeyblade.net (Postfix) with ESMTPSA id 1FC8F13D36D29; Sun, 14 Oct 2018 00:42:42 -0700 (PDT) Date: Sun, 14 Oct 2018 00:42:38 -0700 (PDT) Message-Id: <20181014.004238.292485794143606801.davem@davemloft.net> To: acme@redhat.com CC: linux-kernel@vger.kernel.org Subject: perf's handling of unfindable user symbols... From: David Miller X-Mailer: Mew version 6.7 on Emacs 26 / Mule 6.0 (HANACHIRUSATO) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.5.12 (shards.monkeyblade.net [149.20.54.216]); Sun, 14 Oct 2018 00:42:42 -0700 (PDT) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Perf has this hack where it uses the kernel symbol map as a backup when a symbol can't be found in the user's symbol table(s). This causes problems because the tests driving this code path use machine__kernel_ip(), and that is completely meaningless on Sparc. On sparc64 the kernel and user live in physically separate virtual address spaces, rather than a shared one. And the kernel lives at a virtual address that overlaps common userspace addresses. So this test passes almost all the time when a user symbol lookup fails. The consequence of this is that, if the unfound user virtual address in the sample doesn't match up to a kernel symbol either, we trigger things like this code in builtin-top.c: if (al.sym == NULL && al.map != NULL) { const char *msg = "Kernel samples will not be resolved.\n"; /* * As we do lazy loading of symtabs we only will know if the * specified vmlinux file is invalid when we actually have a * hit in kernel space and then try to load it. So if we get * here and there are _no_ symbols in the DSO backing the * kernel map, bail out. * * We may never get here, for instance, if we use -K/ * --hide-kernel-symbols, even if the user specifies an * invalid --vmlinux ;-) */ if (!machine->kptr_restrict_warned && !top->vmlinux_warned && __map__is_kernel(al.map) && map__has_symbols(al.map)) { if (symbol_conf.vmlinux_name) { char serr[256]; dso__strerror_load(al.map->dso, serr, sizeof(serr)); ui__warning("The %s file can't be used: %s\n%s", symbol_conf.vmlinux_name, serr, msg); } else { ui__warning("A vmlinux file was not found.\n%s", msg); } if (use_browser <= 0) sleep(5); top->vmlinux_warned = true; } } When I fire up a compilation on sparc, this triggers immediately. I'm trying to figure out what the "backup to kernel map" code is accomplishing. I see some language in the current code and in the changes that have happened in this area talking about vdso. Does that really happen? The vdso is mapped into userspace virtual addresses, not kernel ones. More history. This didn't cause problems on sparc some time ago, because the kernel IP check used to be "ip < 0" :-) Sparc kernel addresses are not negative. But now with machine__kernel_ip(), which works using the symbol table determined kernel address range, it does trigger. What it all boils down to is that on architectures like sparc, machine__kernel_ip() should always return false in this scenerio, and therefore this kind of logic: if (cpumode == PERF_RECORD_MISC_USER && machine && mg != &machine->kmaps && machine__kernel_ip(machine, al->addr)) { is basically invalid. PERF_RECORD_MISC_USER implies no kernel address can possibly match for the sample/event in question (no matter how hard you try!) :-) At the very least there should be an arch way to disable this logic, or even formalize in some way the situation. Have some kind of "user_kernel_shared_address_space" boolean, and then machine__kernel_ip() can take a cpumode parameter and it can thus say: if (cpumode == PERF_RECORD_MISC_USER && !user_kernel_shared_address_space) return false; Comments?