Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp730215ybi; Fri, 26 Jul 2019 18:39:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqwXMqlOK0uhUSsodKH6DGOzWpXBYfnvJgEvVaqvxXXrq8v0RKxqnxB6QvH0paCUOmfsQPhO X-Received: by 2002:a17:902:aa03:: with SMTP id be3mr98848507plb.240.1564191578334; Fri, 26 Jul 2019 18:39:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564191578; cv=none; d=google.com; s=arc-20160816; b=z8rLioozdDxv3LWkM/4CV2FGYTaIuh4hsl5rGafw26m8OHTn1auCfP2KVoFIErB2cx 8715vCR6bKhBfOiYGh30UXyAqSwJpFcSe4fbcYmO93CaBg3addhuE5uK+58Vo0x4PaK/ CKFUbZpty6go188xp3l1KOMrsDWo222I4fPZhH+CWoZ+jxDT9Yl9el0OwoXoswXm44oo poYE63Qs9C99P94PLrJ0GcAEK/gAYKk1fLAUExh38J65MINGjwHzckCQaCrb4k2IgEG/ PzBYLH2YZlK2mcLIdTPuJI9mZCqtxsYl7KbnWjrVQP9eoxX+ATDY76rcRO5w6ukknYNR irZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=ynP0RWGfXHb+Ugg6ER1XzuO5G0OYOiJ2jK1uvno/35E=; b=WEIz7EJRKxZ/BjyDVCWhh8B5tX3U8WgPin9/JUhae7DpIYUv5TUUDRsm7bF+yPowRX Z4P1lCGWC8BwQ69KlWbVZ9o9JKXlJDqiMWNtVN8evaaI09V8biAQVizLTAwRdZtu1B/B jvzohffV463DgXsthZ77OfZctrsKdt2VYMHpGq98I42WFT/xGRENbK0siuqh1LC4Et7z IEySTDdH688r8gPs5jG8sHSHRIoueHAIugQtGDPnFnofHMXlM0GAEESOREFrB8NKKSeG yxK1eSLr2TXPIwKT6E5q1rSu/mje8hRW/A9UhQOzCFgkyXVapHzWRnRS9BQuRtyBqZVI cBMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=j54lOfLS; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l68si20530688plb.416.2019.07.26.18.39.23; Fri, 26 Jul 2019 18:39:38 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=j54lOfLS; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728420AbfGZXwl (ORCPT + 99 others); Fri, 26 Jul 2019 19:52:41 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:52756 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726191AbfGZXwl (ORCPT ); Fri, 26 Jul 2019 19:52:41 -0400 Received: by mail-wm1-f65.google.com with SMTP id s3so49236989wms.2 for ; Fri, 26 Jul 2019 16:52:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ynP0RWGfXHb+Ugg6ER1XzuO5G0OYOiJ2jK1uvno/35E=; b=j54lOfLSrM52zu4Z1Omwfucejndrp+XFm/dAFcG2sWu4iuRIcyL+ZJL7nkx1FKzF6a EvYOAtkSsh2ojOCL3fs3jAEh9BSVwIFsilDab6dgr6sLUFaBshp0vhLLfSj8GUCWEkq5 /yQb2YY9ZB3tZ13lHJzvd68aAHlY8BhQM5dg0En4cHGyvgWgPLVnpL/dsMc7kA0sk9pn 9Xpni0yfoHPtb3di8nHFUrBDk1WisQcYOraB7Ez8ttFVYb1xworuzio38MIF8woinNp/ a1hAE2r9QFh5m8wdlOddvsfRMxSJye40F4Cv+pbfVP2Prw5KR4NMZad/5C+9519Qh0PZ hksw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ynP0RWGfXHb+Ugg6ER1XzuO5G0OYOiJ2jK1uvno/35E=; b=iTW/JRJiHd8wMWxinM44jciErXMrLWpyo9jQ6ihEJ9O0Nxek7oKEJH5oJHQKix/Jao ra4yOYv2vkJzxgAxYqwW5tQZ2Di6G0iwAZwsXJIUGcPyOk5lIYcnD0ie9nENf80L5UzI MQdVmzdGM2M0AF+cGCnww/slhGXzBpGZ+dG7gFU92T0PUtcoR+INys9AvcIlbg7RoF2a gE4am1SVSN6xKSTV5wYOg5f+lSMAZaPlbYyW92o4B++Ngiia10zar7x68R2Fd7186W5i 1A2AAF/9hnv2HZIhoHfA9RcepvK7oa55uQR359KRSxXb333QTEa4UNKfHcSG8atkwSUA ly1g== X-Gm-Message-State: APjAAAWt1gV1cEZZAq+H2tKJ1EeoMPrszAGcBrXmecTDsGYjeEOiF28e GMs8yQnzgf9unzIJ0Ycj+iNcCZV1Irs5L1cRY9iiQA== X-Received: by 2002:a05:600c:2056:: with SMTP id p22mr14459424wmg.155.1564185158472; Fri, 26 Jul 2019 16:52:38 -0700 (PDT) MIME-Version: 1.0 References: <20190724234500.253358-1-nums@google.com> <20190724234500.253358-4-nums@google.com> <20190726193227.GH20482@kernel.org> In-Reply-To: <20190726193227.GH20482@kernel.org> From: Ian Rogers Date: Fri, 26 Jul 2019 16:52:26 -0700 Message-ID: Subject: Re: [PATCH 3/3] Fix sched-messaging.c use of uninitialized value errors To: Arnaldo Carvalho de Melo Cc: Numfor Mbiziwo-Tiapo , Peter Zijlstra , Ingo Molnar , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Song Liu , mbd@fb.com, LKML , Stephane Eranian Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jul 26, 2019 at 12:32 PM Arnaldo Carvalho de Melo wrote: > > Em Wed, Jul 24, 2019 at 04:45:00PM -0700, Numfor Mbiziwo-Tiapo escreveu: > > Our local MSAN (Memory Sanitizer) build of perf throws use of > > uninitialized value warnings in "tools/perf/bench/sched-messaging.c" > > when running perf bench. > > > > The first warning comes from the "ready" function where the "dummy" char > > is declared and then passed into "write" without being initialized. > > Initializing "dummy" to any character silences the warning. > > > > The second warning comes from the "sender" function where a "write" call > > is made to write the contents from the "data" char array when it has not > > yet been initialized. Calling memset on "data" silences the warning. > > So, this is just to silence MSAN, as it doesn't matter what is sent, > whatever values are in those variables is ok, as it will not be used, > right? That's right. Thanks, Ian Rogers > - Arnaldo > > > To reproduce this warning, build perf by running: > > make -C tools/perf CLANG=1 CC=clang EXTRA_CFLAGS="-fsanitize=memory\ > > -fsanitize-memory-track-origins" > > > > (Additionally, llvm might have to be installed and clang might have to > > be specified as the compiler - export CC=/usr/bin/clang) > > > > then running: tools/perf/perf bench sched all > > > > Please see the cover letter for why false positive warnings may be > > generated. > > > > Signed-off-by: Numfor Mbiziwo-Tiapo > > --- > > tools/perf/bench/sched-messaging.c | 3 ++- > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > > diff --git a/tools/perf/bench/sched-messaging.c b/tools/perf/bench/sched-messaging.c > > index f9d7641ae833..d22d7b7b591d 100644 > > --- a/tools/perf/bench/sched-messaging.c > > +++ b/tools/perf/bench/sched-messaging.c > > @@ -69,7 +69,7 @@ static void fdpair(int fds[2]) > > /* Block until we're ready to go */ > > static void ready(int ready_out, int wakefd) > > { > > - char dummy; > > + char dummy = 'N'; > > struct pollfd pollfd = { .fd = wakefd, .events = POLLIN }; > > > > /* Tell them we're ready. */ > > @@ -87,6 +87,7 @@ static void *sender(struct sender_context *ctx) > > char data[DATASIZE]; > > unsigned int i, j; > > > > + memset(data, 'N', DATASIZE); > > ready(ctx->ready_out, ctx->wakefd); > > > > /* Now pump to every receiver. */ > > -- > > 2.22.0.657.g960e92d24f-goog > > -- > > - Arnaldo