Received: by 2002:a05:6500:1b41:b0:1fb:d597:ff75 with SMTP id cz1csp181114lqb; Tue, 4 Jun 2024 08:23:04 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXaP5k5pGUP+QiCn4ygJ2UY03RhrWu4RA7gdfsCA6xOLwCQbo7QvY5ETpF0dYji5dE6gkkqptoFidnF7cV0KtfgI2IZtMcFX/dbjGSJLQ== X-Google-Smtp-Source: AGHT+IFP8weIQ/Tb0P2H8w8GrzF/k3Ft3Py5AvK7gevV2X/Q9ymmllCoykkzxEpVVn3NDcaTbkWn X-Received: by 2002:ac2:5b5d:0:b0:51d:68fb:5d73 with SMTP id 2adb3069b0e04-52b8956932dmr8524084e87.8.1717514584127; Tue, 04 Jun 2024 08:23:04 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717514584; cv=pass; d=google.com; s=arc-20160816; b=v3QifNA0Z+o7MlxCiP2ZBC9UVD+hLmM9pdLuZJ7znTW3yfdc327XH6PPAmha830qe7 pLKGQ9FMm8I62Z+nBj+QP5uU9sVNt2UCLU5Yp8S78HO7kL8g9fUcbJQmf+DhOC6GD8Zd 2Dvt86wQaU2zi0ZO0Qns9mUdlR1ikDSwqMXkR0BSISnh3plpsNGMVBuXocwhdNjOSQSU 6kt9uzom6Ay6ubUwbRkoozpgMfkher6Z7Fn6yy/AoxkV1OK2nlzzyo6wQOF83Pu2PyMJ 0r592NZXgJQEYcpow6sc8ToEN8QsP8+gksbqjO664Mi4Wj8l6cAos1+m64yi4M6DzfeJ fQag== 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=fCoq//lS4cx+1hsDeNJ8NkXOwnWmXLZnyX8PSiHATjc=; fh=/wy5e/q+z2qlOMkv0QH/u80KV4ZXPtz68q6c1OyjqGY=; b=MpjzGl2S4DBIY7Qt/IJRBNbllLVwA1sWkE9ZiQGFm9FCufgrGNwQFsqTT/Nu98fgBN M3g526YnmginrQBaDkxvKTJdtkVNU+8kpakmZmCUdvliXTClNq6FaPqsrZlrl4ZjeCxw 7DHK18vWamQOSoBrhm/P+5E4a9Cj4UJrYe1ocdE/xw2hMElCRvdtL++uy7IGLp1B+BYF Dh0xRSA81DovDN9Oyz9SGeELsVJbA+xpgpyuYwl4Z9NCsHUKvEs0V5P9bu4pAcOXq3L1 o7pLVyAQjeDvYVgon4s2NfMA8zqrn7CBI/q8pWi3003IYO1JH3QMDczpQphRXykipif7 KalQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-200880-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-200880-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 4fb4d7f45d1cf-57a31ba711bsi5309429a12.154.2024.06.04.08.23.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 08:23:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-200880-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-200880-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-200880-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 0367E1F26A30 for ; Tue, 4 Jun 2024 14:47:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5638D14C5A3; Tue, 4 Jun 2024 14:42:22 +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 1995D149DFB; Tue, 4 Jun 2024 14:42:17 +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=1717512138; cv=none; b=asEH62RJRfZrMMJiulLVx+ijM0VXh6lMd9a34fLLDSqkNNrJpRlaWGKCMyzKaZ25Csfu9k693VQNeY6/SKixBP/OPy/iPcgjO8BkN+IDvRlO4mhP5lpM1Fs0KZr8yCVelq+r6QfaYaqzUk5/QlHvlhWD+Oxm4BWB8Nv+xdG4Jmw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717512138; c=relaxed/simple; bh=LLcOXWIJvLc0UoG5r0ma9bX/oC7gcdfyq7ld+y9LUoM=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=ROmvcfst9V0bkaFTv9RynZTQJLkQ61Dj/WrH7Eb+Xtl4Rbm/BelSGA2/lm/UjnAtfXNuOfGukmdz/C1mmSjo7nEvZMSGBRSVnvu94IGGTjEoV4XPNH6qWw55p4aS/PSXZmqbaoyD0RFgskyVfA/7G7aCB9GuI7xPYaDsovMFUTw= 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 9C233C4AF08; Tue, 4 Jun 2024 14:42:17 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.97) (envelope-from ) id 1sEVMf-00000000Z20-03Vc; Tue, 04 Jun 2024 10:42:17 -0400 Message-ID: <20240604144216.873024321@goodmis.org> User-Agent: quilt/0.68 Date: Tue, 04 Jun 2024 10:41:21 -0400 From: Steven Rostedt To: linux-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: [for-next][PATCH 18/27] function_graph: Move graph notrace bit to shadow stack global var References: <20240604144103.293353991@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 Link: https://lore.kernel.org/linux-trace-kernel/20240603190823.796709456@goodmis.org Cc: Mark Rutland Cc: Mathieu Desnoyers Cc: Andrew Morton Cc: Alexei Starovoitov Cc: Florent Revest Cc: Martin KaFai Lau Cc: bpf Cc: Sven Schnelle Cc: Alexei Starovoitov Cc: Jiri Olsa Cc: Arnaldo Carvalho de Melo Cc: Daniel Borkmann Cc: Alan Maguire Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: Guo Ren Reviewed-by: Masami Hiramatsu (Google) 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