Message ID | 20230130130246.247537-1-arnd@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2171498wrn; Mon, 30 Jan 2023 05:14:17 -0800 (PST) X-Google-Smtp-Source: AK7set+oq/LLgAROfAxdYwFYObVzFsZOUxRRyom9plw0Vi+p9Q/ekZKWcIssKDueqA/8fBerWx1T X-Received: by 2002:a62:f809:0:b0:593:1bab:1501 with SMTP id d9-20020a62f809000000b005931bab1501mr8026687pfh.7.1675084456885; Mon, 30 Jan 2023 05:14:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675084456; cv=none; d=google.com; s=arc-20160816; b=bbg2gXKfoifdm0htk1AR64x1fx76dvZvVNLQKbhISAUdEHesIh8WY6dupZ5vQjGXfH HLUyrUMIUUPW2ZoX6tLKZZbXYGhQjvEGWX+tpKCyHO9NUiflLYXKA/awbToKlB7Ln/DL R8erWLiGksTze/KAbYxY50zDmRSJvbP4pElQtwCXBi1PX9qZiYCakcDnpqVUms+eKInu bMIBkgnyUDlbywIO5sbbBjXzghMmKbGhpfXjZvNThCd/Lr2tHGy56yHnCV/WvEQnntw9 cjuWco0pjTnqf16UlQR4u0wv3/Ne/mkrL064K626XJWhOSuhd2woQa2+0/vSpKyvkQWB o0Mw== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=So7XKgM4L8UbgRfubvJ2YoE6SAfO5vzT8Ebw9m28zx0=; b=NyRRcLSeY4Sbgk3mKlJSstlcOiwF0Jbte/K+WoFU1CqOQOC/qOikuRs9Y0d4Gnn/+0 1qa1ErNnZDb3ZzLb/QXsaG5US9eCv9zBPDi3rZfMoWF14oBHeT4BbW5maEOKud2Tfwu1 4+7QVi1UJE9KZilKRLmlHGGPuDFwBzd3cJqkcAgPQo+2rb+hU60fF9YlNCdiLSv0Ht75 4Qn9+gdPAu4O/Fz9SUosGCXU3cOoQhqXBD+OvPTbxYaw4+f9RFniOWg2PjKJKFzZYXWV o6amIFAGKbvkMvFebFLmidG9LbOU00PBCJ0oewVbYz23lI6VkYfEC1rjFA9u5MfC6Htg aPyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=bBjjiDc5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p129-20020a625b87000000b0058003199fbbsi11454917pfb.63.2023.01.30.05.14.04; Mon, 30 Jan 2023 05:14:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=bBjjiDc5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236701AbjA3NDE (ORCPT <rfc822;n2h9z4@gmail.com> + 99 others); Mon, 30 Jan 2023 08:03:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234538AbjA3NDC (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 30 Jan 2023 08:03:02 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9FF4335AF; Mon, 30 Jan 2023 05:02:58 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 1BF4160F17; Mon, 30 Jan 2023 13:02:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0D57CC433EF; Mon, 30 Jan 2023 13:02:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675083777; bh=VxL2bjQW8m7T81W4f7nNF2r5l8IfbO/VL9g3wOK2I8c=; h=From:To:Cc:Subject:Date:From; b=bBjjiDc5M9JcXGIWoEMxouNwg1+oguZkfgDvk1SHnjyOV/QXs3x5/yoCkriIXVY1b mY9LL7rtYez19AM8yUawIYJjxfxluvA7Nq1SMpN7WWj7XF2SVZVYhMJMYmXUy/0YyM vOe/UYjg/CBhA5L6O04cFjoZ8bQ2vz6pK4CSUVPMYO37yIw+TupFEGUcuOlUNW1EQ5 JWgqKqiwfJT3bu0kPoNTB8uzcXOcoKPYD26fvt80lbBm59Ev6N3dAIZXlv55RNaBNb Q+6fKMp+43xPF5QXQfkxNQ+RrzTYemgobX31a0x66W7tdgYvO63cforYoeRHw9LvCl XcrweCX7TlrXg== From: Arnd Bergmann <arnd@kernel.org> To: Steven Rostedt <rostedt@goodmis.org>, Masami Hiramatsu <mhiramat@kernel.org>, Mark Rutland <mark.rutland@arm.com> Cc: Arnd Bergmann <arnd@arndb.de>, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org Subject: [PATCH] ftrace: sample: avoid open-coded 64-bit division Date: Mon, 30 Jan 2023 14:02:37 +0100 Message-Id: <20230130130246.247537-1-arnd@kernel.org> X-Mailer: git-send-email 2.39.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756453359232932128?= X-GMAIL-MSGID: =?utf-8?q?1756453359232932128?= |
Series |
ftrace: sample: avoid open-coded 64-bit division
|
|
Commit Message
Arnd Bergmann
Jan. 30, 2023, 1:02 p.m. UTC
From: Arnd Bergmann <arnd@arndb.de> Calculating the average period requires a 64-bit division that leads to a link failure on 32-bit architectures: x86_64-linux-ld: samples/ftrace/ftrace-ops.o: in function `ftrace_ops_sample_init': ftrace-ops.c:(.init.text+0x23b): undefined reference to `__udivdi3' Use the div_u64() helper to do this instead. Since this is an init function that is not called frequently, the runtime overhead is going to be acceptable. Fixes: b56c68f705ca ("ftrace: Add sample with custom ops") Signed-off-by: Arnd Bergmann <arnd@arndb.de> --- samples/ftrace/ftrace-ops.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On Mon, Jan 30, 2023 at 02:02:37PM +0100, Arnd Bergmann wrote: > From: Arnd Bergmann <arnd@arndb.de> > > Calculating the average period requires a 64-bit division that leads > to a link failure on 32-bit architectures: > > x86_64-linux-ld: samples/ftrace/ftrace-ops.o: in function `ftrace_ops_sample_init': > ftrace-ops.c:(.init.text+0x23b): undefined reference to `__udivdi3' Whoops; sorry about that. > Use the div_u64() helper to do this instead. Since this is an init function that > is not called frequently, the runtime overhead is going to be acceptable. > > Fixes: b56c68f705ca ("ftrace: Add sample with custom ops") > Signed-off-by: Arnd Bergmann <arnd@arndb.de> Acked-by: Mark Rutland <mark.rutland@arm.com> Mark. > --- > samples/ftrace/ftrace-ops.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/samples/ftrace/ftrace-ops.c b/samples/ftrace/ftrace-ops.c > index 24deb51c7261..0c8da87ff5c3 100644 > --- a/samples/ftrace/ftrace-ops.c > +++ b/samples/ftrace/ftrace-ops.c > @@ -223,7 +223,7 @@ static int __init ftrace_ops_sample_init(void) > > pr_info("Attempted %u calls to %ps in %lluns (%lluns / call)\n", > nr_function_calls, tracee_relevant, > - period, period / nr_function_calls); > + period, div_u64(period, nr_function_calls)); > > if (persist) > return 0; > -- > 2.39.0 >
diff --git a/samples/ftrace/ftrace-ops.c b/samples/ftrace/ftrace-ops.c index 24deb51c7261..0c8da87ff5c3 100644 --- a/samples/ftrace/ftrace-ops.c +++ b/samples/ftrace/ftrace-ops.c @@ -223,7 +223,7 @@ static int __init ftrace_ops_sample_init(void) pr_info("Attempted %u calls to %ps in %lluns (%lluns / call)\n", nr_function_calls, tracee_relevant, - period, period / nr_function_calls); + period, div_u64(period, nr_function_calls)); if (persist) return 0;