Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2212902pxb; Tue, 23 Feb 2021 01:05:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJzU11HHPHX1MAkv3I1VSynB4xXJgJdNxFxPguMozvv9/HAIamf2S/qz3UK0YhkVzpKq2DOQ X-Received: by 2002:a17:907:9da:: with SMTP id bx26mr21959474ejc.206.1614071102971; Tue, 23 Feb 2021 01:05:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614071102; cv=none; d=google.com; s=arc-20160816; b=ijI6A58Z1KZkkWOs5Mhx2iVUsBSRwOHTtiZzo7HnHnh59S7LgJ0DrX03nE/Va00k5p /QUZXkA7NjFs0cnAAIAgM0bcfxw9K4F2vP8VXpxVcL1LADbfkT653kwtTj2FcDoHcM27 1+2QQA8Poju4LgTcZpuSGDwvrmSWG2hlAUUm9EuXIZKjgZ+9YvaIC+XIpCE+5Nnljiuj Xe104rQl/QOd4VVr2qsVpm315g7jUDQ1dDPel1vDsz9w31yj3kSUhoeUcg80Gq+0GhRk pZB1uSQpDQc7pJpnuMYzphffqQVXaVQ+TdcKJG3SKVMnlFw9rhNTl6cXbSKuB2o31Gcx IdmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=6HXt0S4otk/0tFkf0EsfhEFDLsTAq/84ko3S7B1O8bI=; b=mpieysWWV+yuuDrhtfb2zzDqn4LKRMQznCCqGQ4EoRWl2HVsJ5RL5QEoPzbFsLWgh+ 9WAwyHfmuO8XQu9oR4LJh0QzI+SGybuxQF1vGGFEbRLi2IQB32sLqvUKtjJDAZFBtRRB w0XKXU49E4yez4Kx+d/E/20R818TJn+ObuLwDUyqPL3U2gMOOLBjINWxA87GauqzbRbW bCo0NCnZ/iDYU9PC2yQUhrI9eSlvZJRgTpLtsGDd+dMxqfCBlH1S3ajwZMBevdbDL4Lu S89KvHRx5Uf90uceOT6tm/crfWHHcSyyrO0SRzWIBB9ah01GMzfxPMjEGaUNHSw9dDMM kSzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=CojkXMw+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id q3si12419975edv.223.2021.02.23.01.04.34; Tue, 23 Feb 2021 01:05:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=CojkXMw+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S231699AbhBWHip (ORCPT + 99 others); Tue, 23 Feb 2021 02:38:45 -0500 Received: from mail.kernel.org ([198.145.29.99]:37052 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230104AbhBWHii (ORCPT ); Tue, 23 Feb 2021 02:38:38 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4798264E3F; Tue, 23 Feb 2021 07:37:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1614065877; bh=+afHJL7e/wCiWy1fR3SnBqcXl4qAUrsL6SV/cscUuS4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CojkXMw+D4xi8Ti41V/VFR9Q1WVoX0hp7R75fovuDbPZcg+qj6u7m6YzpVYGC71HE jR5UecxyC6v/4qy07UXCqwmEw+GYkh6+kPzHRvw2URO6hT4EsIwcaFwPGr670/80nY kSssKQYG2EWbxJ6tnRTdRst/4u92kpzBmyovp5eTfaaPqipAJ5C4F8JwEr2I55KPIa BGoAxQIipcdnWHrZpuP+EtmYaolNQK1B3KdGGrkPx9e/BgBaTp8RW4/di+dSF8csBd 4ZNHASZsdVu5K6siL04IqjJbpPet+nl1xTqZ6mXd2rHBT6EoDUk3Xg/eLROT2uztVr VnjH2YWHRoyyQ== From: Masami Hiramatsu To: Arnaldo Carvalho de Melo Cc: Masami Hiramatsu , Josh Poimboeuf , Evgenii Shatokhin , Kristen Carlson Accardi , live-patching@vger.kernel.org, Peter Zijlstra , Ingo Molnar , linux-kernel@vger.kernel.org, Konstantin Khorenko Subject: [PATCH] perf-probe: dso: Add symbols in .text.* subsections to text symbol map in kenrel modules Date: Tue, 23 Feb 2021 16:37:52 +0900 Message-Id: <161406587251.969784.5469149622544499077.stgit@devnote2> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210223000508.cab3cddaa3a3790525f49247@kernel.org> References: <20210223000508.cab3cddaa3a3790525f49247@kernel.org> User-Agent: StGit/0.19 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The kernel modules have .text.* subsections such as .text.unlikely. Since dso__process_kernel_symbol() only identify the symbols in the ".text" section as the text symbols and inserts it in the default dso in the map, the symbols in such subsections can not be found by map__find_symbol(). This adds the symbols in those subsections to the default dso in the map so that map__find_symbol() can find them. This solves the perf-probe issue on probing online module. Without this fix, probing on a symbol in .text.unlikely fails. ---- # perf probe -m nf_conntrack nf_l4proto_log_invalid Probe point 'nf_l4proto_log_invalid' not found. Error: Failed to add events. ---- With this fix, it works because map__find_symbol() can find the symbol correctly. ---- # perf probe -m nf_conntrack nf_l4proto_log_invalid Added new event: probe:nf_l4proto_log_invalid (on nf_l4proto_log_invalid in nf_conntrack) You can now use it in all perf tools, such as: perf record -e probe:nf_l4proto_log_invalid -aR sleep 1 ---- Reported-by: Evgenii Shatokhin Signed-off-by: Masami Hiramatsu --- tools/perf/util/symbol-elf.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c index 6dff843fd883..0c1113236913 100644 --- a/tools/perf/util/symbol-elf.c +++ b/tools/perf/util/symbol-elf.c @@ -985,7 +985,9 @@ static int dso__process_kernel_symbol(struct dso *dso, struct map *map, if (strcmp(section_name, (curr_dso->short_name + dso->short_name_len)) == 0) return 0; - if (strcmp(section_name, ".text") == 0) { + /* .text and .text.* are included in the text dso */ + if (strncmp(section_name, ".text", 5) == 0 && + (section_name[5] == '\0' || section_name[5] == '.')) { /* * The initial kernel mapping is based on * kallsyms and identity maps. Overwrite it to