From: Mark Rutland <mark.rutland@arm.com>
To: Arnd Bergmann <arnd@kernel.org>
Cc: Steven Rostedt <rostedt@goodmis.org>,
Masami Hiramatsu <mhiramat@kernel.org>,
Arnd Bergmann <arnd@arndb.de>,
linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org
Subject: Re: [PATCH] ftrace: sample: avoid open-coded 64-bit division
Date: Mon, 30 Jan 2023 13:07:32 +0000 [thread overview]
Message-ID: <Y9fBFKeJ1zMBtv4b@FVFF77S0Q05N> (raw)
In-Reply-To: <20230130130246.247537-1-arnd@kernel.org>
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
>
prev parent reply other threads:[~2023-01-30 13:07 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-30 13:02 [PATCH] ftrace: sample: avoid open-coded 64-bit division Arnd Bergmann
2023-01-30 13:07 ` Mark Rutland [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Y9fBFKeJ1zMBtv4b@FVFF77S0Q05N \
--to=mark.rutland@arm.com \
--cc=arnd@arndb.de \
--cc=arnd@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mhiramat@kernel.org \
--cc=rostedt@goodmis.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox