From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A1CEDC41604 for ; Tue, 6 Oct 2020 06:53:00 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2991F20796 for ; Tue, 6 Oct 2020 06:53:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="ysf0Gplc" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2991F20796 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=hisilicon.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:In-Reply-To:References:Message-ID:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=/XNZ+oNpu3RQARz1iT0FLZfcKNy21r0Ee0MSyjqx9HY=; b=ysf0GplcqP32SX2hTA8iEQSAs rPwFTgMbJm8+QLhEueKt/AITcc1acujmeKk4SrxerCv66Dr+cDjOahaSbJkjqL4pHAKBxpUoCaqn+ WaXp4IwKfas4L5kWRTDRKNLYj21JWV1foG/t1m6FLI5uHuzQRFV/d/9GM8QqD2WMq6jatEmnf7cin An4F4WYWGxhaKrfxdyifFlLUbIwu/rDK/YPzW3kzLm6c5IhdEiKOrsPryvwa27vfUjfvCrz78KoRs Kq16UaQ67vuwPnGLK1psZyPa6GcCsnZ2f48HvuegmUyWWAwpdSoV/+iYW5ItHO3jJAypQXx/QZkZV RRjFuFTXg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kPgol-000236-8j; Tue, 06 Oct 2020 06:51:23 +0000 Received: from szxga01-in.huawei.com ([45.249.212.187] helo=huawei.com) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kPgoi-000220-5f for linux-arm-kernel@lists.infradead.org; Tue, 06 Oct 2020 06:51:21 +0000 Received: from DGGEMM405-HUB.china.huawei.com (unknown [172.30.72.53]) by Forcepoint Email with ESMTP id A5E697BFA06D529D5A98; Tue, 6 Oct 2020 14:51:14 +0800 (CST) Received: from dggema773-chm.china.huawei.com (10.1.198.217) by DGGEMM405-HUB.china.huawei.com (10.3.20.213) with Microsoft SMTP Server (TLS) id 14.3.487.0; Tue, 6 Oct 2020 14:51:14 +0800 Received: from dggemi761-chm.china.huawei.com (10.1.198.147) by dggema773-chm.china.huawei.com (10.1.198.217) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1913.5; Tue, 6 Oct 2020 14:51:13 +0800 Received: from dggemi761-chm.china.huawei.com ([10.9.49.202]) by dggemi761-chm.china.huawei.com ([10.9.49.202]) with mapi id 15.01.1913.007; Tue, 6 Oct 2020 14:51:14 +0800 From: "Song Bao Hua (Barry Song)" To: Jiri Olsa , Namhyung Kim , "liwei (GF)" Subject: RE: [PATCH 1/2] perf stat: Fix segfault when counting armv8_pmu events Thread-Topic: [PATCH 1/2] perf stat: Fix segfault when counting armv8_pmu events Thread-Index: AQHWkI6N3p3Bu2WQrU64XEFw+dtch6l1MfgAgACHoQCAAAUBgIAAAgsAgABlrQCAATKbgIAMNI4AgAaoV1A= Date: Tue, 6 Oct 2020 06:51:14 +0000 Message-ID: <94f906e548db4534be577815e7cada01@hisilicon.com> References: <20200922031346.15051-1-liwei391@huawei.com> <20200922031346.15051-2-liwei391@huawei.com> <20200923054426.GG2893484@krava> <20200923140747.GN2893484@krava> <20200923201900.GQ2893484@krava> <20200924143623.GA357648@google.com> <20201002085936.GE3999500@krava> In-Reply-To: <20201002085936.GE3999500@krava> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.126.200.32] MIME-Version: 1.0 X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201006_025120_503226_575D356E X-CRM114-Status: GOOD ( 31.41 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Andi Kleen , Alexander Shishkin , Alexey Budankov , Adrian Hunter , Arnaldo Carvalho de Melo , linux-kernel , Peter Zijlstra , Andi Kleen , "Libin \(Huawei\)" , Ingo Molnar , "linux-arm-kernel@lists.infradead.org" Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org > -----Original Message----- > From: Jiri Olsa [mailto:jolsa@redhat.com] > Sent: Friday, October 2, 2020 10:00 PM > To: Namhyung Kim ; liwei (GF) > > Cc: Mark Rutland ; Andi Kleen ; > Alexander Shishkin ; Alexey Budankov > ; Adrian Hunter > ; Arnaldo Carvalho de Melo ; > linux-kernel ; Peter Zijlstra > ; Andi Kleen ; Libin (Huawei) > ; Ingo Molnar ; > linux-arm-kernel@lists.infradead.org > Subject: Re: [PATCH 1/2] perf stat: Fix segfault when counting armv8_pmu > events > > On Thu, Sep 24, 2020 at 11:36:23PM +0900, Namhyung Kim wrote: > > On Wed, Sep 23, 2020 at 10:19:00PM +0200, Jiri Olsa wrote: > > > On Wed, Sep 23, 2020 at 11:15:06PM +0900, Namhyung Kim wrote: > > > > I think the problem is that armv8_pmu has a cpumask, > > > > and the user requested per-task events. > > > > > > > > The code tried to open the event with a dummy cpu map > > > > since it's not a cpu event, but the pmu has cpu map and > > > > it's passed to evsel. So there's confusion somewhere > > > > whether it should use evsel->cpus or a dummy map. > > > > > > you're right, I have following cpus file in pmu: > > > > > > # cat /sys/devices/armv8_pmuv3_0/cpus > > > 0-3 > > > > > > covering all the cpus.. and once you have cpumask/cpus file, > > > you're system wide by default in current code, but we should > > > not crash ;-) > > > > > > I tried to cover this case in patch below and I probably broke > > > some other use cases, but perhaps we could allow to open counters > > > per cpus for given workload > > > > > > I'll try to look at this more tomorrow > > > > I'm thinking about a different approach, we can ignore cpu map > > for the ARM cpu PMU and use the dummy, not tested ;-) > > > > Thanks > > Namhyung > > > > > > diff --git a/tools/lib/perf/evlist.c b/tools/lib/perf/evlist.c > > index 2208444ecb44..cfcdbd7be066 100644 > > --- a/tools/lib/perf/evlist.c > > +++ b/tools/lib/perf/evlist.c > > @@ -45,6 +45,9 @@ static void __perf_evlist__propagate_maps(struct > perf_evlist *evlist, > > if (!evsel->own_cpus || evlist->has_user_cpus) { > > perf_cpu_map__put(evsel->cpus); > > evsel->cpus = perf_cpu_map__get(evlist->cpus); > > + } else if (!evsel->system_wide && > perf_cpu_map__empty(evlist->cpus)) { > > + perf_cpu_map__put(evsel->cpus); > > + evsel->cpus = perf_cpu_map__get(evlist->cpus); > > } else if (evsel->cpus != evsel->own_cpus) { > > perf_cpu_map__put(evsel->cpus); > > evsel->cpus = perf_cpu_map__get(evsel->own_cpus); > > > > Wei Li, > is this fixing your problem? As I have seen the same crash and suggested another patch: [PATCH] perf evlist: fix memory corruption for Kernel PMU event https://lore.kernel.org/lkml/20201001115729.27116-1-song.bao.hua@hisilicon.com/ Also, I have tested Namhyung Kim's patch on ARM64. It does fix the crash for me. So: Tested-by: Barry Song Please put the below fixes-tag in commit log: Fixes: 7736627b865d ("perf stat: Use affinity for closing file descriptors") Thanks Barry _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel