Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp915080lqb; Fri, 24 May 2024 19:48:03 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVsyKsiT8jrfVspfCrbiVHwj1NWpIedkfHnYxoeblrZu5RJoofzKBw4qTQv9JLRI+XQJwh+mURs6QMlFl1Cta8JQVEvx1E+ctmqCOS9cA== X-Google-Smtp-Source: AGHT+IGKB7DHQK3OusqDAbZZnezw4EXmSp1cgOe3GP8SkVp2XD3QWFMvJS0AsO1ApXIsgSdL7wgW X-Received: by 2002:a17:90a:e558:b0:2bd:b43f:4b with SMTP id 98e67ed59e1d1-2bf5f2053abmr3848273a91.31.1716605283529; Fri, 24 May 2024 19:48:03 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716605283; cv=pass; d=google.com; s=arc-20160816; b=vM1abESfEVN6yvw/+zWq7vrITXxxNLFuMHFSRD3APbzdKMNa2LM5fmAfUluOmwfKzS +P5FaNNDGrcXxIuW3F+FdwyAqUwpZR8ETAlQZuqhoYE+tm3WLxW3rhhQ/uBunc5GKdKu NQ+3x4MAJAXXmn85Yefz5bmyS40kgn4MsPK//y7F0AnzmdkzvYBvF2pMwNUFg0MSzHXY V+b545ZbqZhNRfBmz+mKcU5cBfxHmSdfgL+5x9ImnMj9kicOxcais1b29u94QeWXqY17 MRDtQRBvbFtfd/BvBuehAm2PLT57AFbDasuuOdxfwYhSRdjR0Hi6Q1nMK7UVqFInvvxN b+YA== 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=e+m0f4HGe+ziBiLdvUTlL6SMr10dpM5kSK9RAGJlnQ8=; fh=YfcaVrAzBpSwi8dOlqHV4K1os6qdULs4cyXFG/DyLfE=; b=0EwLQ0VxM8o839/deFar9vwFgGYglBIgbKHzMrPYSSsZJptdlFJoRwn1l8rcYhBjX/ Tf1XmF1rBW4xqT+CeF+KWMHy++LGv5qhL5xzeVsArZJ2kF3fQ34z/3MbK3Vmt4SlvYAj rX0g9JNHB3xgSpstNC3rwljrT+v5X+1RJrZnvvVUI5KDHeYklXv/t2Jb47ogDaGsvs+n PfRzaQt6ICs3kpPQK5YsrHWAV0sS/NuVKVoe+MATLnmZIdirSXMsdjoiY6eSktRFT9/A jpYog8i/UpEmLYT5Mj0yFb87XEkdS9OBrsJb4x8dOSQzbTJqNblAWawcz+tYc4yClDoY VvAQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-189256-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-189256-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id 98e67ed59e1d1-2bf5fe6064bsi2357202a91.128.2024.05.24.19.48.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 May 2024 19:48:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-189256-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-189256-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-189256-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id BB34CB23367 for ; Sat, 25 May 2024 02:40:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2BBBB129A9C; Sat, 25 May 2024 02:37:00 +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 B55302C85C; Sat, 25 May 2024 02:36:55 +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=1716604615; cv=none; b=rZx6Cvzz/eq/TpGK6e5qI1DPrM0pYhHecD6FV7F6pGeC5XjbSkrk4x2ychQWehLQiK4yhDcbAMD7KE1LLm1fVIHWJJPtCROfX06JXjLNJX28DvWXtc8eyQO3ZsGminvWUl65Rb1IgxgKH33E0HWVKYX6swn35rWDS1wLYsKKzwc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716604615; c=relaxed/simple; bh=4PMib5tXa91o2GYhKIgnQuRF42K4guKTrKJURb8KRgU=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=h4cbsDQAFtF8R8s136Bd0LRDBswbvtXS4y+Zb03h/LeEqzW/TU1M958sYhKhmIQ+lolRrkFa3C49HNQqTi/oP/VKv6ZuKQ4YLZoalYt4GNdxThNc2sDAHlqnG3BXfm/cQaQlTt2XbL2OWA4+nF7g0sGFW6RXi9XtoOR6p5UFOUQ= 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 16A99C4AF67; Sat, 25 May 2024 02:36:55 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.97) (envelope-from ) id 1sAhHz-00000007DP4-355C; Fri, 24 May 2024 22:37:43 -0400 Message-ID: <20240525023743.591582334@goodmis.org> User-Agent: quilt/0.68 Date: Fri, 24 May 2024 22:37:07 -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 15/20] function_graph: Move graph notrace bit to shadow stack global var References: <20240525023652.903909489@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 5398b6889027..c91953fb58f5 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