[v6,06/36] fgraph: Use BUILD_BUG_ON() to make sure we have structures divisible by long
Message ID | 170505432176.459169.10224406939710504027.stgit@devnote2 |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-24552-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2614:b0:101:6a76:bbe3 with SMTP id mm20csp75796dyc; Fri, 12 Jan 2024 02:13:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IFI3R9lBvtxclyPc85GbQw1CFQ+pvwQtof5rQUvD90u7v6b6AUhWhIv+heaj7iVOmC1u1LD X-Received: by 2002:a17:906:3943:b0:a26:ee0d:1c02 with SMTP id g3-20020a170906394300b00a26ee0d1c02mr296161eje.39.1705054420859; Fri, 12 Jan 2024 02:13:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705054420; cv=none; d=google.com; s=arc-20160816; b=ZUwtozo27ys/Wp6xmRJWwV1i6Sm3LgfrX18besKP7YKknKfRdSsRvOYZJ6UTHVD4rv Pf8USzX9+VLTFwLrkVU1eQf5R/9krxE8QRVX9oPPooWYW0+NHF0smCXR9bwtQzKOW9Fx 6lb+4KDl5Ul5LAIIiV6KbaqhfR5+69Vp7KCZPmyhjciu6DkPsrmpaaDpHUGa+A42XIs/ /RaSwXolHUJgP81/DCnGXqAUBn/LwtQwVyjJS8Z5NMam6F0u6JJnSUFQ8ikEBVaR1fk7 exNR1xy5Um2WSX3Uoar1EluP3Z3K+HAV22yuST3vdWpNmgnF0JC9fZVq+A7HrgxPB1Tq TbCw== ARC-Message-Signature: i=1; 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=OESyYZVxbmArs5V4zMGrIL0/uPgjACK9BAVI1aKMbU0=; fh=SIgps5XdV0XNwjZfT2uAI7g3mrspDldK9Qs8qQAfoa4=; b=KqKaTMVZSdhvPPCpJKf4Uke4Yqsp3KVdeoVgdoQGvCS/YbtS4t47cGQR02oKficM2I V72XjXeCzBSesPFF+Z/6p68WRFzuLjYT9BeVUibR3lVfdCRQVKVN4smjOs8W4UcKrby4 RoWPlWtk7FaJoibca6MIhZVSWX9SAhfUYyHpiMOn9rJly9bwjCxPqdf0sk/1K1z6hdNQ iFFQt2waKT/MOiOXQfCAPaKRSNRyar3qp6EHM/LTkCahWoLJV8swxVH1pk2Y07XKXxQB c9v4Edz6Qo7WnL1CoJOThTq/UGPIEc3mgb6H+1keRW32KpldsTQXD3EgxobDmlS1xyQq Ru+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="FNHbNiB/"; spf=pass (google.com: domain of linux-kernel+bounces-24552-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-24552-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id lr21-20020a170906fb9500b00a28cf59203bsi1220582ejb.62.2024.01.12.02.13.40 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Jan 2024 02:13:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-24552-ouuuleilei=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="FNHbNiB/"; spf=pass (google.com: domain of linux-kernel+bounces-24552-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-24552-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 722A01F268E2 for <ouuuleilei@gmail.com>; Fri, 12 Jan 2024 10:13:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6594B5FF1D; Fri, 12 Jan 2024 10:12:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="FNHbNiB/" 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 C07B85FF0D; Fri, 12 Jan 2024 10:12:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2C9E9C433C7; Fri, 12 Jan 2024 10:12:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705054327; bh=BJTb9S/48BMXgKg9JdebJFjIf4uCQaHDkO4DGbu+/d0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FNHbNiB/xSg/7ehU4MKZbWNtREQbJVpwYTkt3lrjrf9jZ/RGJgfpwJYwNNGQQz0tv OcBZQpGkcvYEDgRzYy7m/aYTaSC2aCJbQmy/Fu17w12A3t01/lcABpnPXCN8/u82Ld fK/gfmREyDHlo6WpgUbIRTTcFRZK39T4IQ6hI+Iw+2Lcc1oKpDOZR0Q6OMinpglSmA efv2X9NjXZ5HOUZZzrPrU1iiq2TXs7j+YGVydXLAKXnzP6bs40mAYqRa+e/pa2wTDG O+RftnN4z83jMnNxuw5cGMrZbcW3I/C1B44oMNOPLYRre/Z7cuNKOARteHrRm0wxSf csl00e7pnRNGA== 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 v6 06/36] fgraph: Use BUILD_BUG_ON() to make sure we have structures divisible by long Date: Fri, 12 Jan 2024 19:12:01 +0900 Message-Id: <170505432176.459169.10224406939710504027.stgit@devnote2> X-Mailer: git-send-email 2.34.1 In-Reply-To: <170505424954.459169.10630626365737237288.stgit@devnote2> References: <170505424954.459169.10630626365737237288.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: 1787879144337639275 X-GMAIL-MSGID: 1787879144337639275 |
Series |
tracing: fprobe: function_graph: Multi-function graph and fprobe on fgraph
|
|
Commit Message
Masami Hiramatsu (Google)
Jan. 12, 2024, 10:12 a.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> --- 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..837daf929d2a 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 (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;