Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1760001rwd; Fri, 9 Jun 2023 01:31:49 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6gxpw0ThK9+riDCUyf9OMc/ARLPYmTmp2fD1QSrHzFQgcxQO5UUpGW/jieJT6VAwPcncI8 X-Received: by 2002:a05:6808:238a:b0:398:2d3a:29ba with SMTP id bp10-20020a056808238a00b003982d3a29bamr1176134oib.3.1686299509650; Fri, 09 Jun 2023 01:31:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686299509; cv=none; d=google.com; s=arc-20160816; b=wW9ReosQahABywHEjTMm20sGsq3z1CGbZAEqqkZjc1Pxmk+JsNU5fn8Iz9vL7Q6kvz RsPFTdEDvFMsq37zJI0K/7BE0Y7YU8bQWQL52BwwMRLEEpLVNRvGqTNqlCEyDPXvKW0b Kgh8S/Pr92dM5Ek9aOrqOtn44UtT8KVt8ta1TmTAoOP7n6mqR7HvDH8ykF1xCNh1sWoL N1V1T4lhXjJBZOX1zK7UJgyagQXxxiKbOHiMzZK5rNdZZ82KIZhIgFrqSQdHVgqHWZL0 pJtc++h4D2A/kehyi0in1bbM5/4RvF1wq0p1+vPCYogcxOCcZB7UhWE7UjKIDijatgCj RNUw== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=g0X0ifb/k8bABFSPSNZHrPlrEsT8fbHQv7lHm5QoM2o=; b=bq+ykJq/k4f4dZvElMIb8byeRsQqsnYHT7e6LehBxUmkj78l7N1yMvDpSCPJUM90kv JZ3cQNeunMXNuaYSosEZ73bRArMdG0VPIqKwsoLz3svKJIK6AsYGLsdsKMDOMQcCTK1I luggS6adFpGkDzX6wivVGA8smD6kdUiMBCgul+ZZn7/HI4Uu6EbPVO1TlM+9eLzBczmw OA61F7kaQtS2Qfb1rRkGB3GBCSa+7Ve6UTq8jGCj0Mp2HKJ02kMG+O045GmUxX4MneO4 iJe4Dy8nlZEA3m6aw7m4BA7tMtrz527pXTs/vi59p6JLg19icXgXjOUna3gcHSsGaKSE +i7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=EFCZKNfn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c1-20020a17090aa60100b0025945de4165si2334646pjq.141.2023.06.09.01.31.35; Fri, 09 Jun 2023 01:31:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=EFCZKNfn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S239673AbjFIIIJ (ORCPT + 99 others); Fri, 9 Jun 2023 04:08:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43734 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240104AbjFIIHe (ORCPT ); Fri, 9 Jun 2023 04:07:34 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0D55A3A84; Fri, 9 Jun 2023 01:07:10 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 9C9A261AA8; Fri, 9 Jun 2023 08:07:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8CC09C433EF; Fri, 9 Jun 2023 08:07:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686298029; bh=WkpNk0rI0ZwQDVMOXz+3VugeUmJZxZ2Bg9yb6RLZeCw=; h=From:To:Cc:Subject:Date:From; b=EFCZKNfng2goc1Z1ZRGcWxcqx3eHb+gRDWB+6+PDgbydcb0N9/J+EsN5S5Wc4jNh0 /v9qM0oPw5w9Ftg1LW5xcthwxjKf2mzBgTreU1X55aL/cdtwrmP8ZzBkvCewAAAShx olu0mQE9up7Di1cDzvGPEejzOtqwofCyugd2zRkD3HWrZ2l/ALvPN8I2EotAyxcLNt dXdKaawOXnO24E11/LYKSZGP3jNnq1/QrHONrb1sxdbTJl8K62KmCj5yJTl7tTImzB K1YVVbPfB1KJihO0sXACXUCT1JngMQjO6TAaLMaqnbzKciwpvxGFAIP4M9iCQDZxLJ 6n7uGY4upLg7g== From: Naveen N Rao To: Cc: Steven Rostedt , Masami Hiramatsu , Srikar Dronamraju , Subject: [PATCH v2] trace/kprobe: Display the actual notrace function when rejecting a probe Date: Fri, 9 Jun 2023 13:28:09 +0530 Message-Id: <20230609075809.434392-1-naveen@kernel.org> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Trying to probe update_sd_lb_stats() using perf results in the below message in the kernel log: trace_kprobe: Could not probe notrace function _text This is because 'perf probe' specifies the kprobe location as an offset from '_text': $ sudo perf probe -D update_sd_lb_stats p:probe/update_sd_lb_stats _text+1830728 However, the error message is misleading and doesn't help convey the actual notrace function that is being probed. Fix this by looking up the actual function name that is being probed. With this fix, we now get the below message in the kernel log: trace_kprobe: Could not probe notrace function update_sd_lb_stats.constprop.0 Signed-off-by: Naveen N Rao --- v2: Update within_notrace_func() stub macro with the second parameter to fix the build error reported by the kernel test robot. - Naveen kernel/trace/trace_kprobe.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c index 74adb82331dd81..2d695db5425e7c 100644 --- a/kernel/trace/trace_kprobe.c +++ b/kernel/trace/trace_kprobe.c @@ -449,9 +449,8 @@ static bool __within_notrace_func(unsigned long addr) return !ftrace_location_range(addr, addr + size - 1); } -static bool within_notrace_func(struct trace_kprobe *tk) +static bool within_notrace_func(struct trace_kprobe *tk, unsigned long addr) { - unsigned long addr = trace_kprobe_address(tk); char symname[KSYM_NAME_LEN], *p; if (!__within_notrace_func(addr)) @@ -471,12 +470,14 @@ static bool within_notrace_func(struct trace_kprobe *tk) return true; } #else -#define within_notrace_func(tk) (false) +#define within_notrace_func(tk, addr) (false) #endif /* Internal register function - just handle k*probes and flags */ static int __register_trace_kprobe(struct trace_kprobe *tk) { + unsigned long addr = trace_kprobe_address(tk); + char symname[KSYM_NAME_LEN]; int i, ret; ret = security_locked_down(LOCKDOWN_KPROBES); @@ -486,9 +487,9 @@ static int __register_trace_kprobe(struct trace_kprobe *tk) if (trace_kprobe_is_registered(tk)) return -EINVAL; - if (within_notrace_func(tk)) { + if (within_notrace_func(tk, addr)) { pr_warn("Could not probe notrace function %s\n", - trace_kprobe_symbol(tk)); + lookup_symbol_name(addr, symname) ? trace_kprobe_symbol(tk) : symname); return -EINVAL; } base-commit: e46ad59233cf16daf4f3b9dd080003f01ac940fe -- 2.40.1