Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp4258845ybp; Mon, 7 Oct 2019 05:55:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqxkIe5nxqJiildtXrkM2Vu3f0HPq0XFCtPagmKt18jKisIOQH30o70Ms497gBp8dSt3XL3N X-Received: by 2002:a17:906:19c9:: with SMTP id h9mr23828397ejd.193.1570452923714; Mon, 07 Oct 2019 05:55:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570452923; cv=none; d=google.com; s=arc-20160816; b=av/tdGd6ogPuijl+4m6KBouCWZwkRlGvvfqPUNEnBl9wpFsPwn1z/QOxo6k0P6QbJA O5/lnzZiTeiOhWcOaDPt9Psn8ucdRY+BsOh1R6qTsXpeUfgkFqT6dhlbeiaUqHQkaTSC aPdNLpYw89erPTmrEBKnkMjy7ofHiVwxoISWx3K4x8VJq7fnI/FZX0NeJibpELboLHK3 u5cyv7CTMcRmkw8EtFVAxOmx6FDfyO4TQ1RpggSFl2wa9Bw15Nm6FqbWt9M9MdYfAROg isAzmdPQW4Jwf4Zi0ucjaRsclOkGcb1+8+9/VW24Xqed72fBwWKVkNWWy41cBGq6ajWx fbsQ== 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=PTFCRaAY0kf64QLRlEJdhkLQ/FvaCMnHswRELFojUyM=; b=yt/53hn7/1qJQ4eRY9jAmdpaj//98usO9SoklWesPtPRtCcvcmbV+CTqvV35taeqxP oOYteuFvywAOTWxtj4OlHW2byBBMHCqn13/VzZD4ZZY8XYy0rqqSaiPk8H/Qgg2Ol8IT mIOatDR910mpc2BJroBTzW2mX0AglNt+7e7iAz5NdssSrAmmjSSVgOf0RM/ugmhD4Txn NQWFGNq82YnDmy1IngHFg8N71Y8X/aTh1H66oe+q34grEmCVNDkQlXEI3FfBFz5cag3u NyCkuYBVspLXRn7tZw0FLEP/lU2mTG/XESoDqc8TpDL8/w+Gq5VaV8yi9HGXRBsafhL+ kHnA== 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 q4si6830845eji.152.2019.10.07.05.55.00; Mon, 07 Oct 2019 05:55:23 -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 S1728232AbfJGMyV (ORCPT + 99 others); Mon, 7 Oct 2019 08:54:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48890 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728207AbfJGMyR (ORCPT ); Mon, 7 Oct 2019 08:54:17 -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 4CE99308FC4B; Mon, 7 Oct 2019 12:54:17 +0000 (UTC) Received: from krava.brq.redhat.com (unknown [10.43.17.61]) by smtp.corp.redhat.com (Postfix) with ESMTP id A79C75ED21; Mon, 7 Oct 2019 12:54:15 +0000 (UTC) From: Jiri Olsa To: Arnaldo Carvalho de Melo Cc: Alexander Shishkin , Michael Petlan , Namhyung Kim , Peter Zijlstra , lkml , Ingo Molnar Subject: [PATCH 14/36] libperf: Add perf_evlist__mmap_ops function Date: Mon, 7 Oct 2019 14:53:22 +0200 Message-Id: <20191007125344.14268-15-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.5.16 (mx1.redhat.com [10.5.110.43]); Mon, 07 Oct 2019 12:54:17 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org To be able to pass specific callbacks to evlist's mmap. There will be specific call to this function from perf's evlist__mmap() and libperf's perf_evlist__mmap() functions in following changes. 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-54-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/lib/evlist.c | 24 ++++++++++++++++++------ tools/perf/lib/include/internal/evlist.h | 8 ++++++++ 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/tools/perf/lib/evlist.c b/tools/perf/lib/evlist.c index 250ad5752589..88d63f5cd9ca 100644 --- a/tools/perf/lib/evlist.c +++ b/tools/perf/lib/evlist.c @@ -472,12 +472,16 @@ mmap_per_cpu(struct perf_evlist *evlist, struct perf_mmap_param *mp) return -1; } -int perf_evlist__mmap(struct perf_evlist *evlist, int pages) +int perf_evlist__mmap_ops(struct perf_evlist *evlist, + struct perf_evlist_mmap_ops *ops, + struct perf_mmap_param *mp) { struct perf_evsel *evsel; const struct perf_cpu_map *cpus = evlist->cpus; const struct perf_thread_map *threads = evlist->threads; - struct perf_mmap_param mp; + + if (!ops) + return -EINVAL; if (!evlist->mmap) evlist->mmap = perf_evlist__alloc_mmap(evlist, false); @@ -491,13 +495,21 @@ int perf_evlist__mmap(struct perf_evlist *evlist, int pages) return -ENOMEM; } + if (perf_cpu_map__empty(cpus)) + return mmap_per_thread(evlist, mp); + + return mmap_per_cpu(evlist, mp); +} + +int perf_evlist__mmap(struct perf_evlist *evlist, int pages) +{ + struct perf_mmap_param mp; + struct perf_evlist_mmap_ops ops; + evlist->mmap_len = (pages + 1) * page_size; mp.mask = evlist->mmap_len - page_size - 1; - if (perf_cpu_map__empty(cpus)) - return mmap_per_thread(evlist, &mp); - - return mmap_per_cpu(evlist, &mp); + return perf_evlist__mmap_ops(evlist, &ops, &mp); } void perf_evlist__munmap(struct perf_evlist *evlist) diff --git a/tools/perf/lib/include/internal/evlist.h b/tools/perf/lib/include/internal/evlist.h index 4438a19ceba3..e5f092ff6202 100644 --- a/tools/perf/lib/include/internal/evlist.h +++ b/tools/perf/lib/include/internal/evlist.h @@ -11,6 +11,7 @@ struct perf_cpu_map; struct perf_thread_map; +struct perf_mmap_param; struct perf_evlist { struct list_head entries; @@ -26,10 +27,17 @@ struct perf_evlist { struct perf_mmap *mmap_ovw; }; +struct perf_evlist_mmap_ops { +}; + int perf_evlist__alloc_pollfd(struct perf_evlist *evlist); int perf_evlist__add_pollfd(struct perf_evlist *evlist, int fd, void *ptr, short revent); +int perf_evlist__mmap_ops(struct perf_evlist *evlist, + struct perf_evlist_mmap_ops *ops, + struct perf_mmap_param *mp); + /** * __perf_evlist__for_each_entry - iterate thru all the evsels * @list: list_head instance to iterate -- 2.21.0