Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp372691pxk; Thu, 24 Sep 2020 07:39:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzeE2L0LqrkmOUh9i3s3VdrjyQvq1IuctICEAVBEAmVmfMNoLU0g/cEarSFP1IYKjhcVhzb X-Received: by 2002:a17:906:68d2:: with SMTP id y18mr202503ejr.197.1600958399424; Thu, 24 Sep 2020 07:39:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600958399; cv=none; d=google.com; s=arc-20160816; b=Ctxi1rEZuLsp7K9+/aS6o+5K8vp3xzA2AezHeNPJDY4oNqSNYQlvlN9pH8H5I7HjB1 O6m3Blw9F2CAlxNF8vvEtfXcixiAVCZYkBxiZ6k3N9DNjnlLBcSykLKf8lIkicmWjjaN gTIXwwq2QezdDbthTa5Xu4qVhy4ABSMXmOKFfEcMpQFfPp47b3+li9eviZdUnWCO/ot9 +agOo7VdBNQdopgU+vLCmGfTR3RoX3aA5/qA9RFdyrXfjveTbEphgPo3mlPKufM8f0gF gmWKqpKGFYgJ7jiNUfnEjn27/2Ms6F/1D6q03EqOQpStiY5LzqMG7exTG/vUdlsFF/Jp rCwA== 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-disposition:mime-version :references:message-id:subject:cc:to:from:date:sender:dkim-signature; bh=/t8PieN/eFPss7Qpw0jjxSzLNSWlXorRRsXxHO8bkrw=; b=Q0hzbBEP0vHtKyIYzykRzF2UuvesFk5MRVekOfLk+26ygnqxj6Qspia0RQ8ZA3sX7Q WwvgbcgzAF+pNTaZf/8gWWBVueBuiJIQyo/KCXq9jYs9NNZc3KpuyXhIEUdsvTLEhXXP Rv8KQcKHWpl/Ugy/6+ZYWQw39eVpoNBPuR+BDQDCMJbWTsd1n+YaCuSZxTOZ7/5tVT3x 9H3JP5OXlGuqdjYWfGB8RHWzZwU+4YKZAhEWCFh114sLJehLb3S+CRKhm3HCQppHajvC aeu1DLKY42qQBpYTIvHbA28V57IyUKHoPOURNns4gyXYNyT1FCT4dVfkXmuFkSiUIBln Vypw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=B5rOfAQG; 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 p61si2254056edd.188.2020.09.24.07.39.34; Thu, 24 Sep 2020 07:39:59 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=B5rOfAQG; 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 S1728274AbgIXOgb (ORCPT + 99 others); Thu, 24 Sep 2020 10:36:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727859AbgIXOgb (ORCPT ); Thu, 24 Sep 2020 10:36:31 -0400 Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46DE6C0613CE for ; Thu, 24 Sep 2020 07:36:31 -0700 (PDT) Received: by mail-pf1-x444.google.com with SMTP id w7so2028946pfi.4 for ; Thu, 24 Sep 2020 07:36:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=/t8PieN/eFPss7Qpw0jjxSzLNSWlXorRRsXxHO8bkrw=; b=B5rOfAQGAlGeVxwr/0IYp/Z9JGcqYTy72x+HQEwDfYQWEybUAgy5tukLTTH7WtxQan OPiu/ZlDVa62RVJi7WPmsJS8RzFHcrH4wV0cS4nDJFxT/OlTuw8/01/Bo1anPFZgbtcu dPXqMy8YcQPK7f3t+qx9DbRlekyLuKIuyHfPFACkrrmfop/W9vQsPuj0LwRySTR/++Bq J8LNbND9KcnKgBpxRVGT2uXTkHp1mpnEzgPFo6/FtFqpWiehDdtcBY2w0utkHgAm+Kwf KY4goQvP9EEJ11U3AkUcPUNmQDEIN9JpFbD83oPLXkgJyoTx9wZ+xHJCx9j4zLHMgKQu pPgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to; bh=/t8PieN/eFPss7Qpw0jjxSzLNSWlXorRRsXxHO8bkrw=; b=r/xpMGcUQNxmcDF8GnPJDlJbRyjxUQDuxxQTQKftZtgowa++z7WxRZiXVT4zGM4q6X GoGF1SztlHqni9yV6cManSksT8G50CyO031WEJRU4Wty0b1m1vSJc8SCqaolbum9Q94F AxUoPOnn7ajFr1f6I8gi/aULRfTB/a6pQeo3tvIs3Dg3qMpLRh5PobvjjY58Oui8sJQv ca8KWPOY6CpImYn695dh9Thv43fx8Z/4dqvMdZul82CjnPzedzuTPTwph7N3NIIRsa6A KzGMhqZ+FBB1GhV9oBfEU9yr58qDNdGgD1mW4OPL9dew4v1VesgWf4uZqmr2GR5DYsUf YSwA== X-Gm-Message-State: AOAM530UxQBenjvm5FkKfIUMQ34dKEFo7ssGAoMlUvUWEEZOZ7hZCYd1 tq1GbNFeHVgRczPVXoS7sEM= X-Received: by 2002:a62:7fcf:0:b029:151:15e0:ab82 with SMTP id a198-20020a627fcf0000b029015115e0ab82mr4825933pfd.80.1600958190712; Thu, 24 Sep 2020 07:36:30 -0700 (PDT) Received: from google.com ([101.235.31.111]) by smtp.gmail.com with ESMTPSA id y1sm3341813pgy.0.2020.09.24.07.36.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Sep 2020 07:36:29 -0700 (PDT) Sender: Namhyung Kim Date: Thu, 24 Sep 2020 23:36:23 +0900 From: Namhyung Kim To: Jiri Olsa Cc: Mark Rutland , Andi Kleen , Alexander Shishkin , Alexey Budankov , Adrian Hunter , Arnaldo Carvalho de Melo , linux-kernel , Peter Zijlstra , Andi Kleen , Li Bin , Wei Li , Ingo Molnar , linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH 1/2] perf stat: Fix segfault when counting armv8_pmu events Message-ID: <20200924143623.GA357648@google.com> References: <20200922031346.15051-1-liwei391@huawei.com> <20200922031346.15051-2-liwei391@huawei.com> <20200923054426.GG2893484@krava> <20200923140747.GN2893484@krava> <20200923201900.GQ2893484@krava> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20200923201900.GQ2893484@krava> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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);