Received: by 2002:ab2:69cc:0:b0:1f4:be93:e15a with SMTP id n12csp1416507lqp; Mon, 15 Apr 2024 06:10:19 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV7pR7elTu6TRzQkFpeC6T3C3ATKUwCBoiL+HUmTmmLG+5YFsti9gl8XqlN8DTFBvrPdam/Bt0crAkfAPY3DQ8QBDd20spbwKBvFgDwmw== X-Google-Smtp-Source: AGHT+IFGztEDjxOtI1ijbe8X/UfOjkwlBnSNoDmEAl94Tis9vUtDWFWNbmrFzB6Z2V/th6gGz5AW X-Received: by 2002:a17:906:1395:b0:a51:9911:eba8 with SMTP id f21-20020a170906139500b00a519911eba8mr6370899ejc.4.1713186618864; Mon, 15 Apr 2024 06:10:18 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713186618; cv=pass; d=google.com; s=arc-20160816; b=Z/JxYyZcedwiCftCDwGdQPJSiZoXjp9QArcd3A4ljsQNvhlUNe47Ea48q2nIkonSCM jBdbKnIIKQiDIWK4DjZReyiGtycnvReDPOVfeU63AY69BWthjL36HBNNdbYT66ZcTJwA zAYJ+T2c+Qalv61u63H3QrarqDsG0B674wfrH0lrN3gk/tBeR/tK42bI5/eqvTWGMpYx RpxS3ngw3erbCg/rP97YM0FNPNi/O5mlkbG7J/DZ4qbffQ+sVtl5GQ1x6L3RWrR4Nv10 8zcwzkH7G6eltDIlNt3iPQVwVM8JFMjeCVlyoNsSk5o8TMfUxE1UJ9By4PvHFSO+vtJo YRkQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:user-agent:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=AVIjzQKvMSZYTFTlRB7H0AahqU2zKSlprqc6gVtKQxw=; fh=SIgps5XdV0XNwjZfT2uAI7g3mrspDldK9Qs8qQAfoa4=; b=fbOvz3tmAxgZeUJ3Pl/MBGgFab+xm0owV2UHr8a1iNsqnusLJQO3IptIpwSUI2B01z kicXap3LjtKKRR5rsyUfJrapS3ccDUh4X7vtJ8JDw2VGvxNaPLh2jWWE1oMXxVt+z5id dEp//+a6LSVStz57mpCxBbGK8IC0EVTyhRDVzDbi8GTza/4zSrQ1KReRgsa+mN/cbmyA i30ccCb+9/pmhFKKDybABzZ9Cbx/6P7poN/VRwZ0zA+dDFlDh2/DRH5smOwD1xlxVe8s ylJQVKSvDYY8/7UGA6yikSUMmnHhrUpQCcWZNaELUViEw3Qc55GtdjaWl0zMeQ1j8HcK 2ChQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=oD56PMCZ; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-145180-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-145180-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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 qk9-20020a1709077f8900b00a52222e6ab6si4788115ejc.675.2024.04.15.06.10.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Apr 2024 06:10:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-145180-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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=oD56PMCZ; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-145180-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-145180-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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 981221F2265C for ; Mon, 15 Apr 2024 13:10:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8D2307F48E; Mon, 15 Apr 2024 12:52:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="oD56PMCZ" 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 AF7BE13A416; Mon, 15 Apr 2024 12:52: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=1713185546; cv=none; b=Em2BFTl7R/8iNQOKk+VGGw1kc0QRhfDj1Y8jhrVVxKmiZf0H001uEoCrXXtejXSIkY6FssErSc3/DOTKONZAUwe5JA/kQodcAYCOEjXRxveEicnH+zzE1KF2fGyiZimVzxsNY6LuX6hT/nB6mqj6QTfPHogeBg9gsku2XEgISV8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713185546; c=relaxed/simple; bh=Y/PRuTVTDsTQKjlNKmV/fXBRExnJ4PMXhavO2F97Z3U=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=aHS08kk4arhALDSax21Z44qVRuqQZFi7wjgjX/iICSFpPjIpu5ZYz2dFXaWSW2oDusRnkCDJHsBI940JW9/LYYGf3LJUAuBp8bD6XTsjZWDNnJ0h/iZ+Ax6El3m4/QdG68SQP/O43u8k/rPTNbfTDrAPtEcevOztudUIZpGoOi4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=oD56PMCZ; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 545BDC113CC; Mon, 15 Apr 2024 12:52:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713185546; bh=Y/PRuTVTDsTQKjlNKmV/fXBRExnJ4PMXhavO2F97Z3U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oD56PMCZhD9tU6il6jcJah5Es2EmHquK77sLIVP7Tog/hGpaevi/u/tBwyqwBX81p mw+Ef4Z2SYLjR8BorHAvEK4D2LRiidDp7IoSFN8sfYvorXkFHvTB783f4w++h9KJ7o ijWtR5goER376Pb5ZMbrdbGZWP9CNhMF97JwyQ5ZdYnGrruxDzaSYEDvHYE0pZ78Vj 6kVXdSk6bAwUqNbnsgHbwzlmgo+XpLgUloQCFhWGb47Zikl6HS49zRVjLMXjDXuk2n h9IAqLZuIiZW3LdXSx9s4wiAPB8KNiPo8eJrpPFvw007hugJ1Y3AbTNdP/pVMA34DC t6Sj9gIXemskQ== From: "Masami Hiramatsu (Google)" To: Alexei Starovoitov , Steven Rostedt , Florent Revest Cc: linux-trace-kernel@vger.kernel.org, LKML , Martin KaFai Lau , bpf , Sven Schnelle , Alexei Starovoitov , Jiri Olsa , Arnaldo Carvalho de Melo , Daniel Borkmann , Alan Maguire , Mark Rutland , Peter Zijlstra , Thomas Gleixner , Guo Ren Subject: [PATCH v9 17/36] function_graph: Move graph notrace bit to shadow stack global var Date: Mon, 15 Apr 2024 21:52:18 +0900 Message-Id: <171318553846.254850.6044633509757665191.stgit@devnote2> X-Mailer: git-send-email 2.34.1 In-Reply-To: <171318533841.254850.15841395205784342850.stgit@devnote2> References: <171318533841.254850.15841395205784342850.stgit@devnote2> User-Agent: StGit/0.19 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" Content-Transfer-Encoding: 8bit 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. Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Masami Hiramatsu (Google) --- Changes in v2: - Make description lines shorter than 76 chars. --- 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 00e792bf148d..cc11b0e9d220 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 7ab731b9ebc8..f23b6fbd547d 100644 --- a/kernel/trace/trace.h +++ b/kernel/trace/trace.h @@ -918,8 +918,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; }