Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp4308892ybi; Mon, 27 May 2019 15:43:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqwfwVhI3Cv6gCWLjT72V8m6JSB7QP/pvC8jiadujpa7nhCWVUb5hh490TYYjuIM/Lv/EewT X-Received: by 2002:a17:902:3fa5:: with SMTP id a34mr21696886pld.317.1558996987707; Mon, 27 May 2019 15:43:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558996987; cv=none; d=google.com; s=arc-20160816; b=ubizJwqOlgG9vIVPM9WhlIqIZp74Z6diTWObJKdp4Qkt/iOjl7IURB9eOz3zkpbHR3 CnhshXATRdpG4rL5SwNrDfDfvywjorfqgc2aSZVSNsf2y3P1mnfIDz+/EfSBV2t+RH10 Scwkpa/eJe803lff2+bXhK3Nd2Oqj2xIkn0X/ZqtMtu4jRbFzWBxeo/Mm9MzWkQXV5m+ oO4FBkTJNeLXHeBeZrb2vfZBOPQbqXpM4mbRoFXUJL3bZ4I/kF4/+tndeL2bUbuar4CC E24BLOB78MUxB2QlvKFawWKsgabvqTeJrg7u8SIEh7sUMhoBiHLJc5IWmRZaKevCC+HL 5Yjg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=+Q6eAIxfniIBcSiARiZ/ssiTpZ6SKukHlNAvEY+xN9Y=; b=IVxq8qagXrp5nDuYDk3hYVvQkXmIOGyz/sGKuK9WkCpj0aChUxUDJwtm+QnWYfSzx2 upLMnqwy6mT/5pczq12wA+YDLplRAu5pq7LUs26TIBeuKWeKVbje3r1CyycY5v6MxoJp PUNX/ZYrDX4Yz9UJnA/Hhyfh5yDMz5iII/xySvc5+gWJefUD4GbJP680a+0h6BmBp2qO G16p82wNYyJT0op2Qi5YYD/V3jMTYBr3yl6M/C5ppEAWNLgyDf7TW8QMmxJTXr461Roz xTxMVVEn0mWBhf6oMkU4Wci07P/LhL0XbODgPAdi5KBJlTlXa509Ny+Ifo4RwZmopvwl il3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="U/evc0Ke"; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b38si688856pgb.250.2019.05.27.15.42.52; Mon, 27 May 2019 15:43:07 -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; dkim=pass header.i=@kernel.org header.s=default header.b="U/evc0Ke"; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728113AbfE0WlL (ORCPT + 99 others); Mon, 27 May 2019 18:41:11 -0400 Received: from mail.kernel.org ([198.145.29.99]:47082 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728086AbfE0WlK (ORCPT ); Mon, 27 May 2019 18:41:10 -0400 Received: from quaco.ghostprotocols.net (179-240-171-7.3g.claro.net.br [179.240.171.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7461E2081C; Mon, 27 May 2019 22:41:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1558996869; bh=46Q44svXPUpVD4scPAxbsdIVi99vSJJDbwx5cLTkPsc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U/evc0KeB6+EN9ZUt3MsUJmnOjYuN1puOKqQ0yGiYMisECBfOhQ55m0PT+9kmKJnF dk6YDAeZLeGbnIO4Q8VkaoFMsxhjQUr7Z6KNky/JlGg3y96ugUJWK73GQsIwPFhYAE ES1sKkG5IhTo26clnW+p/dIzD8aDVYWx8B9aLkt8= From: Arnaldo Carvalho de Melo To: Ingo Molnar , Thomas Gleixner Cc: Jiri Olsa , Namhyung Kim , Clark Williams , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Thomas Richter , Hendrik Brueckner , Heiko Carstens , Arnaldo Carvalho de Melo Subject: [PATCH 43/44] perf record: Fix s390 missing module symbol and warning for non-root users Date: Mon, 27 May 2019 19:37:29 -0300 Message-Id: <20190527223730.11474-44-acme@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190527223730.11474-1-acme@kernel.org> References: <20190527223730.11474-1-acme@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Thomas Richter 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 --- 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; } -- 2.20.1