Received: by 2002:a05:6359:6284:b0:131:369:b2a3 with SMTP id se4csp5725460rwb; Wed, 9 Aug 2023 08:20:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFj06RH+vLtYDgUkVKfU7prYUtjvYFVlNpGuFx/+WFPUAIlegJRBrVzgk30PTgefktS6DMr X-Received: by 2002:a17:90b:358b:b0:25b:c8b7:9e5b with SMTP id mm11-20020a17090b358b00b0025bc8b79e5bmr2461594pjb.31.1691594457271; Wed, 09 Aug 2023 08:20:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691594457; cv=none; d=google.com; s=arc-20160816; b=k9aDKdkn3cPROHG1624h1o8yqBbKId7CZLMwfoJfKlgbd/Z65tWy1lQCgTYWAFkBnN rHw+UwDcgFvouJBczOlVeK8Dscz/cUTOjIwDa+8t5LLpwSIZnp/3lbuqghg/ZHGRe5WL 4OnRiOaIiY0I95CmrfDg17Pt5Sj8rV8UEBOYmoqDSCeRWUpcIxPaotUGkiPQSnJIsIdx DZgYT7fyQNiUHJlYNp8kIFl1CptkkCQ2QzLXY5TkOZdEeDmpRVrz1W0GR+vit2wLWpQQ xxNz9ReqcjG4L/QVgg2sxemEJDQfP6EkDjgBRjuqdxq8dcUXfOuncqbH63jFsyZv8nuk TP3g== 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 :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=O7fhCwAS5At8GwqePpcApIowKqf5VIkc7ntw3+/4TE4=; fh=g9Bw0epkbGk1DkAgG7vR8XN0xStfTcipNOxWcjLkU0g=; b=ZQariXLt3+BShYuChSNh5dRaBlWpMt+x/ms9B9dGFM8Dx/8pdmV+ebNrnPrSyYXYsP 4kyCZdICiymRBuIaPwLHmssEftiU/8Zf1CMjdwc7KBS+YHCtcLqHdgU0S0csCf9NeTvk bKpkF71xFNOJrRBbYedrVrdiCsT2dvmvho4Yik8F1XR5+ur9RhCnI9x+NKu9kFI6VknT WjHKiNrpZ6va/I44W3vkBtDsVS9ft00HNYAuZcd99DKT/Qi5clA2jsYnSpdlkuW+L07v oZ+X7AL2qflx2g0ay5KQ//spBJq0qYlyAXOn8dtRHwKCtK5nF08cYu7x81tffPB3+RNJ 8a+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Q2lERAp4; 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 x2-20020a17090a8a8200b00263cfc9753csi1676340pjn.5.2023.08.09.08.20.43; Wed, 09 Aug 2023 08:20:57 -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=Q2lERAp4; 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 S231488AbjHIOpU (ORCPT + 99 others); Wed, 9 Aug 2023 10:45:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49016 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230123AbjHIOpT (ORCPT ); Wed, 9 Aug 2023 10:45:19 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 63D90EE; Wed, 9 Aug 2023 07:45:19 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id EFCB663C91; Wed, 9 Aug 2023 14:45:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CC02EC433C7; Wed, 9 Aug 2023 14:45:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691592318; bh=sShinOtzr9XlCmMRvGYtsdQ5gUdUATOYQTlYZKdx5mI=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Q2lERAp4Hbea8CPPgjMsfeTLG4XKmDhLbhWuj5VbtEZZaYEeO8sNkjIWDh+7HKwl9 Nr1JgTNvSmhD3fGtoEzckQw2NXAo4FB9ZuodqH01Aem3ZwABSJL3gquLlERpXAL0bj mgPKLtJMAMdvtAkoMPM7n4cewj3HmFgxTcTqojawcQQwSAfcx2Q3bXqqHLRTv5q+1g UoUrQWxBoezN9PtxqIK9wnGX6gPskozHP/G5SLL9vUPT1THqYgljpHNZrcES6qZ2/3 YaJ6BJDubOlHwzFMKYM4tPtHQ80CjObT8kl8vLX2nGk8MoXuw4SUC7SP59yaIaom6A ZL7X2sLs5n4Ug== Date: Wed, 9 Aug 2023 23:45:12 +0900 From: Masami Hiramatsu (Google) To: Florent Revest Cc: Alexei Starovoitov , Steven Rostedt , linux-trace-kernel@vger.kernel.org, LKML , Martin KaFai Lau , bpf , Sven Schnelle , Alexei Starovoitov , Jiri Olsa , Arnaldo Carvalho de Melo , Daniel Borkmann , Alan Maguire , Mark Rutland , Peter Zijlstra , Thomas Gleixner Subject: Re: [RFC PATCH v2 4/6] tracing/fprobe: Enable fprobe events with CONFIG_DYNAMIC_FTRACE_WITH_ARGS Message-Id: <20230809234512.e3c39b8fffcc6297262f8fc8@kernel.org> In-Reply-To: References: <169139090386.324433.6412259486776991296.stgit@devnote2> <169139095066.324433.15514499924371317690.stgit@devnote2> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-5.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS 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 On Wed, 9 Aug 2023 12:31:00 +0200 Florent Revest wrote: > On Mon, Aug 7, 2023 at 8:49 AM Masami Hiramatsu (Google) > wrote: > > > > From: Masami Hiramatsu (Google) > > > > Allow fprobe events to be enabled with CONFIG_DYNAMIC_FTRACE_WITH_ARGS. > > With this change, fprobe events mostly use ftrace_regs instead of pt_regs. > > Note that if the arch doesn't enable HAVE_PT_REGS_COMPAT_FTRACE_REGS, > > fprobe events will not be able to use from perf. > > nit: "to be used from perf" ? OK. > > > --- a/kernel/trace/trace_fprobe.c > > +++ b/kernel/trace/trace_fprobe.c > > @@ -132,25 +132,30 @@ static int > > process_fetch_insn(struct fetch_insn *code, void *rec, void *dest, > > void *base) > > { > > - struct pt_regs *regs = rec; > > - unsigned long val; > > + struct ftrace_regs *fregs = rec; > > + unsigned long val, *stackp; > > int ret; > > > > retry: > > /* 1st stage: get value from context */ > > switch (code->op) { > > case FETCH_OP_STACK: > > - val = regs_get_kernel_stack_nth(regs, code->param); > > + stackp = (unsigned long *)ftrace_regs_get_stack_pointer(fregs); > > + if (((unsigned long)(stackp + code->param) & ~(THREAD_SIZE - 1)) == > > + ((unsigned long)stackp & ~(THREAD_SIZE - 1))) > > Maybe it'd be worth extracting a local > "ftrace_regs_get_kernel_stack_nth_addr" helper function and/or > "ftrace_regs_within_kernel_stack" ? Yeah, maybe we can make it a generic inline function in linux/ftrace.h. Thank you! -- Masami Hiramatsu (Google)