Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp332644lqt; Thu, 6 Jun 2024 05:15:09 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU2wqJ1nT/+glDagdDN/cbE3AO5ydzh8+38WLthrwS7Vkj2zKrPGXboTaHXaAoF8i8S2RgDWHDgs2DILqZcI8tgl8/1QAZRK6+dQbv+xg== X-Google-Smtp-Source: AGHT+IHYolCKRQ5+V+jEPYS1SL9cdOAlKSxbpJM3cK84+SBFIhQp5EyhiHhIUaxLz6WeOqrb661X X-Received: by 2002:a2e:7a1a:0:b0:2ea:81cd:a0da with SMTP id 38308e7fff4ca-2eac79c3413mr30649201fa.8.1717676109795; Thu, 06 Jun 2024 05:15:09 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717676109; cv=pass; d=google.com; s=arc-20160816; b=R+x1Fzfv+5qIFS61HHMpapDsk7KqHQIq4SPYzYE+jAtIBb8O/B6YQWwIS9eYxRkHn6 CuX99hybH9s3sPq9fR1FuSPCJJCuq8y0IdB6Y/eA3HkMFejaAgl2XA83WsiCFXH/y+bx 6sRpvBLRinTnHlvZmTQ07eugvGNFP2HvzLljJdwouIQ+V+Z0NuCNfTk5PT3nzGXOSihx jbnco60I2BAJQ5IPwRFOBZwwm96ffF+cddR45ArMCx512o5XWR4GhhW6bCX58TTQa/3D 8YQ1iMWvxhqd9UMP5raTwPMYNP/K8VbdB/Sep9uGJSeTAApqBSjKIMYFc7cRtIWrIPa3 nK5A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:subject:cc:to:from:date:user-agent:message-id; bh=DBNko6vmfD9+je+UIYHP79Ub5yQrzNPK4Q8y7ZqtM1A=; fh=Mr4Ca7N91EGZb1e92jpmwAiBx4UwHI2oShqJBr5wH/o=; b=svLzwCetlohbscFLGeWhko254lBiCE/uJy6+7f67HMyDfA7xtOsmnxDtob2pX59hM4 WLyxPJhuEVhlSvecC9c7UekkiqVp6F3ZP5cI1gd4KAIaxdMI1io9zzakFOPGDJHY8PzS /RpCF9kYRM1dWQ0BgBO/4nlCWA/6BG+xWC9NKvJKkIWpfWjANrkoJgD4HuMwB3Ak1AmS yBpjqt+GRSb6KaDnGQoiIYa+vD16zQAZR34SsxPfUk1oxl2CMBqNJqboBLAF1eFW/Aon glZ/N9UtcghweWkH5nm87GHSp5OeCrJ//W5Ecj7DwRnq2e9yEzXSWG6zF9JL6SG5wdYB +Nzg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-204255-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-204255-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-57aae1fdfb9si601683a12.280.2024.06.06.05.15.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jun 2024 05:15:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-204255-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-204255-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-204255-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 80C1D1F22FAC for ; Thu, 6 Jun 2024 12:15:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 431A6198A3D; Thu, 6 Jun 2024 12:11:04 +0000 (UTC) Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8906919596A for ; Thu, 6 Jun 2024 12:11:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717675862; cv=none; b=bb0bT7myTeadtnomn457TBskuSVUO78gR5S5labj93WXaO0wT34kerxIYOuXcgzBNhKDjfEvOMptJsVBtWYftAtSCg5ufRgUC9Ul4m9apBbUl12Vttf8C+DKPrLtnqBwXPDIriX3I+XX88+FBHLj4iNBKLDOxrPdEeRbBMDuHEg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717675862; c=relaxed/simple; bh=5LVh91AFmjjDLQKZB1oxRIdLI2t5YNNMCvA9sshgB5Y=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=Gfnyp9bVqNkxEDUht9m2YLjW2YUCagpBnRC++Hacye1UuEB6yC31d/430ICcF5+36e/T07OArPqci0bpzhuMQtLeJmeyZZ5he+uAZc0K5VWqzZk1Mjf8nB1+z/ibSkOnzP18KHbP0mS6ZaSwwY+opK761iBTZWslLInBySChG7o= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 34F9EC4AF68; Thu, 6 Jun 2024 12:11:02 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.97) (envelope-from ) id 1sFBxS-00000000nPK-3Cmr; Thu, 06 Jun 2024 08:11:06 -0400 Message-ID: <20240606121106.626743588@goodmis.org> User-Agent: quilt/0.68 Date: Thu, 06 Jun 2024 08:10:18 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , Tatsuya S Subject: [for-next][PATCH 14/15] ftrace: Hide one more entry in stack trace when ftrace_pid is enabled References: <20240606121004.857581251@goodmis.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 From: Tatsuya S On setting set_ftrace_pid, a extra entry generated by ftrace_pid_func() is shown on stack trace(CONFIG_UNWINDER_FRAME_POINTER=y). [004] ..... 68.459382: => 0xffffffffa00090af => ksys_read => __x64_sys_read => x64_sys_call => do_syscall_64 => entry_SYSCALL_64_after_hwframe To resolve this issue, increment skip count in function_stack_trace_call() if pids are set. Link: https://lore.kernel.org/linux-trace-kernel/20240528032604.6813-3-tatsuya.s2862@gmail.com Signed-off-by: Tatsuya S [ Rebased to current tree ] Signed-off-by: Steven Rostedt (Google) --- kernel/trace/trace_functions.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/kernel/trace/trace_functions.c b/kernel/trace/trace_functions.c index 13bf2415245d..3b0cea37e029 100644 --- a/kernel/trace/trace_functions.c +++ b/kernel/trace/trace_functions.c @@ -231,6 +231,7 @@ function_stack_trace_call(unsigned long ip, unsigned long parent_ip, long disabled; int cpu; unsigned int trace_ctx; + int skip = STACK_SKIP; if (unlikely(!tr->function_enabled)) return; @@ -247,7 +248,11 @@ function_stack_trace_call(unsigned long ip, unsigned long parent_ip, if (likely(disabled == 1)) { trace_ctx = tracing_gen_ctx_flags(flags); trace_function(tr, ip, parent_ip, trace_ctx); - __trace_stack(tr, trace_ctx, STACK_SKIP); +#ifdef CONFIG_UNWINDER_FRAME_POINTER + if (ftrace_pids_enabled(op)) + skip++; +#endif + __trace_stack(tr, trace_ctx, skip); } atomic_dec(&data->disabled); -- 2.43.0