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=-0.9 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS 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 AC2D7C43331 for ; Tue, 24 Mar 2020 10:26:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 827EF20870 for ; Tue, 24 Mar 2020 10:26:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="eCuK6A3r" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727161AbgCXK0M (ORCPT ); Tue, 24 Mar 2020 06:26:12 -0400 Received: from us-smtp-delivery-74.mimecast.com ([216.205.24.74]:58091 "EHLO us-smtp-delivery-74.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727130AbgCXK0M (ORCPT ); Tue, 24 Mar 2020 06:26:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585045571; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=TI9J12sTDb0Vpr1mpuy5hfvmrFn3PMyYGmmiVFdQMGA=; b=eCuK6A3rmH8KdfrmFnpiUhavUywfo7K8ULBEVGHDHCWIl1ChLDuicgx9zIICvF5BH/rgoZ ijw/Fz3iI8hsVpOefWTXokd9dO5Z323SYpyANK6GJwFCZ3PibaTll/+aYvz8ZKU4hTHxcA hxKP6xrunuM791HHQUFi63mPIeZzTu8= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-215-gMheyZxdMLWKB16HPk3-Lw-1; Tue, 24 Mar 2020 06:26:09 -0400 X-MC-Unique: gMheyZxdMLWKB16HPk3-Lw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6A016107ACC7; Tue, 24 Mar 2020 10:26:05 +0000 (UTC) Received: from krava (unknown [10.40.192.119]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 97B6A60BE0; Tue, 24 Mar 2020 10:25:59 +0000 (UTC) Date: Tue, 24 Mar 2020 11:25:57 +0100 From: Jiri Olsa To: Ian Rogers Cc: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Namhyung Kim , Alexei Starovoitov , Daniel Borkmann , Martin KaFai Lau , Yonghong Song , Andrii Nakryiko , Greg Kroah-Hartman , Thomas Gleixner , Igor Lubashev , Alexey Budankov , Florian Fainelli , Adrian Hunter , Andi Kleen , Jiwei Sun , yuzhoujian , Kan Liang , Jin Yao , Leo Yan , John Garry , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, linux-perf-users@vger.kernel.org, Stephane Eranian Subject: Re: [PATCH v5] perf tools: add support for libpfm4 Message-ID: <20200324102557.GN1534489@krava> References: <20200323235846.104937-1-irogers@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200323235846.104937-1-irogers@google.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Sender: bpf-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org On Mon, Mar 23, 2020 at 04:58:46PM -0700, Ian Rogers wrote: SNIP > + /* no event */ > + if (*q == '\0') > + continue; > + > + memset(&attr, 0, sizeof(attr)); > + event_attr_init(&attr); > + > + ret = parse_libpfm_event(q, &attr); > + if (ret != PFM_SUCCESS) { > + fprintf(stderr, "failed to parse event %s : %s\n", str, pfm_strerror(ret)); > + goto error; > + } > + > + evsel = perf_evsel__new_idx(&attr, evlist->core.nr_entries); > + if (evsel == NULL) > + goto error; > + > + evsel->name = strdup(q); > + if (!evsel->name) { > + evsel__delete(evsel); > + goto error; > + } > + evsel->is_libpfm_event = true; > + > + pmu = perf_pmu__find_by_type((unsigned)attr.type); > + if (pmu) > + evsel->core.own_cpus = perf_cpu_map__get(pmu->cpus); I think you need to do more setup in here, like in __add_event function would be great to factor those bits from __add_event function and call it from here, so it's all in one place jirka