Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp4262745ybp; Mon, 7 Oct 2019 05:59:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqyiddoeGxp/r0ybKOXB4anu/nGO4vcKU8UjloWVWD/Rcbh53CA46uD3xLGEGhmrlUBNY/90 X-Received: by 2002:a05:6402:1583:: with SMTP id c3mr29136178edv.286.1570453159462; Mon, 07 Oct 2019 05:59:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570453159; cv=none; d=google.com; s=arc-20160816; b=fzrKLOesXQ3sv4ywTEdodjNKiTs1wLlqc1Llms2DE0SsoVxRI1S5zzyxlqVOIZQJHw E9JKhDW0+kM/fXZMTP60VoAYAnVmr/AQpHrNb6Gv67sTiF5Yq+Rx4ishxtIrEW9Wlsci HEWnY2sAwfbosWNjyr2wW6V2ZemCkKUuf9zAHeVfiRILLhxN2Zm2slq1QqqPjk58JZzd Lx1dY8EcEC4m1YURN5SJJU9JfXBFXcstO7xv+HS3CY4oxI3MbV2NTn8Mx4EjEsXK/Od3 rROhhtOpGqjhZe4ouphtI18G55IQs1in8S+6LP28Udyn4fG6HyKh9dPARbQ/fcrLq5EI VgtQ== 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=lwJdzOJV5JpTKLxtzialQUrYtWjhl22ZrCN/Z26PgIE=; b=pgLI8iODnph1rlqxu0s1ZF2O2oZur03+4w6oHLsorVcEqVfxI4U1VLN4kdfawah12X 93rEXu3gpWFG7YtgCP2S37C0D5pQYFR4i5UinewFijPAWEzhva23mC2+4NgZv2MVGc75 dm/maCXFa976JNBNBSkUIEs5V56nFQnYgd0cBK0A6ewcMZ4I6gK7t3icLytvmgHIYI1F W8HIc8SIeUcrFLKDIez+dZeQtaq7T4ghjroBU3vSMOcoqtcvdz28zReeUPJ3W2mSfNsA /Db1Ah6wBq1lbOAcZ9YGuQUdIyvxRSfQstXonM16HBRUTwFcVrahwAOb+DacJ+RRihhq IBdA== 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 h13si8721451edh.242.2019.10.07.05.58.56; Mon, 07 Oct 2019 05:59:19 -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 S1728658AbfJGMzy (ORCPT + 99 others); Mon, 7 Oct 2019 08:55:54 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59480 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727787AbfJGMyV (ORCPT ); Mon, 7 Oct 2019 08:54:21 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B1070883853; Mon, 7 Oct 2019 12:54:20 +0000 (UTC) Received: from krava.brq.redhat.com (unknown [10.43.17.61]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9F2405D9CC; Mon, 7 Oct 2019 12:54:17 +0000 (UTC) From: Jiri Olsa To: Arnaldo Carvalho de Melo Cc: Alexander Shishkin , Michael Petlan , Namhyung Kim , Peter Zijlstra , lkml , Ingo Molnar Subject: [PATCH 15/36] libperf: Add perf_evlist_mmap_ops::idx callback Date: Mon, 7 Oct 2019 14:53:23 +0200 Message-Id: <20191007125344.14268-16-jolsa@kernel.org> In-Reply-To: <20191007125344.14268-1-jolsa@kernel.org> References: <20191007125344.14268-1-jolsa@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.69]); Mon, 07 Oct 2019 12:54:20 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add the 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 use this callback to set the aux index. Signed-off-by: Jiri Olsa Cc: Alexander Shishkin Cc: Michael Petlan Cc: Namhyung Kim Cc: Peter Zijlstra Link: http://lore.kernel.org/lkml/20190913132355.21634-55-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- 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 88d63f5cd9ca..3832d3e9a3b4 100644 --- a/tools/perf/lib/evlist.c +++ b/tools/perf/lib/evlist.c @@ -426,7 +426,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); @@ -435,6 +436,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; @@ -448,7 +452,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); @@ -458,6 +463,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)) @@ -496,15 +504,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 }; evlist->mmap_len = (pages + 1) * page_size; mp.mask = evlist->mmap_len - page_size - 1; diff --git a/tools/perf/lib/include/internal/evlist.h b/tools/perf/lib/include/internal/evlist.h index e5f092ff6202..053f620696f3 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