From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752037AbdFUU0R (ORCPT ); Wed, 21 Jun 2017 16:26:17 -0400 Received: from mga11.intel.com ([192.55.52.93]:36588 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751963AbdFUU0P (ORCPT ); Wed, 21 Jun 2017 16:26:15 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.39,370,1493708400"; d="scan'208";a="277076534" Subject: Re: [PATCH V3 20/37] perf script: Add 'synth' event type for synthesized events To: Arnaldo Carvalho de Melo Cc: Andi Kleen , Peter Zijlstra , Jiri Olsa , Namhyung Kim , Wang Nan , David Ahern , Alexander Shishkin , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org References: <1495786658-18063-21-git-send-email-adrian.hunter@intel.com> <1498040239-32418-1-git-send-email-adrian.hunter@intel.com> <20170621135145.GO13640@kernel.org> <66cdc4e6-58a4-e365-8a76-112daf71baf9@intel.com> <20170621172911.GQ13640@kernel.org> From: Adrian Hunter Organization: Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki Message-ID: <0d5f93ef-f5c9-5185-c1f6-f176f8f533ea@intel.com> Date: Wed, 21 Jun 2017 23:20:03 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.1 MIME-Version: 1.0 In-Reply-To: <20170621172911.GQ13640@kernel.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 06/21/2017 08:29 PM, Arnaldo Carvalho de Melo wrote: > Em Wed, Jun 21, 2017 at 07:41:04PM +0300, Adrian Hunter escreveu: >> On 06/21/2017 04:51 PM, Arnaldo Carvalho de Melo wrote: >>> Em Wed, Jun 21, 2017 at 01:17:19PM +0300, Adrian Hunter escreveu: >>>> +++ b/tools/perf/util/event.h >>>> @@ -252,6 +252,9 @@ enum auxtrace_error_type { >>>> PERF_AUXTRACE_ERROR_MAX >>>> }; >>> >>>> +/* Attribute type for custom synthesized events */ >>>> +#define PERF_TYPE_SYNTH 3000000000 >>> >>> Why don't you make it PERF_TYPE_MAX and bump PERF_TYPE_MAX by one? I.e. >>> this way we have what can be in attr.type in a nice enumeration, can >>> validate it more easily (attr.type < PERF_TYPE_MAX) and will not need to >>> do those conversions to/from OUTPUT_TYPE_/PERF_TYPE_). > >> PERF_TYPE_ is dynamically allocated above PERF_TYPE_MAX for PMUs. Presently >> perf_pmu_register() calls idr_alloc() with end=0 which limits the allocation >> to INT_MAX. > > Oh, forgot about that, guess a comment right beside PERF_TYPE_MAX is in > demand :-\ > > So why not: > > /* > * PERF_TYPE_ is dynamically allocated above PERF_TYPE_MAX for PMUs. Presently > * perf_pmu_register() calls idr_alloc() with end=0 which limits the allocation > * to INT_MAX. > */ > #define PERF_TYPE_SYNTH (INT_MAX + 1L) > > I.e. wouldn't be some arbitrarily huge value, but one right after what > was defined as the area for the dynamicly allocated PERF_TYPE_ > "namespace" for PMUs, right? That seems fine. Pedantically it should be (INT_MAX + 1U) otherwise it will be negative on a 32-bit system. > >>> Peter: now its not the PERF_RECORD_ namespace that userspaces want a >>> chunk of, its PERF_TYPE_, which so far has been pretty stable, grabing >>> _one_ for event synthesizing things like Intel PT (and ARM's coresight, >>> I think) directly at include/uapi/linux/perf_event.h's perf_type_id enum >>> looks cleaner, no? > > - Arnaldo >