Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2510981pxb; Mon, 18 Jan 2021 21:42:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJx8BWjOV0x0k9tain97QwOIGJBpobpnWZBWbtH9MInLZ4jYrD5xcnYNK4tHBDSKuLGNWEQo X-Received: by 2002:a17:906:e43:: with SMTP id q3mr1800661eji.493.1611034953420; Mon, 18 Jan 2021 21:42:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611034953; cv=none; d=google.com; s=arc-20160816; b=GrPEdFqg6TsuQRlS9jfbeziPT4ymkMPAcSmkTX/21Y5Ba6uMxXlpEZwwrhPPxRTJdM CA02q2R8MpkQV8TLgLze3r2/fVr1JGrtrnR9gPfziNnLvWqlf9j7FsNvzu0CbGi/T+Kf c6cSlHjj/iYpijWvTuR4WZi0YnM1XppUEV4CDbV8FaBIAXWPZb3/QGFSzKaA63M47DGK jnD60XKrwwBtt+jdw+orxvLaibtv0VBtxh+CNMv0ogY59rM/Uk8//JdSt+t8pV/IATBD kPCArJUv3FSKkDlvK8KeVmS/VVpLFwYeKwxgTsS+wt9uiWHjuIxDmWRDqnwxZ88TtpcH ccVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:references:cc :to:from:subject:ironport-sdr:ironport-sdr; bh=6Pbh85oxgkX3LtKDJbVeCVGbJLLhTMB0DvuafsMkjag=; b=bzdmmLafCcvS+GDImxnSUcPqDmkaBeVmvMrv8rsAKhEPeVL3gFp5xwzZHZNDuWBJty vgw2cjwt74i8sz847a3hqQhtggYr6e5Oqk7aTv0944EJMc6Wr5NgsdXajGM7eWyxZqCS q4Wtfjv1PmMx8qc/rwNCxzbmKH67aJYgH3nVM0EMwu1IBU+nFnxNiSl5gtREtmBDAgBn Hz1EN++B8De6nB/BGkh7jd62IGe8gY30GL5gAx7Y1D5vw6NVMwED8CeKTnV9VFUxA4yt 7kwV3HnnHl5fNBigiIUo91ewvsr0td5QMLiyo8AzL4X4zZCFm916bgP8KUgUxEhkuXUC EehA== 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gu1si7406366ejb.20.2021.01.18.21.42.10; Mon, 18 Jan 2021 21:42:33 -0800 (PST) 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732984AbhASAvq (ORCPT + 99 others); Mon, 18 Jan 2021 19:51:46 -0500 Received: from mga04.intel.com ([192.55.52.120]:48528 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732808AbhASAvp (ORCPT ); Mon, 18 Jan 2021 19:51:45 -0500 IronPort-SDR: L87LnFWIwdanQv6Quz8d9Kw0w8U9zFdf5D4RYwMG90vLh5r0ubinpzn0GesiHFtyeyLBnO/rCj N0w/gcWZ185g== X-IronPort-AV: E=McAfee;i="6000,8403,9868"; a="176290975" X-IronPort-AV: E=Sophos;i="5.79,357,1602572400"; d="scan'208";a="176290975" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Jan 2021 16:49:57 -0800 IronPort-SDR: E6wtFFaIku3AzslxS651+GFazQ8xrTMwUZbFMyUtMQJCa07GRnXSMpKQ0o/PE1UuuTpatxP8MT UKsWgHt/0pRg== X-IronPort-AV: E=Sophos;i="5.79,357,1602572400"; d="scan'208";a="426287838" Received: from yjin15-mobl1.ccr.corp.intel.com (HELO [10.238.4.27]) ([10.238.4.27]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Jan 2021 16:49:54 -0800 Subject: Re: [PATCH v2] perf script: Fix overrun issue for dynamically-allocated pmu type number From: "Jin, Yao" To: Adrian Hunter , acme@kernel.org, jolsa@kernel.org, peterz@infradead.org, mingo@redhat.com, alexander.shishkin@linux.intel.com Cc: Linux-kernel@vger.kernel.org, ak@linux.intel.com, kan.liang@intel.com, yao.jin@intel.com References: <20201209005828.21302-1-yao.jin@linux.intel.com> <3fcdc860-d858-0166-de23-34fc6fe5c1cd@intel.com> <18fde68f-0d24-5bcb-38e1-11dcf6f70bc1@linux.intel.com> Message-ID: <934aa658-1147-8882-99c2-68561b42d63d@linux.intel.com> Date: Tue, 19 Jan 2021 08:49:52 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.1 MIME-Version: 1.0 In-Reply-To: <18fde68f-0d24-5bcb-38e1-11dcf6f70bc1@linux.intel.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Arnaldo, Jiri, On 12/25/2020 9:10 AM, Jin, Yao wrote: > Hi Arnaldo, Jiri, > > On 12/11/2020 2:10 PM, Adrian Hunter wrote: >> On 9/12/20 2:58 am, Jin Yao wrote: >>> When unpacking the event which is from dynamic pmu, the array >>> output[OUTPUT_TYPE_MAX] may be overrun. For example, type number of >>> SKL uncore_imc is 10, but OUTPUT_TYPE_MAX is 7 now (OUTPUT_TYPE_MAX = >>> PERF_TYPE_MAX + 1). >>> >>> /* In builtin-script.c */ >>> process_event() >>> { >>>          unsigned int type = output_type(attr->type); >>> >>>          if (output[type].fields == 0) >>>                  return; >>> } >>> >>> output[10] is overrun. >>> >>> Create a type OUTPUT_TYPE_OTHER for dynamic pmu events, then >>> output_type(attr->type) will return OUTPUT_TYPE_OTHER here. >>> >>> Note that if PERF_TYPE_MAX ever changed, then there would be a conflict >>> between old perf.data files that had a dynamicaliy allocated PMU number >>> that would then be the same as a fixed PERF_TYPE. >>> >>> Example: >>> >>> perf record --switch-events -C 0 -e >>> "{cpu-clock,uncore_imc/data_reads/,uncore_imc/data_writes/}:SD" -a -- sleep 1 >>> perf script >>> >>> Before: >>>           swapper     0 [000] 1479253.987551:     277766               cpu-clock: >>> ffffffff9d4ddb6f cpuidle_enter_state+0xdf ([kernel.kallsyms]) >>>           swapper     0 [000] 1479253.987797:     246709               cpu-clock: >>> ffffffff9d4ddb6f cpuidle_enter_state+0xdf ([kernel.kallsyms]) >>>           swapper     0 [000] 1479253.988127:     329883               cpu-clock: >>> ffffffff9d4ddb6f cpuidle_enter_state+0xdf ([kernel.kallsyms]) >>>           swapper     0 [000] 1479253.988273:     146393               cpu-clock: >>> ffffffff9d4ddb6f cpuidle_enter_state+0xdf ([kernel.kallsyms]) >>>           swapper     0 [000] 1479253.988523:     249977               cpu-clock: >>> ffffffff9d4ddb6f cpuidle_enter_state+0xdf ([kernel.kallsyms]) >>>           swapper     0 [000] 1479253.988877:     354090               cpu-clock: >>> ffffffff9d4ddb6f cpuidle_enter_state+0xdf ([kernel.kallsyms]) >>>           swapper     0 [000] 1479253.989023:     145940               cpu-clock: >>> ffffffff9d4ddb6f cpuidle_enter_state+0xdf ([kernel.kallsyms]) >>>           swapper     0 [000] 1479253.989383:     359856               cpu-clock: >>> ffffffff9d4ddb6f cpuidle_enter_state+0xdf ([kernel.kallsyms]) >>>           swapper     0 [000] 1479253.989523:     140082               cpu-clock: >>> ffffffff9d4ddb6f cpuidle_enter_state+0xdf ([kernel.kallsyms]) >>> >>> After: >>>           swapper     0 [000] 1397040.402011:     272384               cpu-clock: >>> ffffffff9d4ddb6f cpuidle_enter_state+0xdf ([kernel.kallsyms]) >>>           swapper     0 [000] 1397040.402011:       5396  uncore_imc/data_reads/: >>>           swapper     0 [000] 1397040.402011:        967 uncore_imc/data_writes/: >>>           swapper     0 [000] 1397040.402259:     249153               cpu-clock: >>> ffffffff9d4ddb6f cpuidle_enter_state+0xdf ([kernel.kallsyms]) >>>           swapper     0 [000] 1397040.402259:       7231  uncore_imc/data_reads/: >>>           swapper     0 [000] 1397040.402259:       1297 uncore_imc/data_writes/: >>>           swapper     0 [000] 1397040.402508:     249108               cpu-clock: >>> ffffffff9d4ddb6f cpuidle_enter_state+0xdf ([kernel.kallsyms]) >>>           swapper     0 [000] 1397040.402508:       5333  uncore_imc/data_reads/: >>>           swapper     0 [000] 1397040.402508:       1008 uncore_imc/data_writes/: >>> >>> Signed-off-by: Jin Yao >> >> Acked-by: Adrian Hunter >> > > Can this patch be accepted? :) > > Thanks > Jin Yao > Can this bug fix be accepted or anything else I need to improve? Thanks Jin Yao