public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] perf bench: Fix 2 memory sanitizer warnings
@ 2020-09-12  5:37 Ian Rogers
  2020-09-12 20:51 ` Jiri Olsa
  0 siblings, 1 reply; 3+ messages in thread
From: Ian Rogers @ 2020-09-12  5:37 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
	linux-kernel
  Cc: Stephane Eranian, Ian Rogers

Memory sanitizer warns if a write is performed where the memory
being read for the write is uninitialized. Avoid this warning by
initializing the memory.

Signed-off-by: Ian Rogers <irogers@google.com>
---
 tools/perf/bench/sched-messaging.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/perf/bench/sched-messaging.c b/tools/perf/bench/sched-messaging.c
index 71d830d7b923..cecce93ccc63 100644
--- a/tools/perf/bench/sched-messaging.c
+++ b/tools/perf/bench/sched-messaging.c
@@ -66,11 +66,10 @@ static void fdpair(int fds[2])
 /* Block until we're ready to go */
 static void ready(int ready_out, int wakefd)
 {
-	char dummy;
 	struct pollfd pollfd = { .fd = wakefd, .events = POLLIN };
 
 	/* Tell them we're ready. */
-	if (write(ready_out, &dummy, 1) != 1)
+	if (write(ready_out, "R", 1) != 1)
 		err(EXIT_FAILURE, "CLIENT: ready write");
 
 	/* Wait for "GO" signal */
@@ -85,6 +84,7 @@ static void *sender(struct sender_context *ctx)
 	unsigned int i, j;
 
 	ready(ctx->ready_out, ctx->wakefd);
+	memset(data, 'S', sizeof(data));
 
 	/* Now pump to every receiver. */
 	for (i = 0; i < nr_loops; i++) {
-- 
2.28.0.618.gf4bc123cb7-goog


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

* Re: [PATCH] perf bench: Fix 2 memory sanitizer warnings
  2020-09-12  5:37 [PATCH] perf bench: Fix 2 memory sanitizer warnings Ian Rogers
@ 2020-09-12 20:51 ` Jiri Olsa
  2020-09-14 21:30   ` Arnaldo Carvalho de Melo
  0 siblings, 1 reply; 3+ messages in thread
From: Jiri Olsa @ 2020-09-12 20:51 UTC (permalink / raw)
  To: Ian Rogers
  Cc: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Mark Rutland, Alexander Shishkin, Namhyung Kim, linux-kernel,
	Stephane Eranian

On Fri, Sep 11, 2020 at 10:37:25PM -0700, Ian Rogers wrote:
> Memory sanitizer warns if a write is performed where the memory
> being read for the write is uninitialized. Avoid this warning by
> initializing the memory.
> 
> Signed-off-by: Ian Rogers <irogers@google.com>

Acked-by: Jiri Olsa <jolsa@redhat.com>

thanks,
jirka

> ---
>  tools/perf/bench/sched-messaging.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/perf/bench/sched-messaging.c b/tools/perf/bench/sched-messaging.c
> index 71d830d7b923..cecce93ccc63 100644
> --- a/tools/perf/bench/sched-messaging.c
> +++ b/tools/perf/bench/sched-messaging.c
> @@ -66,11 +66,10 @@ static void fdpair(int fds[2])
>  /* Block until we're ready to go */
>  static void ready(int ready_out, int wakefd)
>  {
> -	char dummy;
>  	struct pollfd pollfd = { .fd = wakefd, .events = POLLIN };
>  
>  	/* Tell them we're ready. */
> -	if (write(ready_out, &dummy, 1) != 1)
> +	if (write(ready_out, "R", 1) != 1)
>  		err(EXIT_FAILURE, "CLIENT: ready write");
>  
>  	/* Wait for "GO" signal */
> @@ -85,6 +84,7 @@ static void *sender(struct sender_context *ctx)
>  	unsigned int i, j;
>  
>  	ready(ctx->ready_out, ctx->wakefd);
> +	memset(data, 'S', sizeof(data));
>  
>  	/* Now pump to every receiver. */
>  	for (i = 0; i < nr_loops; i++) {
> -- 
> 2.28.0.618.gf4bc123cb7-goog
> 


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

* Re: [PATCH] perf bench: Fix 2 memory sanitizer warnings
  2020-09-12 20:51 ` Jiri Olsa
@ 2020-09-14 21:30   ` Arnaldo Carvalho de Melo
  0 siblings, 0 replies; 3+ messages in thread
From: Arnaldo Carvalho de Melo @ 2020-09-14 21:30 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: Ian Rogers, Peter Zijlstra, Ingo Molnar, Mark Rutland,
	Alexander Shishkin, Namhyung Kim, linux-kernel, Stephane Eranian

Em Sat, Sep 12, 2020 at 10:51:24PM +0200, Jiri Olsa escreveu:
> On Fri, Sep 11, 2020 at 10:37:25PM -0700, Ian Rogers wrote:
> > Memory sanitizer warns if a write is performed where the memory
> > being read for the write is uninitialized. Avoid this warning by
> > initializing the memory.
> > 
> > Signed-off-by: Ian Rogers <irogers@google.com>
> 
> Acked-by: Jiri Olsa <jolsa@redhat.com>

Thanks, applied.

- Arnaldo

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

end of thread, other threads:[~2020-09-14 21:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-09-12  5:37 [PATCH] perf bench: Fix 2 memory sanitizer warnings Ian Rogers
2020-09-12 20:51 ` Jiri Olsa
2020-09-14 21:30   ` Arnaldo Carvalho de Melo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox