Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp2664397ybb; Sun, 5 Apr 2020 13:16:48 -0700 (PDT) X-Google-Smtp-Source: APiQypKg4sIxsjoMBHrX4mX2HyEbMnm4nAkGpnxj1QJae+YntZ/+qaS4W8t5Muyww9JqrHYPPHbZ X-Received: by 2002:a05:6830:1495:: with SMTP id s21mr15741864otq.35.1586117808527; Sun, 05 Apr 2020 13:16:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586117808; cv=none; d=google.com; s=arc-20160816; b=xcDllSS8iKjZRxJW3Wahfs/gPv6lEMzvuzC62GhXbia0wIPQo2FU6mkG/PqFnu5Vil a2Spx2R0o2aMtQgeLFKz0gZ9QL0tRCsm2xkIu2UCvMdOLIfCDNtFjQ3LiEIJFUMZ2zLz YrFzc090KQ3yR1arvWgvkE7+vsZvsJmsPjkUDa2RyN5E6a7jy56vCPoKV8/oO85HljSo 8AERl6N5QyqJhPKLnYDSe20zkhFHKeMin8LsMHNrdHHYdD25CBsYeyIMxKtJ0RQpXEtT qzbxtVSk/zwBFFQDctLP8H4Y1NgqAWzDHuI3zd50sFKQntYu/N5eErZfbrm6R83HphA2 UbVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:organization:references:in-reply-to :message-id:date:subject:cc:to:from:ironport-sdr:ironport-sdr; bh=eYloKwIQdR99TI8o1YsgbC0jVO/sZ73bewAbYWwqr8o=; b=wOIVlQS5S8GbwLslW//HGXgFxslIx3yAwPotvzK1JN4bgfjIz+J2I3QmFqqY2brrtX WBKidORTiYxPq6HGIDZ063O07rcyV6w8c3mOVrBEuxDnj10WoJYuUbT/1yZ3VLuxk6wc HTpLzcef7oWNCB2K746k5Qjm7x5er0+uOgC/vCd0X7ilGhbK1b2hDP0LafIUJadQ7Iaj AAw4rHYJ7w5q4kZ+0czs58b2Q+8o9SQOLn4lHiWUpAGsz5a/p1atC7ug2Q3QPGT0vCqy YMXC6VYEjpaf7U3PaL18Vp/gDbdiSe+COeoQbjHzHVEibxEzLUB4uCOIh1hS/uRUv+Ux 2Svg== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l5si6358673oic.3.2020.04.05.13.16.36; Sun, 05 Apr 2020 13:16:48 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727975AbgDEUO4 (ORCPT + 99 others); Sun, 5 Apr 2020 16:14:56 -0400 Received: from mga01.intel.com ([192.55.52.88]:62225 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727612AbgDEUOz (ORCPT ); Sun, 5 Apr 2020 16:14:55 -0400 IronPort-SDR: 3PO45XIylC3ldUeinb2V/eWfAhXzuSIEML5Q4VNcpg+OXD4HinXTp0q0RIhCixmKBpkBUmVI6K WiSNZHBAyWXA== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Apr 2020 13:14:53 -0700 IronPort-SDR: AFPLoI4TOUVTt4nxqDOwggKdovMmxOQgTn+UK+Kz7QLf4nM7Sd+LyXErbWcQdG+TyMhXBAji/c VTXHn7ApNeVg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,348,1580803200"; d="scan'208";a="329688430" Received: from ahunter-desktop.fi.intel.com ([10.237.72.87]) by orsmga001.jf.intel.com with ESMTP; 05 Apr 2020 13:14:50 -0700 From: Adrian Hunter To: Peter Zijlstra Cc: Ingo Molnar , Masami Hiramatsu , Steven Rostedt , Borislav Petkov , "H . Peter Anvin" , x86@kernel.org, Mark Rutland , Alexander Shishkin , Mathieu Poirier , Leo Yan , Arnaldo Carvalho de Melo , Jiri Olsa , linux-kernel@vger.kernel.org Subject: [PATCH V6 09/15] perf kcore_copy: Fix module map when there are no modules loaded Date: Sun, 5 Apr 2020 23:13:21 +0300 Message-Id: <20200405201327.7332-10-adrian.hunter@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200405201327.7332-1-adrian.hunter@intel.com> References: <20200405201327.7332-1-adrian.hunter@intel.com> Organization: Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In the absence of any modules, no "modules" map is created, but there are other executable pages to map, due to eBPF JIT, kprobe or ftrace. Map them by recognizing that the first "module" symbol is not necessarily from a module, and adjust the map accordingly. Signed-off-by: Adrian Hunter --- tools/perf/util/symbol-elf.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c index be5b493f8284..5e43054bffea 100644 --- a/tools/perf/util/symbol-elf.c +++ b/tools/perf/util/symbol-elf.c @@ -1458,6 +1458,7 @@ struct kcore_copy_info { u64 first_symbol; u64 last_symbol; u64 first_module; + u64 first_module_symbol; u64 last_module_symbol; size_t phnum; struct list_head phdrs; @@ -1534,6 +1535,8 @@ static int kcore_copy__process_kallsyms(void *arg, const char *name, char type, return 0; if (strchr(name, '[')) { + if (!kci->first_module_symbol || start < kci->first_module_symbol) + kci->first_module_symbol = start; if (start > kci->last_module_symbol) kci->last_module_symbol = start; return 0; @@ -1731,6 +1734,10 @@ static int kcore_copy__calc_maps(struct kcore_copy_info *kci, const char *dir, kci->etext += page_size; } + if (kci->first_module_symbol && + (!kci->first_module || kci->first_module_symbol < kci->first_module)) + kci->first_module = kci->first_module_symbol; + kci->first_module = round_down(kci->first_module, page_size); if (kci->last_module_symbol) { -- 2.17.1