Received: by 2002:ab2:7903:0:b0:1fb:b500:807b with SMTP id a3csp293667lqj; Sat, 1 Jun 2024 21:17:52 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWISe4xiY3MdO7jxnJ0PEOQBa2TfLz57gSysGdAsWpTFzWCZjoxfIn/LOYOGE+ZIbrmOB2fy+9w2WZCiuiBCm29H7U4FWLCfxnmq7fKTg== X-Google-Smtp-Source: AGHT+IEktR7jksGQy2H6SdRcoXpV7PiN0bTAgI7sGwLk+b6WkzwWW9W2WvXYI3OWYMulBQ9mgRPD X-Received: by 2002:a17:907:9392:b0:a68:4397:a80a with SMTP id a640c23a62f3a-a684397acdcmr347855166b.17.1717301872281; Sat, 01 Jun 2024 21:17:52 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717301872; cv=pass; d=google.com; s=arc-20160816; b=esHl9B8X1axsN1O4D7O0/hGT/o9H4NWqZNqyCgYYqR/RXwJ3hRRZDN8vwCzT8wa0FC RNZexHZD5xQNzSJqW4TcQfgZYb45PP+90BBYVnVEmbOBePivbTRYckQIlCyl4IqiNkvs 0AmC8Hwqc/66ziiKUnGSd2acrCYK3ZR5Z4pnUbrINKvDitO7fb4Ok2aAnzWjL1LSYsqu WXtCQxwKYT/NNY4RkanIOSEg+nN7n2MjMHXnN+xGRBJuUQVYu1XM+0FDYTiDdw1/toeu O75ZsclNQVgN4YEa/SXOYQZc0maAeiCRlXzP2mWFBOs5mSWYzPn2a/c02B12bmktybCI /6+w== 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=Gn9kX6eGgmTUda6T/5+XNpu5Bfz3pA7ruDzS+kIdLSdK3GLFojEgCt9iikOy8ndMJ2 7zu5dndYdPewk/92S0ktGQxcchQ1H6IyozB0kBIQ+OpVZbrFtclA2ZzRoN6Vle98XmE5 m647rncwPfKLv64/nzEaU7LY4nakQU4ErAxJUdZowoLQkAvaXsGwftZcW8bLPmakfrMi 6K0Ek/zNmDjdoNyPQQTSgmW7lv5we0d1Kp6NjFQjVTIQ59FGj4wTRumPyTm6Eq1NfxJN 3el5kGpsRrvRlM6OXPL1P8qAGKdl7y1tUI6rENyeQZbpxGgxweEjE1aC065tIGhoTcYs yWuQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-198099-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-198099-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 a640c23a62f3a-a67eaf64ddbsi274480666b.782.2024.06.01.21.17.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Jun 2024 21:17:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-198099-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-198099-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-198099-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 805F21F22858 for ; Sun, 2 Jun 2024 03:41:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5387679C8; Sun, 2 Jun 2024 03:37:31 +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 1D18538DC8; Sun, 2 Jun 2024 03:37:26 +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=1717299447; cv=none; b=ojBWobQmPgGMtZe91cZitjQj2y8T9E2/7zNk1l+9UZnZvNrMC8PVBR8H8Ap95e7/ts14PD48EcVxAgMfNs+pgN/r08Z+gJ4JfQ5n5WCkZ8lF+eMS64+t8tkG8Ps6cwJyHDFN6cnm7eNLn7cEJk7Hkprg8HtJJqovdEAIqvBMPRs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717299447; c=relaxed/simple; bh=NmE7oZQh9MdS7aKT9pQIniDkO7K+Ej0rPisWKG9X8eA=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=jaghl70mnaENp6xGm4YpX+7ssOrGSNRF361SpRB+6WAv0owG+B7/pSy5S8vmIXRYNWNk+S9rwZPQXcjtdhuisr/6foeveIjLyeBYqHEyaYH0Zw5Geka8VqPVPHL7oH1OUDqWnnkJfnyGuS/vVsc45KmmnYauYlQjkVCKMklN0O8= 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 D019BC4AF07; Sun, 2 Jun 2024 03:37:26 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.97) (envelope-from ) id 1sDc3G-000000094Rw-0eZt; Sat, 01 Jun 2024 23:38:34 -0400 Message-ID: <20240602033834.016722869@goodmis.org> User-Agent: quilt/0.68 Date: Sat, 01 Jun 2024 23:38:02 -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 v2 18/27] function_graph: Move graph notrace bit to shadow stack global var References: <20240602033744.563858532@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