Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2687741pxb; Tue, 23 Feb 2021 13:03:52 -0800 (PST) X-Google-Smtp-Source: ABdhPJyLcNLtN3C79eJpQXZ2DP9qJVYIwZ1BZRDKPLa93Xf/1Qp+oqzV3acUXxFKtBx/icvIzmmj X-Received: by 2002:a05:6402:b1c:: with SMTP id bm28mr30455637edb.354.1614114232372; Tue, 23 Feb 2021 13:03:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614114232; cv=none; d=google.com; s=arc-20160816; b=EegqpBK9O5KQFeZiWwvjwU3mFg1FD/orQBnBRaLRe6x37v+OhtnIyu7P/urb2DLLY2 KEn9u2rhVO7PzZfP5c1uAo4xbKczBlLtRxz382vHXV7N4V6hE/KZbUELPCSreeiar3U2 XoC5Kv43ncmPNg+U2uXTIYVvi0qOLSWFcfXAWXdgN5cJyUQr9d7xMNBLvWYRdxOwL1tI AmJ+exQxkIaALa6jlsmiY21B+V7GQj6j6l1g3k4e5dKMf3+56HL5k+2aXYU8SDLHzy4z LlSap39+36trZvX5Jh2CIho3jkQrzI6ujKgHr238x14JJdrmjNImgGm6lPssrNidH9ba kwRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=WYsocuKb9w5XM0rBZG8Rm3syPGoNrHCF+DXrW+RODg4=; b=NGewb3ZhERfGUzEcQlYt1zTEfCgxlF/zMkR+xGp1UK9ZmniZ1WZri+0DpUMdYKT8la yF/qplDNUiEK9fRedE/65bY9r+zgNwxje60cuiw1mGU0LRkLRgisv2hV0U1Z2t9Efkj0 fllLwsepRxUwzCZxjEH+ge+MH5iVEahr+wRmCnQlQOejm8eXy9mtrJ/xOc5kwLZzqeAh s0lp0KdL0fIz/tw3yQAiZFK/P+q45I3qPdL4AxEWZA6rKaUNbnjds7tMNv4aBzkUDU7M uobeiXMtWuxtXnA+o6Hq3wmm116ntdOcvnppQ+RKEqVpuXbXROb7fs37rm2D0NPiCj/F w9yA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=FVBxku+Z; 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 v27si9316656edx.73.2021.02.23.13.03.26; Tue, 23 Feb 2021 13:03:52 -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=FVBxku+Z; 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 S234110AbhBWUNB (ORCPT + 99 others); Tue, 23 Feb 2021 15:13:01 -0500 Received: from mail.kernel.org ([198.145.29.99]:41934 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233363AbhBWUMa (ORCPT ); Tue, 23 Feb 2021 15:12:30 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id E88EA64E6B; Tue, 23 Feb 2021 20:11:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1614111109; bh=V7jGgaTvePLnhzX3IQJRxGgf0qmrmtHMEb1eydTPlpE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=FVBxku+ZS7e5oVm8i9uCYBS8TafOUM1B4jKGo7qNqsLdjEjvUQa8QLyx1bqPd+5mm 6O4uFRlLLHBagADxj4zWhrJVsBSxPKWdEyTebOHjNcZjtjFBhg9SohXlfZ7G5kDAB5 GMOeYBDapkfcce5BA1pic7YUD0W/2mtVGgTlLVd2SBTQCvih5Z4FmRGl4hOCY02z67 8H36If1ygaJsO8z2J8vvAZJowjOCJfsXGopt/qLmpKS0z+b362QAbyH2aBLiDm3xss cRzXkL63gl6efSH5AhMQKFN5ZOpZQJJn1Phuk4ujDfFLbaSknhrqCOyrefPSJDKnBD KOMVx3OhLOD4Q== Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id CDBFD40CD9; Tue, 23 Feb 2021 17:11:44 -0300 (-03) Date: Tue, 23 Feb 2021 17:11:44 -0300 From: Arnaldo Carvalho de Melo To: Evgenii Shatokhin Cc: Masami Hiramatsu , Josh Poimboeuf , Kristen Carlson Accardi , live-patching@vger.kernel.org, Peter Zijlstra , Ingo Molnar , linux-kernel@vger.kernel.org, Konstantin Khorenko Subject: Re: [PATCH] perf-probe: dso: Add symbols in .text.* subsections to text symbol map in kenrel modules Message-ID: References: <20210223000508.cab3cddaa3a3790525f49247@kernel.org> <161406587251.969784.5469149622544499077.stgit@devnote2> <00abcbd4-e2c2-a699-8eb5-f8804035b46e@virtuozzo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <00abcbd4-e2c2-a699-8eb5-f8804035b46e@virtuozzo.com> X-Url: http://acmel.wordpress.com Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Tue, Feb 23, 2021 at 06:02:58PM +0300, Evgenii Shatokhin escreveu: > On 23.02.2021 10:37, Masami Hiramatsu wrote: > > 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 > > Thanks for the fix! > > It looks like it helps, at least with nf_conntrack in kernel 5.11: So I'm taking this as you providing a: Tested-by: Evgenii Shatokhin ok? - Arnaldo > --------------------- > # ./perf probe -v -m nf_conntrack nf_ct_resolve_clash > probe-definition(0): nf_ct_resolve_clash > symbol:nf_ct_resolve_clash file:(null) line:0 offset:0 return:0 lazy:(null) > 0 arguments > Failed to get build-id from nf_conntrack. > Cache open error: -1 > Open Debuginfo file: > /lib/modules/5.11.0-test01/kernel/net/netfilter/nf_conntrack.ko > Try to find probe point from debuginfo. > Matched function: nf_ct_resolve_clash [33616] > Probe point found: nf_ct_resolve_clash+0 > Found 1 probe_trace_events. > Opening /sys/kernel/tracing//kprobe_events write=1 > Opening /sys/kernel/tracing//README write=0 > Writing event: p:probe/nf_ct_resolve_clash > nf_conntrack:nf_ct_resolve_clash+0 > Added new event: > probe:nf_ct_resolve_clash (on nf_ct_resolve_clash in nf_conntrack) > > You can now use it in all perf tools, such as: > > perf record -e probe:nf_ct_resolve_clash -aR sleep 1 > --------------------- > > I guess, the patch is suitable for stable kernel branches as well. > > Without the patch, the workaround you suggested earlier (using the full path > to nf_conntrack.ko) works too. > > > --- > > 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 > > > > . > > > > Regards, > Evgenii -- - Arnaldo