Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1608625rwl; Fri, 24 Mar 2023 12:57:20 -0700 (PDT) X-Google-Smtp-Source: AKy350Ytyg9a+OMjH2VKsHGiMN3ucTz/ZBse8p6+7fxqjh8iWkTM9TCDbdIGtLSwlJUt/NBR862Y X-Received: by 2002:a17:907:8b88:b0:925:f788:d76d with SMTP id tb8-20020a1709078b8800b00925f788d76dmr4245542ejc.27.1679687840276; Fri, 24 Mar 2023 12:57:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679687840; cv=none; d=google.com; s=arc-20160816; b=Fq1ZC3ky7SEx6zBIVg2IYkLTm65Pz9ordNoX/aB204o0idSuJp5Kq4ndLgvqxNJVus 7GuUrzD6AV2fplwDnwb45uU37MMoBhaDIny/OWF8QOgWCE5au0X7Sjw204L5Wg3fJxri MmeOeD3h26a9yfh6X7daWiJ95YqXSGuHJVltjRJ+JIHDO1r9eQWJWFbcUBzHav0/GYtI lPyH/NQX2cpN2qWWiSWaDtQlLEI9UU3qk9KRRVIOWQJ5qVMbefycp/FtPj53MRstzRcE 1g641uIMxdjbOUPAPm9ZaDPvdmr6pjc/Qnu23v3roI8WQb/HWpjmO/6bGjzKl64W8axH XLdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=9oaBPFHMD+l3dyHQySAJFl99A1x9RQ3us2C6d2CnMKo=; b=b0tkWIHVyB0Jf2h0aFmWkZ9ZNBFzzLFA+RLd1TLL6eK/kx5Ze1HDInFl4MYguVp/RA 6O2knPDyn5UVWdSLr+kvcZjr7PhXXiJPg0HNKT9vgz9lpWR8Y+I4BgNEdGczdE7orpnu /JBw8w+HkEQ2MiGBTX/uOhzuImz75K0UL1wm0pgIjMtAC4EvWQUQuKSzZVh+pfYwDqSr wAjNktT1hZIKK+6GlxH+TsRuamhUBLqaw8rjFBB89DOKhAJv/h2mkUPrkSQnW//rcCjL clsM5B509o1Qf2LHrlnHs5aIdrqilt2fRKGi0BwhERI0yznboFLACLXoJD03pqIgfSvC KuAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=OUI7997C; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id kn10-20020a1709079b0a00b0093dddb820dasi2570014ejc.305.2023.03.24.12.56.55; Fri, 24 Mar 2023 12:57:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=OUI7997C; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231891AbjCXTyY (ORCPT + 99 others); Fri, 24 Mar 2023 15:54:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58558 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231520AbjCXTyX (ORCPT ); Fri, 24 Mar 2023 15:54:23 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A8F1719C54; Fri, 24 Mar 2023 12:54:20 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 69969B825F8; Fri, 24 Mar 2023 19:54:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D31BCC433A1; Fri, 24 Mar 2023 19:54:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1679687658; bh=/qBMaNf2uyTNrEhxXPzBWpqskPlVDXXWaE1a7Spl8og=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=OUI7997CfkwHW/tpwqGpap88f1/mnco4Lmt9No4R+YQ0pfiCXVKlHhuHpjGHD455O 3MyNK4t6qifiCBHxt/iq/2NoOU8tYaStg4q0wRK+st02XtJzTwFBqrUKn0vP8VvLgN Uj8Rjh0kQvpyDi7s9jngnS0Z/yNUwyyXiV9REBxTpOakXx237RStN23FdQXaHVpqkW 7iiD1oT4V7nTABXAftJhTpEbylJZy1Lpq1PbRNKpPewMF5wH4QodtCWCnrpiMzssyf Wak03vmRDbakybRCcdSnLyBb9yVAp2lHJhULw+Bpsma97g80hTn9RGXP7NCcnNVHAO uVKtoSWgkMeAw== Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id 53D514052D; Fri, 24 Mar 2023 16:54:15 -0300 (-03) Date: Fri, 24 Mar 2023 16:54:15 -0300 From: Arnaldo Carvalho de Melo To: Ian Rogers Cc: Namhyung Kim , Jiri Olsa , Adrian Hunter , Peter Zijlstra , Ingo Molnar , LKML , linux-perf-users@vger.kernel.org Subject: Re: [PATCH] perf lock contention: Fix msan issue in lock_contention_read() Message-ID: References: <20230324001922.937634-1-namhyung@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Url: http://acmel.wordpress.com X-Spam-Status: No, score=-2.5 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Thu, Mar 23, 2023 at 11:50:57PM -0700, Ian Rogers escreveu: > On Thu, Mar 23, 2023 at 5:19 PM Namhyung Kim wrote: > > > > I got a report of a msan failure like below: > > > > $ sudo perf lock con -ab -- sleep 1 > > ... > > ==224416==WARNING: MemorySanitizer: use-of-uninitialized-value > > #0 0x5651160d6c96 in lock_contention_read util/bpf_lock_contention.c:290:8 > > #1 0x565115f90870 in __cmd_contention builtin-lock.c:1919:3 > > #2 0x565115f90870 in cmd_lock builtin-lock.c:2385:8 > > #3 0x565115f03a83 in run_builtin perf.c:330:11 > > #4 0x565115f03756 in handle_internal_command perf.c:384:8 > > #5 0x565115f02d53 in run_argv perf.c:428:2 > > #6 0x565115f02d53 in main perf.c:562:3 > > #7 0x7f43553bc632 in __libc_start_main > > #8 0x565115e865a9 in _start > > > > It was because the 'key' variable is not initialized. Actually it'd be set > > by bpf_map_get_next_key() but msan didn't seem to understand it. Let's make > > msan happy by initializing the variable. > > > > Signed-off-by: Namhyung Kim > > Acked-by: Ian Rogers Thanks, applied. - Arnaldo > Thanks, > Ian > > > --- > > tools/perf/util/bpf_lock_contention.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/tools/perf/util/bpf_lock_contention.c b/tools/perf/util/bpf_lock_contention.c > > index 235fc7150545..5927bf0bd92b 100644 > > --- a/tools/perf/util/bpf_lock_contention.c > > +++ b/tools/perf/util/bpf_lock_contention.c > > @@ -249,7 +249,7 @@ static const char *lock_contention_get_name(struct lock_contention *con, > > int lock_contention_read(struct lock_contention *con) > > { > > int fd, stack, err = 0; > > - struct contention_key *prev_key, key; > > + struct contention_key *prev_key, key = {}; > > struct contention_data data = {}; > > struct lock_stat *st = NULL; > > struct machine *machine = con->machine; > > -- > > 2.40.0.348.gf938b09366-goog > > -- - Arnaldo