[RFC,03/32] fgraph: Use BUILD_BUG_ON() to make sure we have structures divisible by long
Message ID | 169920042620.482486.2035922638334412424.stgit@devnote2 |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp2196351vqu; Sun, 5 Nov 2023 08:08:00 -0800 (PST) X-Google-Smtp-Source: AGHT+IFiSTjjRSwUUtc7QFzBnZ5X9Ab2W/wU9XKRWBMBcMaV48gmpUrCHw+Mbdz93HVivxltStOo X-Received: by 2002:a05:6358:881f:b0:169:81e:b6e0 with SMTP id hv31-20020a056358881f00b00169081eb6e0mr34467704rwb.24.1699200479942; Sun, 05 Nov 2023 08:07:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699200479; cv=none; d=google.com; s=arc-20160816; b=IpK00y+QgzrsR3YsZn81UIH5FkAUE2/haM5gxTiXqDOkV+1eZjoOClLNXF/c4SXLh4 dUPRim8TToKBg3xUjxThUTy2SjgjmR2R5Gq4n6hY73YAXgfSfc8RWb5JBkWIgH5ScskB a4Qj2ttnVV7bnjmgP76Kjp6WlE6BDZQ1xvf6Aac3Wxz3szbKbG73b7QnFKWrlXr8BcUc w1GLW3dh9Ur3hqNK/Miu4CvkbogarNjSRaICxM+lhZp0k3ikfTQ6GwyBoGrPEK79vn/u Lf8dxsm3zgWoegeACQIyqDTJVcuiSCHsduq1Mg6nwN7cpOSMdMIOtHUoYzISCSe4j0mN BayQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=OESyYZVxbmArs5V4zMGrIL0/uPgjACK9BAVI1aKMbU0=; fh=SIgps5XdV0XNwjZfT2uAI7g3mrspDldK9Qs8qQAfoa4=; b=PYB67YagvjiC6L5HXZuQduJ9qMIQPOEHKR/f5ZbDSYHv80ZOWhnTJowo3NEyYgQKFh Oj5i+m4XD6vPqAiRXhH4kowAf6iDRkLy5CjsKfBqSJKrkgdeu+QFVGfLslEYhp5nPG35 LoE7FWQnE0BYnks74MH2lgnX8WF5zdejdaAHzrWcSAzSAYQTi4WjQU1BGbTS+Hd+9jeh Jj3kXx1kWPhLhae2XI6+Aqoi2YOTkwufHrtjYk1R+RTHRG3Mqsbt1jWyFX6448WrFdZJ yg5G9XcROdKyyjqBAQxUwk+nxNB9sqq6rpQ2H8YokMZPpR2giH7rxWShYS6LSleWXJzn 0Mbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=dyF6zqhC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id q184-20020a632ac1000000b005b7dd1e334csi6052344pgq.601.2023.11.05.08.07.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Nov 2023 08:07:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=dyF6zqhC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 1CFF180545B5; Sun, 5 Nov 2023 08:07:50 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229637AbjKEQHU (ORCPT <rfc822;heyuhang3455@gmail.com> + 34 others); Sun, 5 Nov 2023 11:07:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53886 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229698AbjKEQHQ (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sun, 5 Nov 2023 11:07:16 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A27131B2 for <linux-kernel@vger.kernel.org>; Sun, 5 Nov 2023 08:07:13 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 263A0C433C8; Sun, 5 Nov 2023 16:07:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1699200433; bh=BJTb9S/48BMXgKg9JdebJFjIf4uCQaHDkO4DGbu+/d0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dyF6zqhCWxd07sdjAl8Mrzwr5pVkixS3gZKjnp0JhrnrLFhKeNzHfqhRUBW2qRj4D la81PR8h5F2034JRrNmOstiPEzOMAKF5LExKlV3vlJE2e1XFjzt6aP/4vcQSdunlm9 yxX6zJ2ylc27phnsYa7WwfcJfR3fsb58GrB8rJRnrtjRhGFH3YxJrdxkD0mKvxJXSc US3GXWMKaYMAClk0Sfy010l4pMEXaoOnyo2hUvrNlzBzZ/v+DiBEsPEKpC2blHq1hA 1uc5iuL3zDROJ4+WWfk8ccymhSQgvX+AzZaGHxWyzJZidF+0auyTegwnwwfaevPPBg KF3Fj186CGthw== 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: [RFC PATCH 03/32] fgraph: Use BUILD_BUG_ON() to make sure we have structures divisible by long Date: Mon, 6 Nov 2023 01:07:06 +0900 Message-Id: <169920042620.482486.2035922638334412424.stgit@devnote2> X-Mailer: git-send-email 2.34.1 In-Reply-To: <169920038849.482486.15796387219966662967.stgit@devnote2> References: <169920038849.482486.15796387219966662967.stgit@devnote2> User-Agent: StGit/0.19 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Sun, 05 Nov 2023 08:07:50 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781740842261569774 X-GMAIL-MSGID: 1781740842261569774 |
Series |
tracing: fprobe: function_graph: Multi-function graph and fprobe on fgraph
|
|
Commit Message
Masami Hiramatsu (Google)
Nov. 5, 2023, 4:07 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> --- 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;