Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2118098pxj; Thu, 20 May 2021 00:04:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzfLFau6QzUVRR4mTYmkk/VWSGdFX9JOC59y5D1UXWHv1jayMKHBYUFzCXjybYf2FxOBm2z X-Received: by 2002:a17:906:14c1:: with SMTP id y1mr3263034ejc.481.1621494283482; Thu, 20 May 2021 00:04:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621494283; cv=none; d=google.com; s=arc-20160816; b=kM+82N0MR8iEqo4CskX/rSPrs+lDEKP2in7mjBCMu9hnhAqc4g0eid75ArjVVDe79k a/cufkfUjil7Y617dRoGv6oGwgbG2jKGVypihrxgntjq52uPcsKHXb/GT35kjp5m1Vim TG0Lp9er4GMpxESQ24Bmild197BMUx5XTJOW4HYwBZmE2Opr3PiucAUl1eE+prDs03iX UdZRwRmAnhjz2cwJxWtV/34P4SlPs0LXvkSpbPO4X81DGT+sehT8SG/8mNezvT9NPV2p HlrIEhQe2ApxpUpFBktuz8a8ewk7iOXE5bZrOuzGAUMpJ6BnHplODRGA15UVcwZAtBVV TMbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:ironport-sdr:ironport-sdr; bh=/+H1QG8mhml1wL+MzaEoOIK6SyNZSPltdo96zRcIhf8=; b=onmG9hvj4Qs3FdCwa9BCpuLAY85NwXbY11XBTDHQNxiBxHpKmlRH4Mo0LUR7oBVSA2 J5Ux7veGN0TnwhcpBGcrUYhi2IUxEcLlXDfH4R0+EckicfUAxR7oSqRoL0HlH2udwfSJ WMZ7U7FTmXnWIOdXMX56eynGNWHxgOdJFh3RUkQ/ru0rAb78wt3aXgptjaSnk2ZwPdiL NWaL12oSw12waH+0fXB9r/Bc8tpa9vNAK/yq0Pi8X9lGa9UGqHEGYkdkf+zAmukukouO P3nrFeMlMteZE9DanKdw6EXHxcr7beNbFGlE3NX8qa5M9uf2oFGoy9YtASkbFeLttVUs fVKg== 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 b6si2382838ejb.158.2021.05.20.00.04.19; Thu, 20 May 2021 00:04:43 -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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230495AbhETHDl (ORCPT + 99 others); Thu, 20 May 2021 03:03:41 -0400 Received: from mga05.intel.com ([192.55.52.43]:53040 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230460AbhETHDi (ORCPT ); Thu, 20 May 2021 03:03:38 -0400 IronPort-SDR: pO24zgEBxdNL/xg/o7dmURGISaU9tOlYKkh4IOFQZ42kjyf7IF7g+BWJlHTuL024qD/WC4M67D z0cQjx2QDo0w== X-IronPort-AV: E=McAfee;i="6200,9189,9989"; a="286691074" X-IronPort-AV: E=Sophos;i="5.82,313,1613462400"; d="scan'208";a="286691074" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 May 2021 00:02:17 -0700 IronPort-SDR: gJ18iSheBGtxdrVlC0gqsqOle0u4CpiiIB50yMdhowyIB3fkAOqLNz0bcW7eWgLGQoFu1Vhb2n LQ61Dd6oNnlQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,313,1613462400"; d="scan'208";a="543206925" Received: from kbl-ppc.sh.intel.com ([10.239.159.163]) by fmsmga001.fm.intel.com with ESMTP; 20 May 2021 00:02:15 -0700 From: Jin Yao To: 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, Jin Yao Subject: [PATCH v1 5/5] perf c2c: Support record for hybrid platform Date: Thu, 20 May 2021 15:00:40 +0800 Message-Id: <20210520070040.710-6-yao.jin@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210520070040.710-1-yao.jin@linux.intel.com> References: <20210520070040.710-1-yao.jin@linux.intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Support 'perf c2c record' for hybrid platform. On hybrid platform, such as Alderlake, when executing 'perf c2c record', it actually calls: record -W -d --phys-data --sample-cpu -e {cpu_core/mem-loads-aux/,cpu_core/mem-loads,ldlat=30/}:P -e cpu_atom/mem-loads,ldlat=30/P -e cpu_core/mem-stores/P -e cpu_atom/mem-stores/P Signed-off-by: Jin Yao --- tools/perf/builtin-c2c.c | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c index a4fd375acdd1..70804ad9017a 100644 --- a/tools/perf/builtin-c2c.c +++ b/tools/perf/builtin-c2c.c @@ -2907,8 +2907,9 @@ static const char * const *record_mem_usage = __usage_record; static int perf_c2c__record(int argc, const char **argv) { - int rec_argc, i = 0, j; + int rec_argc, i = 0, j, rec_nr = 0; const char **rec_argv; + char **rec_tmp; int ret; bool all_user = false, all_kernel = false; bool event_set = false; @@ -2932,11 +2933,17 @@ static int perf_c2c__record(int argc, const char **argv) argc = parse_options(argc, argv, options, record_mem_usage, PARSE_OPT_KEEP_UNKNOWN); - rec_argc = argc + 11; /* max number of arguments */ + rec_argc = argc + 64; /* max number of arguments */ rec_argv = calloc(rec_argc + 1, sizeof(char *)); if (!rec_argv) return -1; + rec_tmp = calloc(rec_argc + 1, sizeof(char *)); + if (!rec_tmp) { + free(rec_argv); + return -1; + } + rec_argv[i++] = "record"; if (!event_set) { @@ -2964,21 +2971,9 @@ static int perf_c2c__record(int argc, const char **argv) rec_argv[i++] = "--phys-data"; rec_argv[i++] = "--sample-cpu"; - for (j = 0; j < PERF_MEM_EVENTS__MAX; j++) { - e = perf_mem_events__ptr(j); - if (!e->record) - continue; - - if (!e->supported) { - pr_err("failed: event '%s' not supported\n", - perf_mem_events__name(j, NULL)); - free(rec_argv); - return -1; - } - - rec_argv[i++] = "-e"; - rec_argv[i++] = perf_mem_events__name(j, NULL); - } + ret = perf_mem_events__record_args(rec_argv, &i, rec_tmp, &rec_nr); + if (ret) + goto out; if (all_user) rec_argv[i++] = "--all-user"; @@ -3002,6 +2997,13 @@ static int perf_c2c__record(int argc, const char **argv) } ret = cmd_record(i, rec_argv); +out: + for (i = 0; i < rec_nr; i++) { + if (rec_tmp[i]) + free(rec_tmp[i]); + } + + free(rec_tmp); free(rec_argv); return ret; } -- 2.17.1