Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp914438ybe; Fri, 13 Sep 2019 08:15:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqyAsT8ujfEjYFHk0+j9Ivm4sMG0EKyluvwjeb3eLe3+lc3VVCLwX5FXgtfrRSAftDeFi0i0 X-Received: by 2002:a50:d55e:: with SMTP id f30mr49079382edj.35.1568387733496; Fri, 13 Sep 2019 08:15:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568387733; cv=none; d=google.com; s=arc-20160816; b=cPrxE4UYwI0UYhy0QQNcuqVdacPdKkng+vSUpr4QIYL5vog70yNCqi1pBB/arxF2u1 3Rfbjlj+zsjx7yr4InwhpWlFpWexNF+7bDSI6iXeE8En1sFIuDagBTEQ+/EbwVePSdcE 8EQ46lwC4g/4VtSExeAQGpqRJOsjHIInY2XQNFEWz2vI5T3OWPQLU4b0Hr4Y4PfGvI2U fPtRtsNOPZUKnGYQZGRPzaYgvRevRGI2treAZsiVsVMbb2KLXtHiXb+2FGnzSoAKTzDc S4yDMGdEk/exeniyq2kVTRMo0tY0qolu3978SZY/EwZkwxDBAoqR5s8SMsapsA9hSv/o b24g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=9SIOut3y4O/psV3v39lzsm5DpPoYKZOs0iCi52reJnE=; b=AA/xlCG1tzYeTEqPZOrugIORlNEN43XACN/OHiSQBVjoW/0022/Frm5lIcWGdECRas P6ciEFMUFbZbIr5bMF0VuqBLP2TtwJgYrNvI6sN/jQ2ljOOsEwGbnFrHfI4KnPmJ+BrX Chm5gUApPO4CZ4n6x46/O6HJoxzJaeedJexGPA54FX7mR02lQTX0vWPTU3GEaYO9jbe8 QnnqoZDm5HMepLzZyp3IF4c68+eXl5M7MRkboVIVAdNEPvtO9li4Agde+8VaUBQ3/vCL qTnOjBI+nzvlgDHVG0Dp36+F7TdMqs+Hf1RMn12q8EjNLxxFE286NhMrtbf2Sr+cPPtV TThw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j47si17761650ede.117.2019.09.13.08.15.09; Fri, 13 Sep 2019 08:15:33 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391534AbfIMN0N (ORCPT + 99 others); Fri, 13 Sep 2019 09:26:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45538 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391526AbfIMN0L (ORCPT ); Fri, 13 Sep 2019 09:26:11 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A882A806A40; Fri, 13 Sep 2019 13:26:10 +0000 (UTC) Received: from krava.brq.redhat.com (unknown [10.43.17.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0DE7A5C1D4; Fri, 13 Sep 2019 13:26:08 +0000 (UTC) From: Jiri Olsa To: Arnaldo Carvalho de Melo Cc: lkml , Ingo Molnar , Namhyung Kim , Alexander Shishkin , Peter Zijlstra , Michael Petlan Subject: [PATCH 54/73] libperf: Add perf_evlist_mmap_ops::idx callback Date: Fri, 13 Sep 2019 15:23:36 +0200 Message-Id: <20190913132355.21634-55-jolsa@kernel.org> In-Reply-To: <20190913132355.21634-1-jolsa@kernel.org> References: <20190913132355.21634-1-jolsa@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.67]); Fri, 13 Sep 2019 13:26:10 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Adding perf_evlist_mmap_ops::idx callback to be called in mmap_per_cpu and mmap_per_thread with current cpu and thread indexes. It's used by current aux code, so perf will used this callback to set aux index. Link: http://lkml.kernel.org/n/tip-smr1w2e6j37ncbmsd1eet228@git.kernel.org Signed-off-by: Jiri Olsa --- tools/perf/lib/evlist.c | 18 +++++++++++++----- tools/perf/lib/include/internal/evlist.h | 4 ++++ 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/tools/perf/lib/evlist.c b/tools/perf/lib/evlist.c index 0f103c10d8ca..67b5f14f738f 100644 --- a/tools/perf/lib/evlist.c +++ b/tools/perf/lib/evlist.c @@ -397,7 +397,8 @@ mmap_per_evsel(struct perf_evlist *evlist, int idx, } static int -mmap_per_thread(struct perf_evlist *evlist, struct perf_mmap_param *mp) +mmap_per_thread(struct perf_evlist *evlist, struct perf_evlist_mmap_ops *ops, + struct perf_mmap_param *mp) { int thread; int nr_threads = perf_thread_map__nr(evlist->threads); @@ -406,6 +407,9 @@ mmap_per_thread(struct perf_evlist *evlist, struct perf_mmap_param *mp) int output = -1; int output_overwrite = -1; + if (ops->idx) + ops->idx(evlist, mp, thread, false); + if (mmap_per_evsel(evlist, thread, mp, 0, thread, &output, &output_overwrite)) goto out_unmap; @@ -419,7 +423,8 @@ mmap_per_thread(struct perf_evlist *evlist, struct perf_mmap_param *mp) } static int -mmap_per_cpu(struct perf_evlist *evlist, struct perf_mmap_param *mp) +mmap_per_cpu(struct perf_evlist *evlist, struct perf_evlist_mmap_ops *ops, + struct perf_mmap_param *mp) { int nr_threads = perf_thread_map__nr(evlist->threads); int nr_cpus = perf_cpu_map__nr(evlist->cpus); @@ -429,6 +434,9 @@ mmap_per_cpu(struct perf_evlist *evlist, struct perf_mmap_param *mp) int output = -1; int output_overwrite = -1; + if (ops->idx) + ops->idx(evlist, mp, cpu, true); + for (thread = 0; thread < nr_threads; thread++) { if (mmap_per_evsel(evlist, cpu, mp, cpu, thread, &output, &output_overwrite)) @@ -462,15 +470,15 @@ int perf_evlist__mmap_ops(struct perf_evlist *evlist, } if (perf_cpu_map__empty(cpus)) - return mmap_per_thread(evlist, mp); + return mmap_per_thread(evlist, ops, mp); - return mmap_per_cpu(evlist, mp); + return mmap_per_cpu(evlist, ops, mp); } int perf_evlist__mmap(struct perf_evlist *evlist, int pages) { struct perf_mmap_param mp; - struct perf_evlist_mmap_ops ops; + struct perf_evlist_mmap_ops ops = { 0 }; if (!evlist->mmap && perf_evlist__alloc_maps(evlist)) return -ENOMEM; diff --git a/tools/perf/lib/include/internal/evlist.h b/tools/perf/lib/include/internal/evlist.h index 5a8706a81c0d..64522b8237be 100644 --- a/tools/perf/lib/include/internal/evlist.h +++ b/tools/perf/lib/include/internal/evlist.h @@ -27,7 +27,11 @@ struct perf_evlist { struct perf_mmap **mmap_ovw; }; +typedef void +(*perf_evlist_mmap__cb_idx_t)(struct perf_evlist*, struct perf_mmap_param*, int, bool); + struct perf_evlist_mmap_ops { + perf_evlist_mmap__cb_idx_t idx; }; int perf_evlist__alloc_pollfd(struct perf_evlist *evlist); -- 2.21.0