[v8,05/35] fgraph: Use BUILD_BUG_ON() to make sure we have structures divisible by long
Message ID | 170887415852.564249.2786094184227554396.stgit@devnote2 |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-80133-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp1620019dyb; Sun, 25 Feb 2024 07:16:36 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCW7TP89ZO2hyTdflBijzIbCyO4yYXQ45G0ZFt9tnhfJBQKw+VXdNniAk4IgExLLFe3f6+FgCUhVx4UZ+ivzgiPEEcaGnQ== X-Google-Smtp-Source: AGHT+IEZw+Xu+9o3mX/FqZhKZfgTYV/+WScBGaYaCu5PDJ540WhvdK/OvQpOp0ywXkzypVMlxiKf X-Received: by 2002:a17:902:6e16:b0:1dc:82bc:c073 with SMTP id u22-20020a1709026e1600b001dc82bcc073mr3505880plk.41.1708874196607; Sun, 25 Feb 2024 07:16:36 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708874196; cv=pass; d=google.com; s=arc-20160816; b=wHGDdfFEK4DK62ncxz8PBvL1ybBdqlWobqSoG3SSRKWut6RYqIj296L90C4929bGbe g1azd+psibiCXQ54zQwXnjSeCnZB/9+8e6KmRTeN/2Ryr6q54LZ3jEuuJ7Y+NBCRWZPg NnmrhqbkAPhXLpNimzyPHb+L1S6XNUJz4AkI5IC2uDMk6vOP3L3Ra02kxptsU/VufCxJ 7/phRGd787H2Nilxra9lCep72yzAzRdKwC9cRZCUc0ZfEVfNG/vPzWjbgouuwPJ7YPZI 86jgMO223U1/TR/Xhh4aH9fNL5t2pE14Cy2886572aEppWWqqyrq83yjST/ucYKA7SAW CMQw== 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=eVgZgoy+UGwGEm8Va6QmNfArgtjudfTwfrDl+ut0Pgc=; fh=SIgps5XdV0XNwjZfT2uAI7g3mrspDldK9Qs8qQAfoa4=; b=XgpaG/2cBMMEkL6sr7tHewl5GCMru2/6PCxjNRu+bs9N6gKXRPeMFTbfhtlzoH0fhU ++OPIIMgjHB2x79Ai+J406ksBPqPIpIcNt/FhEVmnHwYIIGyUlkT3KrMLP1o5YWDzJzP D2saXf1F6+Pkc4Z81BGsb8FmksYkFjLaX03KYy839mbJd3hyEbQWIFOkOJf15BeZ6YRJ 3v0aw2mFNKFeoEsMAlYwya/2tEhhrZwCRkU5HdBqFKRyq4eoP0WubUdd4Riv2gaGXiMC iWD8MK1jWqBbGulgeRmKosILqUUhEty5DWT93y10zIPmLpKT1jiCuykfJr2JAlwa8pkO eAAg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=QXUre6XP; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-80133-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-80133-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id f10-20020a17090ab94a00b002990deb1ddcsi4063012pjw.171.2024.02.25.07.16.36 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Feb 2024 07:16:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-80133-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=QXUre6XP; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-80133-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-80133-ouuuleilei=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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 6E0A8280FB3 for <ouuuleilei@gmail.com>; Sun, 25 Feb 2024 15:16:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6715C175AD; Sun, 25 Feb 2024 15:16:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="QXUre6XP" 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 891DE17584; Sun, 25 Feb 2024 15:16:04 +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=1708874164; cv=none; b=pb109QV1tYtWFI1ErtA4epAIOjspzui8m3s3GTy+O7cN5QEtmWxMxR939iRrWOBTuNucq5r1EQ2lFl++iDn8/GPh2BSf1w5GHH3cyY9cZXKb/xQPEXJizCgi0+R/vJIcWrw2KP2m9tfV17XFZaOAVXMOYlE/D9CwaXHBzfN50Gk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708874164; c=relaxed/simple; bh=v6a8A4n/NQNVvl6IUBlyb4ncY6wKsPnocwxI4QmL7G4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=BakN5gHCdH485uw53Hf889SP5IP75ehbF0pgg8GfpZ4N59DusrxcRxyjwcH/cwroks/LnNi0Ik30PMJAqbYamb/0eYOKQ8/GpUvpHSjn8LXvhoctECdTDE4iO6TAN06FylLWMhCaqUY5+xB+LBmRcvFlcZ3+tUQW+VIzAIef7zs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=QXUre6XP; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0A726C433F1; Sun, 25 Feb 2024 15:16:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708874164; bh=v6a8A4n/NQNVvl6IUBlyb4ncY6wKsPnocwxI4QmL7G4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QXUre6XPnI81EY0m3S3EOLP0frJIY/XLwk1o9zu85FqVubANhpGRLbP+8LRtkUDA3 B+T+WELA9Im4wzVxFk8D21LxfwC4B4F0Ybvb+ETT+TZTpkfGjpnprUXJ0CC7kayJCX 0PnG/4q3ekl+BV9uxRlRM7h/8LyNOWb3DXg+AO1guxRQFzhfiDaFvBN6HlLVpodj+p swiKCvcV0NrAREvMEFAw9pod8guQZcnFMtes3sQhHBie/1zhj+64wp02iY//KCYa0A 2/dpUORGigM4M786knB2FshNDe9peTwwQxBWqpV2QVVMOhKVdl8sggwMZRXO8ZwttJ nF7OCM1eMMuQw== From: "Masami Hiramatsu (Google)" <mhiramat@kernel.org> To: Alexei Starovoitov <alexei.starovoitov@gmail.com>, Steven Rostedt <rostedt@goodmis.org>, Florent Revest <revest@chromium.org> Cc: linux-trace-kernel@vger.kernel.org, LKML <linux-kernel@vger.kernel.org>, Martin KaFai Lau <martin.lau@linux.dev>, bpf <bpf@vger.kernel.org>, Sven Schnelle <svens@linux.ibm.com>, Alexei Starovoitov <ast@kernel.org>, Jiri Olsa <jolsa@kernel.org>, Arnaldo Carvalho de Melo <acme@kernel.org>, Daniel Borkmann <daniel@iogearbox.net>, Alan Maguire <alan.maguire@oracle.com>, Mark Rutland <mark.rutland@arm.com>, Peter Zijlstra <peterz@infradead.org>, Thomas Gleixner <tglx@linutronix.de>, Guo Ren <guoren@kernel.org> Subject: [PATCH v8 05/35] fgraph: Use BUILD_BUG_ON() to make sure we have structures divisible by long Date: Mon, 26 Feb 2024 00:15:58 +0900 Message-Id: <170887415852.564249.2786094184227554396.stgit@devnote2> X-Mailer: git-send-email 2.34.1 In-Reply-To: <170887410337.564249.6360118840946697039.stgit@devnote2> References: <170887410337.564249.6360118840946697039.stgit@devnote2> User-Agent: StGit/0.19 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791884469614897353 X-GMAIL-MSGID: 1791884469614897353 |
Series |
tracing: fprobe: function_graph: Multi-function graph and fprobe on fgraph
|
|
Commit Message
Masami Hiramatsu (Google)
Feb. 25, 2024, 3:15 p.m. UTC
From: Steven Rostedt (VMware) <rostedt@goodmis.org> Instead of using "ALIGN()", use BUILD_BUG_ON() as the structures should always be divisible by sizeof(long). Link: http://lkml.kernel.org/r/20190524111144.GI2589@hirez.programming.kicks-ass.net Suggested-by: Peter Zijlstra <peterz@infradead.org> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org> Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org> --- Changes in v7: - Use DIV_ROUND_UP() to calculate FGRAPH_RET_INDEX --- kernel/trace/fgraph.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/kernel/trace/fgraph.c b/kernel/trace/fgraph.c index 30edeb6d4aa9..6f8d36370994 100644 --- a/kernel/trace/fgraph.c +++ b/kernel/trace/fgraph.c @@ -26,10 +26,9 @@ #endif #define FGRAPH_RET_SIZE sizeof(struct ftrace_ret_stack) -#define FGRAPH_RET_INDEX (ALIGN(FGRAPH_RET_SIZE, sizeof(long)) / sizeof(long)) +#define FGRAPH_RET_INDEX DIV_ROUND_UP(FGRAPH_RET_SIZE, sizeof(long)) #define SHADOW_STACK_SIZE (PAGE_SIZE) -#define SHADOW_STACK_INDEX \ - (ALIGN(SHADOW_STACK_SIZE, sizeof(long)) / sizeof(long)) +#define SHADOW_STACK_INDEX (SHADOW_STACK_SIZE / sizeof(long)) /* Leave on a buffer at the end */ #define SHADOW_STACK_MAX_INDEX (SHADOW_STACK_INDEX - FGRAPH_RET_INDEX) @@ -91,6 +90,8 @@ ftrace_push_return_trace(unsigned long ret, unsigned long func, if (!current->ret_stack) return -EBUSY; + BUILD_BUG_ON(SHADOW_STACK_SIZE % sizeof(long)); + /* * We must make sure the ret_stack is tested before we read * anything else. @@ -325,6 +326,8 @@ ftrace_graph_get_ret_stack(struct task_struct *task, int idx) { int index = task->curr_ret_stack; + BUILD_BUG_ON(FGRAPH_RET_SIZE % sizeof(long)); + index -= FGRAPH_RET_INDEX * (idx + 1); if (index < 0) return NULL;