[v3,05/33] fgraph: Use BUILD_BUG_ON() to make sure we have structures divisible by long
Message ID | 170109323585.343914.8827157689000519661.stgit@devnote2 |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce62:0:b0:403:3b70:6f57 with SMTP id o2csp3127776vqx; Mon, 27 Nov 2023 05:54:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IFLZeUE9q7qPlonEkVv8SM8Jex0hrowEtZCTovJvIccIc5/b9NQ8kE5o3oULPwf0V4OTTss X-Received: by 2002:a17:903:110e:b0:1cf:9e88:100d with SMTP id n14-20020a170903110e00b001cf9e88100dmr13782948plh.59.1701093270769; Mon, 27 Nov 2023 05:54:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701093270; cv=none; d=google.com; s=arc-20160816; b=QEQbMjGn69XKMKeOGWAVn1rVtBclpJlG8KoyQW2d/VqjK4YC8pG0kkHI1Q1XSj3nr/ /2UWA3N4VL+BsRixxZKDjAkIxaLa+JzGRKpldnR0ShClTpS/cPERIKAc6vmk8ltcRE+D 1RZ+nxpVlCmevNMzvCyPW4eSLLXuAerVNKAXh0tdHc+HjKmmXwXtiKRQR5LmphksRB0H KHHZkUBXDpILEaA70CKGJFjnnTJ6BCZ8nXfT0KabFrVH1PUh3gt86jK1cGf5K1qbosd5 OzHvJne4izVt0V3F2yZd6JZm3wrua/SM0s9Y7goAqMntUYfpT4Bofq8AtEJnBk3c8F6T UKGA== 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=umHH1zdlv6simvMW1SeaVnT0NYlxNpawWdolOgZQR5CYPH2N4jTwXdQ4UjNkq3kU2p ZRsxwMd4wpFa0gCeir5rTcrwLhDUT77YnV7UcO3slKayfihRx2NnsGX27BOqUlpc1fDO D7qsB2Ol80ElM5suKj+Om5/AT9slSUMBUG5DF5MGT7k0ykY9MhEt76sn/h18CbuODOMI alr7RVqc5HjGjLb60cOKTv/akoUcvJEctiGOXbdUwTppbHOZe8cpAq7KVNkIH6LOBi5k iUhuioKPDW+OIamXwzUwJy5Edr37V5+wVxgshCAhtR2p+VjSqa6PUtdcVxjVjNFdEaLr oiGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GYUOOnwv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id h14-20020a63c00e000000b005b834096959si9847895pgg.851.2023.11.27.05.54.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Nov 2023 05:54:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GYUOOnwv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (Postfix) with ESMTP id 87F2B8094D56; Mon, 27 Nov 2023 05:54:22 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233392AbjK0NyG (ORCPT <rfc822;toshivichauhan@gmail.com> + 99 others); Mon, 27 Nov 2023 08:54:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44920 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233300AbjK0Nx5 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 27 Nov 2023 08:53:57 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5063F136 for <linux-kernel@vger.kernel.org>; Mon, 27 Nov 2023 05:54:03 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1D003C433CA; Mon, 27 Nov 2023 13:53:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701093242; bh=BJTb9S/48BMXgKg9JdebJFjIf4uCQaHDkO4DGbu+/d0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GYUOOnwvQwsNlxSNuewCevm+q5XiHdJpOfdaSmMN+SXiZXPA0yXdYnswPHthV9OJ4 JWBFYOgT8yMoFGbfKTKWNFudYzy/VhLwKXMNYuJOs2xiqW2i0GHesk4ftCGA42hC+s sGcLQk4JU8qlQcd5e7qtQlNs3N4pxxBRldmtfsJnCtJipJS04rFhshaGrH9uCSMvol subLIaiFHSNXNaFX9EnViMCbyRJ81TfNSB2wgpxqA4X5lQC2bUe8z6DCxj6/ixLGNc ukeLgFfVWLMw8KXT/voig76MqTg3d+3Z/jaLvW0Wu/VwtvF+hMIVB2M/TuDhKFPyWf jrOWe0WQcF8bw== 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 v3 05/33] fgraph: Use BUILD_BUG_ON() to make sure we have structures divisible by long Date: Mon, 27 Nov 2023 22:53:56 +0900 Message-Id: <170109323585.343914.8827157689000519661.stgit@devnote2> X-Mailer: git-send-email 2.34.1 In-Reply-To: <170109317214.343914.4784420430328654397.stgit@devnote2> References: <170109317214.343914.4784420430328654397.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.2 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 fry.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 (fry.vger.email [0.0.0.0]); Mon, 27 Nov 2023 05:54:22 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783725577269798034 X-GMAIL-MSGID: 1783725577269798034 |
Series |
tracing: fprobe: function_graph: Multi-function graph and fprobe on fgraph
|
|
Commit Message
Masami Hiramatsu (Google)
Nov. 27, 2023, 1:53 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;