Received: by 2002:ab2:7903:0:b0:1fb:b500:807b with SMTP id a3csp1166832lqj; Mon, 3 Jun 2024 12:11:39 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUEdpLMiYOGVdlq8cXQXSX2IzPgDHlBzJI9+ttsmflzOywWna9DVrTbbb02rnRnYdoNUst5WJyBAjyfKx9QQ/K/CmrOrxjgme//5R9YPQ== X-Google-Smtp-Source: AGHT+IHd552+yMDm/xC+y/4FgQxNXcpp40Q7Zas5lK7vlpIUME7oIN4yq9rxeNfsIHcwz7hWJ9uj X-Received: by 2002:a17:906:160f:b0:a68:e6d8:3154 with SMTP id a640c23a62f3a-a68e6d8330dmr415499266b.71.1717441899852; Mon, 03 Jun 2024 12:11:39 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717441899; cv=pass; d=google.com; s=arc-20160816; b=KtMISpPlpOpaY8M1WGscjri5ljFTtPzrA5+IAvVSnrfl9Ugy37JqmVp/PneYG8S+RJ JKw+nldWcz354CDVDLq5Mgdq6MqEqxndvxRyxOgdL9QH0xf/ccSLNzPjsCcrRJ0XX8aM wCFmafr/0GoJ2QOI4XQNzpleC3zBOMW/kMEzzdlvs6OQwus5UBS2l/NI9Vg0yniIbOAY /Ji2R7LmXUBgpAbGafZnmMFPbMOyBM3xdMbSAVMQ2z0/Q6HUoYu2Vjo+PVytT+dVEyxR B+E5VoNFP8GlrLFQXaScuJVSwjomCoaP1disE2ybPVhuXHoUgxjXbU4sjHIuMGRjPzsy ZJ0A== 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=MitWgtSp27FCT4/oySdAT5wkPAx6u0TfLnS5s5RKF9E=; fh=YfcaVrAzBpSwi8dOlqHV4K1os6qdULs4cyXFG/DyLfE=; b=g95RPjcGk8YAyzV/v3ZzeEKfcIcUmVUVrzXTaEMHM8ixlyiN8Wnmc+SXo4qjb3XJgS TdD5GUuzQpUS3I9VntF7pnbTxSWdpOcusd9IMLS891qOLBIdIeKPSwkAgqQxukiOnaJg UM6xaDJWONFjaYTFZqFBunj+Z9neRtg+KKDCMBgM0oW7+OMdQeQai5YK59JtrluxO6bz dg4UqAS8MVvc1jhPhL2rmVu+6HXH91lEGgGhdlNZZ+f/4Iva8fyapOhcF1/n9ZI6PBFl zeG4T+4p233Ad8wEYqhMkUyaRKVZTDa/1u6YGJLRtR5VtTsw4bByTKQSohmVVR+fxPZC pduw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-199614-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-199614-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a640c23a62f3a-a67e6f036b7si439529466b.150.2024.06.03.12.11.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jun 2024 12:11:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-199614-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-199614-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-199614-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 199671F26097 for ; Mon, 3 Jun 2024 19:11:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 359B113F441; Mon, 3 Jun 2024 19:07:17 +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 74F5913CAA4; Mon, 3 Jun 2024 19:07:13 +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=1717441633; cv=none; b=p9At9TtebbcqUTCxYUcPbCHiJeay3+TTg7e5ZhXgEmoS8WnM+RO4tgDfT9AajZMjubWdnfoo6VYR0CZDjIs2+pF/gsiZO7JGzKQF175DjtlMsjEJRhqv5OVY0SV+Ew0Xt50bC+ur5iE3D0xW9WgvbSOS8gVWEI/JPLclsiL5vK0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717441633; c=relaxed/simple; bh=NmE7oZQh9MdS7aKT9pQIniDkO7K+Ej0rPisWKG9X8eA=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=O8NFc9XtelDaJvlswbxYbLSLbUQkJdJ1Po78qU5MIYPT35qCjITkUSCuPo94YIb9gkXQQDR63XPgh3MBSnoEkd7PJo99GYty5vmkB+a8hwup9lCb+VSWFB1D9ILJflt78WKg1yukYoMvM9nZ6GipNjFSWu4Z2LeZD6BSJtUDFyA= 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 E80DDC4DE0A; Mon, 3 Jun 2024 19:07:12 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.97) (envelope-from ) id 1sED2d-00000009Tuw-3wUs; Mon, 03 Jun 2024 15:08:23 -0400 Message-ID: <20240603190823.796709456@goodmis.org> User-Agent: quilt/0.68 Date: Mon, 03 Jun 2024 15:07:22 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , Alexei Starovoitov , Florent Revest , Martin KaFai Lau , bpf , Sven Schnelle , Alexei Starovoitov , Jiri Olsa , Arnaldo Carvalho de Melo , Daniel Borkmann , Alan Maguire , Peter Zijlstra , Thomas Gleixner , Guo Ren Subject: [PATCH v3 18/27] function_graph: Move graph notrace bit to shadow stack global var References: <20240603190704.663840775@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: "Steven Rostedt (VMware)" The use of the task->trace_recursion for the logic used for the function graph no-trace was a bit of an abuse of that variable. Now that there exists global vars that are per stack for registered graph traces, use that instead. Link: https://lore.kernel.org/linux-trace-kernel/171509107907.162236.6564679266777519065.stgit@devnote2 Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Masami Hiramatsu (Google) Signed-off-by: Steven Rostedt (Google) --- include/linux/trace_recursion.h | 7 ------- kernel/trace/trace.h | 9 +++++++++ kernel/trace/trace_functions_graph.c | 10 ++++++---- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/include/linux/trace_recursion.h b/include/linux/trace_recursion.h index fdfb6f66718a..ae04054a1be3 100644 --- a/include/linux/trace_recursion.h +++ b/include/linux/trace_recursion.h @@ -44,13 +44,6 @@ enum { */ TRACE_IRQ_BIT, - /* - * To implement set_graph_notrace, if this bit is set, we ignore - * function graph tracing of called functions, until the return - * function is called to clear it. - */ - TRACE_GRAPH_NOTRACE_BIT, - /* Used to prevent recursion recording from recursing. */ TRACE_RECORD_RECURSION_BIT, }; diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h index 82d879dc63ff..b37402e3f0c9 100644 --- a/kernel/trace/trace.h +++ b/kernel/trace/trace.h @@ -919,8 +919,17 @@ enum { TRACE_GRAPH_DEPTH_START_BIT, TRACE_GRAPH_DEPTH_END_BIT, + + /* + * To implement set_graph_notrace, if this bit is set, we ignore + * function graph tracing of called functions, until the return + * function is called to clear it. + */ + TRACE_GRAPH_NOTRACE_BIT, }; +#define TRACE_GRAPH_NOTRACE (1 << TRACE_GRAPH_NOTRACE_BIT) + static inline unsigned long ftrace_graph_depth(unsigned long *task_var) { return (*task_var >> TRACE_GRAPH_DEPTH_START_BIT) & 3; diff --git a/kernel/trace/trace_functions_graph.c b/kernel/trace/trace_functions_graph.c index 66cce73e94f8..13d0387ac6a6 100644 --- a/kernel/trace/trace_functions_graph.c +++ b/kernel/trace/trace_functions_graph.c @@ -130,6 +130,7 @@ static inline int ftrace_graph_ignore_irqs(void) int trace_graph_entry(struct ftrace_graph_ent *trace, struct fgraph_ops *gops) { + unsigned long *task_var = fgraph_get_task_var(gops); struct trace_array *tr = gops->private; struct trace_array_cpu *data; unsigned long flags; @@ -138,7 +139,7 @@ int trace_graph_entry(struct ftrace_graph_ent *trace, int ret; int cpu; - if (trace_recursion_test(TRACE_GRAPH_NOTRACE_BIT)) + if (*task_var & TRACE_GRAPH_NOTRACE) return 0; /* @@ -149,7 +150,7 @@ int trace_graph_entry(struct ftrace_graph_ent *trace, * returning from the function. */ if (ftrace_graph_notrace_addr(trace->func)) { - trace_recursion_set(TRACE_GRAPH_NOTRACE_BIT); + *task_var |= TRACE_GRAPH_NOTRACE_BIT; /* * Need to return 1 to have the return called * that will clear the NOTRACE bit. @@ -240,6 +241,7 @@ void __trace_graph_return(struct trace_array *tr, void trace_graph_return(struct ftrace_graph_ret *trace, struct fgraph_ops *gops) { + unsigned long *task_var = fgraph_get_task_var(gops); struct trace_array *tr = gops->private; struct trace_array_cpu *data; unsigned long flags; @@ -249,8 +251,8 @@ void trace_graph_return(struct ftrace_graph_ret *trace, ftrace_graph_addr_finish(gops, trace); - if (trace_recursion_test(TRACE_GRAPH_NOTRACE_BIT)) { - trace_recursion_clear(TRACE_GRAPH_NOTRACE_BIT); + if (*task_var & TRACE_GRAPH_NOTRACE) { + *task_var &= ~TRACE_GRAPH_NOTRACE; return; } -- 2.43.0