linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] perf-probe: no need to initialize the entire temporary buffers in synthesize_perf_probe_point()
@ 2010-12-23 15:27 Franck Bui-Huu
  2010-12-24  4:46 ` Masami Hiramatsu
  0 siblings, 1 reply; 5+ messages in thread
From: Franck Bui-Huu @ 2010-12-23 15:27 UTC (permalink / raw)
  To: Masami Hiramatsu; +Cc: Arnaldo Carvalho de Melo, linux-kernel

From: Franck Bui-Huu <fbuihuu@gmail.com>

This patches only put a single null byte at the beginning of each
temporary buffers line[], offs[], file[] instead of filling their full
contents with null bytes.

Signed-off-by: Franck Bui-Huu <fbuihuu@gmail.com>
---
 tools/perf/util/probe-event.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index adc2620..e453f13 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -1058,9 +1058,11 @@ error:
 static char *synthesize_perf_probe_point(struct perf_probe_point *pp)
 {
 	char *buf, *tmp;
-	char offs[32] = "", line[32] = "", file[32] = "";
+	char offs[32], line[32], file[32];
 	int ret, len;
 
+	offs[0] = line[0] = file[0] = '\0';
+
 	buf = zalloc(MAX_CMDLEN);
 	if (buf == NULL) {
 		ret = -ENOMEM;
-- 
1.7.3.2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] perf-probe: no need to initialize the entire temporary buffers in synthesize_perf_probe_point()
  2010-12-23 15:27 [PATCH] perf-probe: no need to initialize the entire temporary buffers in synthesize_perf_probe_point() Franck Bui-Huu
@ 2010-12-24  4:46 ` Masami Hiramatsu
  2010-12-24 13:14   ` Arnaldo Carvalho de Melo
  2010-12-27 21:01   ` Franck Bui-Huu
  0 siblings, 2 replies; 5+ messages in thread
From: Masami Hiramatsu @ 2010-12-24  4:46 UTC (permalink / raw)
  To: Franck Bui-Huu; +Cc: Arnaldo Carvalho de Melo, linux-kernel, 2nddept-manager

(2010/12/24 0:27), Franck Bui-Huu wrote:
> From: Franck Bui-Huu <fbuihuu@gmail.com>
> 
> This patches only put a single null byte at the beginning of each
> temporary buffers line[], offs[], file[] instead of filling their full
> contents with null bytes.

Hmm, sorry but NAK it.

IMHO, with modern chips, the original code has no problem from the
viewpoint of memory access (all are cached and no need to access just
one byte) nor a bottleneck.
I'd rather use '= ""' style initialization for local variables from the
viewpoint of readability.

Anyway, thank you for looking into the code :-)

Thanks,

> 
> Signed-off-by: Franck Bui-Huu <fbuihuu@gmail.com>
> ---
>  tools/perf/util/probe-event.c |    4 +++-
>  1 files changed, 3 insertions(+), 1 deletions(-)
> 
> diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
> index adc2620..e453f13 100644
> --- a/tools/perf/util/probe-event.c
> +++ b/tools/perf/util/probe-event.c
> @@ -1058,9 +1058,11 @@ error:
>  static char *synthesize_perf_probe_point(struct perf_probe_point *pp)
>  {
>  	char *buf, *tmp;
> -	char offs[32] = "", line[32] = "", file[32] = "";
> +	char offs[32], line[32], file[32];
>  	int ret, len;
>  
> +	offs[0] = line[0] = file[0] = '\0';
> +
>  	buf = zalloc(MAX_CMDLEN);
>  	if (buf == NULL) {
>  		ret = -ENOMEM;


-- 
Masami HIRAMATSU
2nd Dept. Linux Technology Center
Hitachi, Ltd., Systems Development Laboratory
E-mail: masami.hiramatsu.pt@hitachi.com

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] perf-probe: no need to initialize the entire temporary buffers in synthesize_perf_probe_point()
  2010-12-24  4:46 ` Masami Hiramatsu
@ 2010-12-24 13:14   ` Arnaldo Carvalho de Melo
  2010-12-27 21:06     ` Franck Bui-Huu
  2010-12-27 21:01   ` Franck Bui-Huu
  1 sibling, 1 reply; 5+ messages in thread
From: Arnaldo Carvalho de Melo @ 2010-12-24 13:14 UTC (permalink / raw)
  To: Masami Hiramatsu; +Cc: Franck Bui-Huu, linux-kernel, 2nddept-manager

Em Fri, Dec 24, 2010 at 01:46:09PM +0900, Masami Hiramatsu escreveu:
> (2010/12/24 0:27), Franck Bui-Huu wrote:
> > This patches only put a single null byte at the beginning of each
> > temporary buffers line[], offs[], file[] instead of filling their
> > full contents with null bytes.

> Hmm, sorry but NAK it.

> IMHO, with modern chips, the original code has no problem from the
> viewpoint of memory access (all are cached and no need to access just
> one byte) nor a bottleneck.
> I'd rather use '= ""' style initialization for local variables from the
> viewpoint of readability.

No strong feelings here, not really a fast path, just learned something
new, I thought that that kind of initialization would be equivalent to
what Franck proposed, but gcc really uses the most efficient way of
zeroing the whole string (movq for things like that, and rep stos for
bigger arrays, etc).
 
> Anyway, thank you for looking into the code :-)

Yes, please continue sending your improvements and fixes!

Masami, what about the fixes Franck sent, clould you please send ACK or
NACKs for those?

- Arnaldo

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] perf-probe: no need to initialize the entire temporary buffers in synthesize_perf_probe_point()
  2010-12-24  4:46 ` Masami Hiramatsu
  2010-12-24 13:14   ` Arnaldo Carvalho de Melo
@ 2010-12-27 21:01   ` Franck Bui-Huu
  1 sibling, 0 replies; 5+ messages in thread
From: Franck Bui-Huu @ 2010-12-27 21:01 UTC (permalink / raw)
  To: Masami Hiramatsu; +Cc: Arnaldo Carvalho de Melo, linux-kernel, 2nddept-manager

Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> writes:

> (2010/12/24 0:27), Franck Bui-Huu wrote:
>> From: Franck Bui-Huu <fbuihuu@gmail.com>
>> 
>> This patches only put a single null byte at the beginning of each
>> temporary buffers line[], offs[], file[] instead of filling their full
>> contents with null bytes.
>
> Hmm, sorry but NAK it.
>

No problem :)

>
> IMHO, with modern chips, the original code has no problem from the
> viewpoint of memory access (all are cached and no need to access just
> one byte) nor a bottleneck.

I'm not sure to understand this.

But my point is that you're clearing the whole buffers with 0 although
you just need to initialize them with the null string (a single null
byte at the beginning).

So you're doing useless memory accesses (cached or not).

I agree with you that it won't make any speed improvements though, but
it was just clearer for me, since what you want are null strings and not
a char arrays fill with 0.

Thanks.
-- 
		Franck

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] perf-probe: no need to initialize the entire temporary buffers in synthesize_perf_probe_point()
  2010-12-24 13:14   ` Arnaldo Carvalho de Melo
@ 2010-12-27 21:06     ` Franck Bui-Huu
  0 siblings, 0 replies; 5+ messages in thread
From: Franck Bui-Huu @ 2010-12-27 21:06 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo; +Cc: Masami Hiramatsu, linux-kernel, 2nddept-manager

Arnaldo Carvalho de Melo <acme@ghostprotocols.net> writes:

> Em Fri, Dec 24, 2010 at 01:46:09PM +0900, Masami Hiramatsu escreveu:
>> (2010/12/24 0:27), Franck Bui-Huu wrote:
>> > This patches only put a single null byte at the beginning of each
>> > temporary buffers line[], offs[], file[] instead of filling their
>> > full contents with null bytes.
>
>> Hmm, sorry but NAK it.
>
>> IMHO, with modern chips, the original code has no problem from the
>> viewpoint of memory access (all are cached and no need to access just
>> one byte) nor a bottleneck.
>> I'd rather use '= ""' style initialization for local variables from the
>> viewpoint of readability.
>
> No strong feelings here, not really a fast path, just learned something
> new, I thought that that kind of initialization would be equivalent to
> what Franck proposed, but gcc really uses the most efficient way of
> zeroing the whole string (movq for things like that, and rep stos for
> bigger arrays, etc).
> 

gcc has no other choice than clearing the whole buffers here since it's
how C initialisation works.

Thanks
-- 
		Franck

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2010-12-27 21:06 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-12-23 15:27 [PATCH] perf-probe: no need to initialize the entire temporary buffers in synthesize_perf_probe_point() Franck Bui-Huu
2010-12-24  4:46 ` Masami Hiramatsu
2010-12-24 13:14   ` Arnaldo Carvalho de Melo
2010-12-27 21:06     ` Franck Bui-Huu
2010-12-27 21:01   ` Franck Bui-Huu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).