lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240214185407.767243b4@gandalf.local.home>
Date: Wed, 14 Feb 2024 18:54:07 -0500
From: Steven Rostedt <rostedt@...dmis.org>
To: "Masami Hiramatsu (Google)" <mhiramat@...nel.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 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 ;-)

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.

-- Steve

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ