Received: by 2002:a05:6358:51dd:b0:131:369:b2a3 with SMTP id 29csp454945rwl; Wed, 9 Aug 2023 17:59:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG5NSP2XWcAAxkp6oeoAOw19ZQQ0tLf0Uz394eSbuhBnWug7joKyjVZ2koOmiD4jS4AxhVs X-Received: by 2002:a17:906:3101:b0:99b:cb59:79b3 with SMTP id 1-20020a170906310100b0099bcb5979b3mr753969ejx.1.1691629191244; Wed, 09 Aug 2023 17:59:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691629191; cv=none; d=google.com; s=arc-20160816; b=w+YHq3KfmkW1VdgKowIwbNOXv2MUeqtTL8jn3Iaw0KuSS1PKOE+HlDAo0XoMVS/YMh KPKqMvRFA+Tz70kCCgEqsvW8tBpINlFIRZGudiBH3t6c1kSvR94jEt21tQdVrz6mQGoL DFy37/SX/rfTfvzLU6HhjQc/jmzXMRXuHBk+M1fqcaManZrQHHFj0i9qrvX1FKhkoYuP 8HjB5SbPhSNFtpJ2Le934QSS6OdLFQJbAMdIJhy2B/01wAdWDUxeRxAgQ7usV5FxSB+0 2lgpw5p0tNMI2XD6w+fBsuMwOszNkk9gFgrv5MyoPWjvTEsXPBg0ALQuzaTLQU6eQU7k uM1A== 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=AL3px5RIbXD+q+MGZHiVn2tOzJWhmjDXdKQ2oZq98a4=; fh=g9Bw0epkbGk1DkAgG7vR8XN0xStfTcipNOxWcjLkU0g=; b=iNshiEzrWA9mV0npI8oQTarnoREHXfFRQBn7xhkfDJYYidrtOexgvXkl7PqwFagkEb k8zLHKbT7kRAAYd7rAXByZYIZmF9YK49+AO9DjCvU/kS/Hh7gmaBynAmb/gBLPyKbrVs 4DWkafh7Wqtn8TzdLGlmPyahmMC7OSiIwkn93oTEXnz8h/yxTV1SVh2EIq56PhX5RxPu L4ueCHIeaxzhPOBPcKrBeqggUB7lPz+VJQQnkZGfdQelP+KUeAblwfE18fEKSDYrwv/2 PW206g80jGHK/vUZeR3px6R2CmbVVNrwNUhIjJajrhX02wSL5xynTn7xmQXO+SfnFsQ8 oPeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=icx7Buej; 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 f1-20020a1709067f8100b00992d0de875esi342415ejr.914.2023.08.09.17.59.27; Wed, 09 Aug 2023 17:59:51 -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=icx7Buej; 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 S232403AbjHJAjU (ORCPT + 99 others); Wed, 9 Aug 2023 20:39:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51270 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229470AbjHJAjI (ORCPT ); Wed, 9 Aug 2023 20:39:08 -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 DD66E26A0; Wed, 9 Aug 2023 17:38:52 -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) server-digest SHA256) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 73E9C64CA9; Thu, 10 Aug 2023 00:38:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2DDA7C433C7; Thu, 10 Aug 2023 00:38:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691627931; bh=WrUTXC6uZjIJQaROzuUF9MIOrS/vce2evjZsylCt4wc=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=icx7BuejGWgQgdLOejuiVvwevfHp410W6RFZHWf6b76nLjgPpuwce3UJ3nKshFNej D0kuuMcogJ/IR91m2pOGC+D4ILV2jdYk4SX3pNEcDYrBxU0ktSD4p7Ft/ROwAMobOy j1F+duGqMm4TaR0My8lIgRmcaIShJZv9T4zjtsN6OrP776fHTDWlLJFKn8bK9gMTgk b17i9kv5vuYgcxaVdOBQubAqarBTny43Uy6ehQOmWSnqmyKLwHa11gIkzFanmww4xE rEx4iH+RE0Enkh0PbDaZtsS+j1FjKJbqep4xSTcwFt5Sr4bVrX3DOHUSmGmAczfm7q UFbENRY1hm5xg== Date: Thu, 10 Aug 2023 09:38:45 +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: <20230810093845.7ebbe1ada897a4afe861e331@kernel.org> In-Reply-To: References: <169139090386.324433.6412259486776991296.stgit@devnote2> <169139095066.324433.15514499924371317690.stgit@devnote2> <20230809234512.e3c39b8fffcc6297262f8fc8@kernel.org> 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=-2.9 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_BLOCKED,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 17:38:00 +0200 Florent Revest wrote: > On Wed, Aug 9, 2023 at 4:45 PM Masami Hiramatsu wrote: > > > > --- 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. > > Or even just above this function if there are low chances it would get > used elsewhere :) Thanks, but since regs_get_kernel_stack_nth() is defined in asm/ptrace.h, I think ftrace_regs_get_kernel_stack_nth() is better defined in linux/ftrace.h. :) Thank you! -- Masami Hiramatsu (Google)