Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp5773254rdb; Wed, 13 Dec 2023 21:19:19 -0800 (PST) X-Google-Smtp-Source: AGHT+IFG2Po1X91wQYhGL5CplPoMCfDahkaIvCixY88mAjAEdCrSSK9xTXMzOqUpoQNNJn9+DvHZ X-Received: by 2002:a05:6a20:7f94:b0:191:2dc7:573b with SMTP id d20-20020a056a207f9400b001912dc7573bmr4471468pzj.43.1702531158731; Wed, 13 Dec 2023 21:19:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702531158; cv=none; d=google.com; s=arc-20160816; b=bRIXnT0JlU/VnkNjh3pbpTBTJ8dVHUVJN5EnD/YOpxinGCP9VhsBQ9GbKHG20Z0aBZ 772iVGa3MM4leIPQ3+8fC8KAJ8i9OzT2hOmlkr9RR/ALso88v6wEPq0FuiSJaDhlxZZz M56X2KBRygtn+Dv9k/x0J990XcmuBnhahxxzLOjty/zc/1V4/X6UGVf8MZz7NZKeKDEv nBhvzmvoh8uESMMUH+tRCeCgpBZXkTRXY5so2S5Mcqspk3+o/dAAJui8N8CgqVn1/Xau aMHH/Er4Q+OfwCSuEtmUVLHzvdkzn2fzIiMmlco99mXHKzEB1h4bYeR2p/Su9FxUKOcM 3Bng== 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=ADDCINuGr4ysSol6MJw9Quv3YAzck5q2WKb2516jI+4=; fh=uICiEIMiL5wFbzGCJ4gqTcqOppOpN/4OXqBCwl31y5w=; b=SBsQty6rtD1Nj0AffcLWWOAJNjykPRvcol8w9GnW+eshaKJbfSmXWzkYB3ynTpkglU WZ6/BTvue3iMztOys513aQN95LhAz3uMwEQO3XTx5LPO9TReSpudngW72fY03Ul72/VR Pxj6FvBLYBEE66LxAaXxesfWsnQ5JszuGhtTWISS/AJdLvc8lAUEh9KMhvW0F/LSADJ4 LfACajNxDP0iK0gXVDgqZOrMjKXubHmYGulW3qhpSOZCKUjeDmYDRmIFcn3W5poZD3fA TYqCn85KEDwGNELAEXtX1HuPUnQCLshk/rs5Ebb3502/5P4HyfD0lqvQRi3RSy5VI9IR gIeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=YSEWEqGE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id jn3-20020a170903050300b001d04dd7cd12si10456803plb.194.2023.12.13.21.19.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 21:19:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=YSEWEqGE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 4A2B28028B43; Wed, 13 Dec 2023 21:19:16 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1443149AbjLNFTD (ORCPT + 99 others); Thu, 14 Dec 2023 00:19:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43284 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1443128AbjLNFTC (ORCPT ); Thu, 14 Dec 2023 00:19:02 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CD0BCBD for ; Wed, 13 Dec 2023 21:19:08 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B09AAC433C7; Thu, 14 Dec 2023 05:19:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1702531148; bh=Qmguxw2VEVkdVujawfXKj9hwmQrHGLFvLZ7pg6rQI8w=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=YSEWEqGEva6OY5Pl9k5S1taXN2jrycqHbr7jLJyw0uTdJz3uyiILDCkwtjoIwfeIF B4FLQo71YhYmk4SpI+sGDAiOb0e8+lwzcchJHmqLA0EV1megEwmY64VoL2N9c3HHEl OBf+FmSRd9xKHbln/tnWntDdRYXGbmHjm4RgKoZYQqJ2JWQv8hawASRySqRIRBlOMa 7Vw/dACuRBnenN28rwhFZQtBWEZEnoEaK2KZo1JUzCKHOdjBNFzefbLTB9CUTN2odZ 0UudCTtjJwxRrkgrBc/Xmp2iYcJC4VrkasxVq8TmtFw3F54RKN+a9SXD8nONekoHGt by/vNuvkNg8EQ== Date: Thu, 14 Dec 2023 10:46:56 +0530 From: Naveen N Rao To: Masami Hiramatsu Cc: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, Steven Rostedt , Srikar Dronamraju Subject: Re: [PATCH v3] trace/kprobe: Display the actual notrace function when rejecting a probe Message-ID: References: <20231213143914.1591175-1-naveen@kernel.org> <20231214080210.99ff94d956307b036208520d@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231214080210.99ff94d956307b036208520d@kernel.org> X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Wed, 13 Dec 2023 21:19:16 -0800 (PST) On Thu, Dec 14, 2023 at 08:02:10AM +0900, Masami Hiramatsu wrote: > On Wed, 13 Dec 2023 20:09:14 +0530 > Naveen N Rao wrote: > > > 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 > > --- > > v3: Remove tk parameter from within_notrace_func() as suggested by > > Masami > > > > 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 3d7a180a8427..dc36c6ed6131 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(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(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(addr)) { > > pr_warn("Could not probe notrace function %s\n", > > - trace_kprobe_symbol(tk)); > > + lookup_symbol_name(addr, symname) ? trace_kprobe_symbol(tk) : symname); > > Can we just use %ps and (void *)trace_kprobe_address(tk) here? > > That will be simpler. Indeed - that is much simpler. v4 on its way... Thanks! - Naveen