From patchwork Fri Aug 23 12:07:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kleber Sacilotto de Souza X-Patchwork-Id: 1152136 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46FKsK4zlmz9sNk; Fri, 23 Aug 2019 22:07:32 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1i18Lo-0006Cz-KT; Fri, 23 Aug 2019 12:07:28 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.86_2) (envelope-from ) id 1i18Lm-0006CF-TW for kernel-team@lists.ubuntu.com; Fri, 23 Aug 2019 12:07:26 +0000 Received: from mail-wr1-f71.google.com ([209.85.221.71]) by youngberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1i18Lm-00076h-Hb for kernel-team@lists.ubuntu.com; Fri, 23 Aug 2019 12:07:26 +0000 Received: by mail-wr1-f71.google.com with SMTP id x12so4739468wrw.0 for ; Fri, 23 Aug 2019 05:07:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=N8SyORatKJJxIcVfDVGk+Yzx8XSTK6ymyeS6CVtsXCw=; b=tjgonPWCqqyfxCjlX7+qbDeZPg2tKudyh0+dbAhGZ2CGdaXbuxs6hs9mjMAKlZ0ZJA 07MSVWM82z/nhwsRQKPJ9uUZi2d3qbnhU5nQiw9BvvCcmZjgUCl3Knatct+RYkMWcrbM CYfQiELk5nHaJPmWdghG2+OWJMvEnUni23+VlaGMRcPy89j+qVsozf4k0UoDOq+0rbhg Qbat1UG9mLf3r5GR8eWPHzQI0qb40XvW5S8KTp/tADfiD/o+YJzAUattWAlBCWuj8X5K W+3RgQAjHbxAVOGM2PFVRdOElkTXNNnWqFVhRoFyXnwNq1ojj3Wu6zfMO/wGdsaCkACB +tMg== X-Gm-Message-State: APjAAAVawsaYOoOdBrUWhDGd843m0doXm0Pv/zM/D/Us58V4316UYHzZ nbeveYkJA/hzNttVIAX4tkoSnAj8CQ8svjnN87aj8LqR9v6EPYNjj5eE6KkXPR10yx17x0z7rj6 DmBwBzZIWemFJ+oBIRHvHCGK4b7WobhMx8DTOnvbLkA== X-Received: by 2002:a1c:a383:: with SMTP id m125mr4949820wme.57.1566562046000; Fri, 23 Aug 2019 05:07:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqxDwXQHcTZOSqt3gMdLIB9J2yNUXaOQppNSEdxFgPujy5Sv6oOtIknmyOYoZn18sQP/48Hv6w== X-Received: by 2002:a1c:a383:: with SMTP id m125mr4949782wme.57.1566562045727; Fri, 23 Aug 2019 05:07:25 -0700 (PDT) Received: from localhost ([37.61.220.43]) by smtp.gmail.com with ESMTPSA id a23sm3670819wma.24.2019.08.23.05.07.24 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 23 Aug 2019 05:07:25 -0700 (PDT) From: Kleber Sacilotto de Souza To: kernel-team@lists.ubuntu.com Subject: [SRU][Disco][PATCH 1/3] perf record: Fix s390 missing module symbol and warning for non-root users Date: Fri, 23 Aug 2019 14:07:18 +0200 Message-Id: <20190823120720.4623-4-kleber.souza@canonical.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190823120720.4623-1-kleber.souza@canonical.com> References: <20190823120720.4623-1-kleber.souza@canonical.com> X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Thomas Richter BugLink: https://bugs.launchpad.net/bugs/1828166 Command 'perf record' and 'perf report' on a system without kernel debuginfo packages uses /proc/kallsyms and /proc/modules to find addresses for kernel and module symbols. On x86 this works for root and non-root users. On s390, when invoked as non-root user, many of the following warnings are shown and module symbols are missing: proc/{kallsyms,modules} inconsistency while looking for "[sha1_s390]" module! Command 'perf record' creates a list of module start addresses by parsing the output of /proc/modules and creates a PERF_RECORD_MMAP record for the kernel and each module. The following function call sequence is executed: machine__create_kernel_maps machine__create_module modules__parse machine__create_module --> for each line in /proc/modules arch__fix_module_text_start Function arch__fix_module_text_start() is s390 specific. It opens file /sys/module//sections/.text to extract the module's .text section start address. On s390 the module loader prepends a header before the first section, whereas on x86 the module's text section address is identical the the module's load address. However module section files are root readable only. For non-root the read operation fails and machine__create_module() returns an error. Command perf record does not generate any PERF_RECORD_MMAP record for loaded modules. Later command perf report complains about missing module maps. To fix this function arch__fix_module_text_start() always returns success. For root users there is no change, for non-root users the module's load address is used as module's text start address (the prepended header then counts as part of the text section). This enable non-root users to use module symbols and avoid the warning when perf report is executed. Output before: [tmricht@m83lp54 perf]$ ./perf report -D | fgrep MMAP 0 0x168 [0x50]: PERF_RECORD_MMAP ... x [kernel.kallsyms]_text Output after: [tmricht@m83lp54 perf]$ ./perf report -D | fgrep MMAP 0 0x168 [0x50]: PERF_RECORD_MMAP ... x [kernel.kallsyms]_text 0 0x1b8 [0x98]: PERF_RECORD_MMAP ... x /lib/modules/.../autofs4.ko.xz 0 0x250 [0xa8]: PERF_RECORD_MMAP ... x /lib/modules/.../sha_common.ko.xz 0 0x2f8 [0x98]: PERF_RECORD_MMAP ... x /lib/modules/.../des_generic.ko.xz Signed-off-by: Thomas Richter Reviewed-by: Hendrik Brueckner Cc: Heiko Carstens Link: http://lkml.kernel.org/r/20190522144601.50763-4-tmricht@linux.ibm.com Signed-off-by: Arnaldo Carvalho de Melo (cherry picked from commit 6738028dd57df064b969d8392c943ef3b3ae705d) Signed-off-by: Kleber Sacilotto de Souza --- tools/perf/arch/s390/util/machine.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tools/perf/arch/s390/util/machine.c b/tools/perf/arch/s390/util/machine.c index 0b2054007314..a19690a17291 100644 --- a/tools/perf/arch/s390/util/machine.c +++ b/tools/perf/arch/s390/util/machine.c @@ -5,16 +5,19 @@ #include "util.h" #include "machine.h" #include "api/fs/fs.h" +#include "debug.h" int arch__fix_module_text_start(u64 *start, const char *name) { + u64 m_start = *start; char path[PATH_MAX]; snprintf(path, PATH_MAX, "module/%.*s/sections/.text", (int)strlen(name) - 2, name + 1); - - if (sysfs__read_ull(path, (unsigned long long *)start) < 0) - return -1; + if (sysfs__read_ull(path, (unsigned long long *)start) < 0) { + pr_debug2("Using module %s start:%#lx\n", path, m_start); + *start = m_start; + } return 0; }