[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240216164007.2de685ce5c78cee69e168601@kernel.org>
Date: Fri, 16 Feb 2024 16:40:07 +0900
From: Masami Hiramatsu (Google) <mhiramat@...nel.org>
To: Steven Rostedt <rostedt@...dmis.org>
Cc: Alexei Starovoitov <alexei.starovoitov@...il.com>, Florent Revest
<revest@...omium.org>, linux-trace-kernel@...r.kernel.org, LKML
<linux-kernel@...r.kernel.org>, Martin KaFai Lau <martin.lau@...ux.dev>,
bpf <bpf@...r.kernel.org>, Sven Schnelle <svens@...ux.ibm.com>, Alexei
Starovoitov <ast@...nel.org>, Jiri Olsa <jolsa@...nel.org>, Arnaldo
Carvalho de Melo <acme@...nel.org>, Daniel Borkmann <daniel@...earbox.net>,
Alan Maguire <alan.maguire@...cle.com>, Mark Rutland
<mark.rutland@....com>, Peter Zijlstra <peterz@...radead.org>, Thomas
Gleixner <tglx@...utronix.de>, Guo Ren <guoren@...nel.org>
Subject: Re: [PATCH v7 19/36] function_graph: Implement
fgraph_reserve_data() and fgraph_retrieve_data()
On Wed, 14 Feb 2024 18:54:07 -0500
Steven Rostedt <rostedt@...dmis.org> wrote:
> On Thu, 15 Feb 2024 08:45:52 +0900
> Masami Hiramatsu (Google) <mhiramat@...nel.org> wrote:
>
> > > Hmm, the above is a fast path. I wonder if we should add a patch to make that into:
> > >
> > > if (unlikely(size_bytes & (sizeof(long) - 1)))
> > > data_size = DIV_ROUND_UP(size_bytes, sizeof(long));
> > > else
> > > data_size = size_bytes >> (sizeof(long) == 4 ? 2 : 3);
> > >
> > > to keep from doing the division.
> >
> > OK, I thought DIV_ROUND_UP was not much cost. Since sizeof(long) is
> > fixed 4 or 8, so
> >
> > data_size = (size_bytes + sizeof(long) - 1) >> BITS_PER_LONG;
> >
> > will this work?
>
> No, because BITS_PER_LONG is 32 or 64 ;-)
Oops indeed.
>
> But this should;
>
> data_size = (size_bytes + sizeof(long) - 1) >> (sizeof(long) == 4 ? 2 : 3);
>
> As sizeof(long) is a constant, that conditional expression will be hard
> coded into either 2 or 3 by the compiler.
Yeah. OK, let me update it.
Thank you,
>
> -- Steve
--
Masami Hiramatsu (Google) <mhiramat@...nel.org>
Powered by blists - more mailing lists