Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp205684pxu; Wed, 7 Oct 2020 00:26:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxc+OE7Qrsj69py24B21VPFYZEVPAuSowrpNjRUJvyBJVOKpv1YYx6K1NHSey/sEHsspUI+ X-Received: by 2002:a05:6402:d06:: with SMTP id eb6mr2033457edb.289.1602055577514; Wed, 07 Oct 2020 00:26:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602055577; cv=none; d=google.com; s=arc-20160816; b=BHTCiQHZ5mrtaR9QztTTxVsTxh1z/uC3ed8ndeAwtH/xsbcgnSsAfyaCW+A/PUMOq/ UFjqZHdBaaVhMEa1avujFLI2tUibzDkafA1T4GSBjtulp46RxIjtEip/WMtQ5pEEZFqC v8rHSpeOFx7JeqBAKM1AhpjiL7B+E7dwMB1a6QrQcd19yVGrl9KsOBlrJT6NxQcWxmeq ExysJCyv8AQuht7XzcZyaaZ24gllxdbxuIZN9XlvDX+341Wx+hIpGPltOJJ5kwJQ8F7X OjSbq267rBpUGqrXYkROjuV8WzGzwJWuJk8kWRt8660HLHUhdH0b+z36EUVVKaEhfmGa /EvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version; bh=vm13Z3HWwFFOXzAYg9vXSvr/1kojOsqrdIrCgv8M87U=; b=qrmXq9NxU0CCYwv2W3yWCR0hprhpGc2bEkdy7ELqMb43KBw9X1557ECgcUypt0e6wo aJsn5xqSQ1Wv1lXHsIId3CDDDWZBvO1kZ7Ju3kkAIer03BHxYuqhIdlL1+Ju/B5xx9Zr V3N8Dm0OFNxX0LX9glteVpBayEAAJ+xDttPtY3u3OKZTRc3HZpy+WcYie8d7S+OaGqZT J20nx+5+0iIS3WZFht1ICqY9P6nuT98frUERCxu7ienqDu3rIdCdaXb3DriisTyZhMTw 4y/ppL3DVaWytIuOyfwP7o4G+SHkiwaPf0316ObGts8AbseGKdbLVPJB9uERSWubEgsX Y2tw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j13si793873edt.35.2020.10.07.00.25.54; Wed, 07 Oct 2020 00:26:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1727668AbgJGHXr (ORCPT + 99 others); Wed, 7 Oct 2020 03:23:47 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:42136 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726771AbgJGHXr (ORCPT ); Wed, 7 Oct 2020 03:23:47 -0400 Received: by mail-wr1-f67.google.com with SMTP id e18so894412wrw.9 for ; Wed, 07 Oct 2020 00:23:45 -0700 (PDT) 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=vm13Z3HWwFFOXzAYg9vXSvr/1kojOsqrdIrCgv8M87U=; b=QdpWMGznDkim71teTKnuNeEf2ndCLnrUbK+6fWboH8ZqC5WBv0CTmxip4vBXZ4W8dZ IH8rijrzDlioXR279Qe5iRcRz722gwS847f+0xkPEcXNADrKgDF2JivVA8X0SaU+Oric YX6WgHM+BgGCvsG90vv+hlNQu6toFnj8Kvgu0YOFqBf0kEX46TRgFeG3CeEtA9UspHYZ nPoZjMvy9CivQM+VjCDYJiFUG+DeOQst7seKwMCcpe65CcLegYSbYlMgkftZNt0KPCQb k20LLOEPeYzpSj4A8q1zZ6P7HQPH8L3L44zsraXHmoBZDIybna3UpNmVlHDe1MFO+a4F nlKw== X-Gm-Message-State: AOAM531p+63EbIa4ebyrxNo+w66bRKDOphiOYKxGd/NUz+GAvNqZNsKX cbTRj4RA0w1hU5bDx5BygIQNxQuc0HNr3OhrDSU= X-Received: by 2002:adf:8b48:: with SMTP id v8mr1878671wra.21.1602055424968; Wed, 07 Oct 2020 00:23:44 -0700 (PDT) MIME-Version: 1.0 References: <20201001115729.27116-1-song.bao.hua@hisilicon.com> <20201001230653.GM50079@tassilo.jf.intel.com> <41a3e45d558242f79f9e10a8d9ca92f1@hisilicon.com> <20201006111113.GB249615@krava> In-Reply-To: <20201006111113.GB249615@krava> From: Namhyung Kim Date: Wed, 7 Oct 2020 16:23:10 +0900 Message-ID: Subject: Re: [PATCH] perf evlist: fix memory corruption for Kernel PMU event To: Jiri Olsa Cc: "Song Bao Hua (Barry Song)" , Andi Kleen , "linux-kernel@vger.kernel.org" , Linuxarm , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Adrian Hunter , Alexey Budankov Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, On Tue, Oct 6, 2020 at 8:11 PM Jiri Olsa wrote: > > On Tue, Oct 06, 2020 at 06:39:44AM +0000, Song Bao Hua (Barry Song) wrote: > > SNIP > > > > > Andi, thanks! Could you share the link or the commit ID? I'd like to take a > > > look at the fix. > > > > I could still reproduce this issue in the latest linus' tree and I didn't find any > > > commit > > > > related to this issue in linux-next and tip/perf/core. > > > > > > I think Andi was referring to this discussion which is not merged yet: > > > > > > https://lore.kernel.org/lkml/20200922031346.15051-2-liwei391@huawei.co > > > m/ > > > > > > I suggested a patch at the end. Can you please try it? > > > > I tried the patch you suggested. > > > > 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); > > > > it did fix the crash I have seen on arm64. I'd prefer you put the below fixes tag in the commit log. > > Fixes: 7736627b865d ("perf stat: Use affinity for closing file descriptors") > > Perf stat began to crash from v5.4 kernel, so the fix should be backported to stable trees. > > awesome.. Namhyung, could you please send full patch? Sure, I'll do! Thanks Namhyung