Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp796041ybe; Fri, 13 Sep 2019 06:31:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqyFQu5s+/q4KCFjQ7IhNSWlgnjFPjXhRyNNEKIcaEl624Kz9QV0IgSJg34RHTC/ga5pxvE5 X-Received: by 2002:a50:d949:: with SMTP id u9mr8451582edj.142.1568381489675; Fri, 13 Sep 2019 06:31:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568381489; cv=none; d=google.com; s=arc-20160816; b=zElTCl7pu+fCJ9U9Hv5lflH2igYpdrWdXFjwEGADWWtNpxbM2okzE+GvaNqONyrFEf zcc7beybtbV8QnnFARvcvOb/KsWW9aYgG1ADdMJDAvvbuLrdBtHkTqaLf1hqWuvwNTff J8MTdVsTByAUnAi283aJcEDEviRCI9KqZClG9CDYk4WCE8BXRc4Cp6l+edE0qE4bF4jh JFzTfnsCYF/od9Xl+P/Uy1K7B84WWiVGep2+yZpE/uy+BXi5NU0juorDgIZHPoSLfDTu WSCUz2sH3qKC11cDvlXLM/OlEZTQlXiPs5kkqel22CR4/7t7cDLVPPdU6rroTCYneznk lHwQ== 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=qCXpoHjo25aPT7C7B8U+EDc77gXIXWYZg8RJrLvRyMQ=; b=Dk9d5hACUrCdCFQfv2fC04ZAGnofDyu0jyStSktJISlv3WMPEWOVdRusZvdSlcl/04 Qu/shzX8EW6qECc9JgOQ0Dal3lA1TzurI1PeV8GboNiWkQuX0OyWYvKUGVvA2ANtQIch ge8TWWmBYKPy6XoMBlySj3AZN5isJS6fkB6I6GKUQw3fbylKSX2a6feMHez8+QGKpJRH Etj7nPG6cA1j8iY5WpF9fCd+arofA1gwFgRaipfV8pVuRX7YvlVgCUsgQJIIJTKHIUCm 4Z50y9b7zkw13gymGg0DbvigDYZHvkNyhRFPoMIkn9KvRi+mha1UxeB5yV+aqFX60LgD qxCg== 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 k18si14098359ejo.145.2019.09.13.06.30.58; Fri, 13 Sep 2019 06:31:29 -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 S2391554AbfIMN0S (ORCPT + 99 others); Fri, 13 Sep 2019 09:26:18 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49636 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391546AbfIMN0Q (ORCPT ); Fri, 13 Sep 2019 09:26:16 -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 67C2781129; Fri, 13 Sep 2019 13:26:16 +0000 (UTC) Received: from krava.brq.redhat.com (unknown [10.43.17.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id ADEC55C1D4; Fri, 13 Sep 2019 13:26:13 +0000 (UTC) From: Jiri Olsa To: Arnaldo Carvalho de Melo Cc: lkml , Ingo Molnar , Namhyung Kim , Alexander Shishkin , Peter Zijlstra , Michael Petlan Subject: [PATCH 56/73] libperf: Add perf_evlist_mmap_ops::mmap callback Date: Fri, 13 Sep 2019 15:23:38 +0200 Message-Id: <20190913132355.21634-57-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.5.16 (mx1.redhat.com [10.5.110.27]); Fri, 13 Sep 2019 13:26:16 +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::mmap callback to be called in mmap_per_evsel to actually mmap the map. Adding libperf's perf_evlist__mmap_cb_mmap function as libperf's mmap callback. Link: http://lkml.kernel.org/n/tip-9cksnv3xbb1eset7ge67at4a@git.kernel.org Signed-off-by: Jiri Olsa --- tools/perf/lib/evlist.c | 15 ++++++++++++--- tools/perf/lib/include/internal/evlist.h | 3 +++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/tools/perf/lib/evlist.c b/tools/perf/lib/evlist.c index 8caced7d489a..ec83022cd62f 100644 --- a/tools/perf/lib/evlist.c +++ b/tools/perf/lib/evlist.c @@ -341,6 +341,14 @@ perf_evlist__mmap_cb_new(struct perf_evlist *evlist, bool overwrite, int idx) return map; } +static int +perf_evlist__mmap_cb_mmap(struct perf_mmap *map, struct perf_mmap_param *mp, + int output, int cpu) +{ + refcount_set(&map->refcnt, 2); + return perf_mmap__mmap(map, mp, output, cpu); +} + static int mmap_per_evsel(struct perf_evlist *evlist, struct perf_evlist_mmap_ops *ops, int idx, struct perf_mmap_param *mp, int cpu_idx, @@ -379,7 +387,7 @@ mmap_per_evsel(struct perf_evlist *evlist, struct perf_evlist_mmap_ops *ops, if (*output == -1) { *output = fd; - if (perf_mmap__mmap(map, mp, *output, evlist_cpu) < 0) + if (ops->mmap(map, mp, *output, evlist_cpu) < 0) return -1; } else { if (ioctl(fd, PERF_EVENT_IOC_SET_OUTPUT, *output) != 0) @@ -471,7 +479,7 @@ int perf_evlist__mmap_ops(struct perf_evlist *evlist, const struct perf_cpu_map *cpus = evlist->cpus; const struct perf_thread_map *threads = evlist->threads; - if (!ops || !ops->new) + if (!ops || !ops->new || !ops->mmap) return -EINVAL; perf_evlist__for_each_entry(evlist, evsel) { @@ -491,7 +499,8 @@ int perf_evlist__mmap(struct perf_evlist *evlist, int pages) { struct perf_mmap_param mp; struct perf_evlist_mmap_ops ops = { - .new = perf_evlist__mmap_cb_new, + .new = perf_evlist__mmap_cb_new, + .mmap = perf_evlist__mmap_cb_mmap, }; if (!evlist->mmap && perf_evlist__alloc_maps(evlist)) diff --git a/tools/perf/lib/include/internal/evlist.h b/tools/perf/lib/include/internal/evlist.h index 3cb836912ee6..851837ce4ff8 100644 --- a/tools/perf/lib/include/internal/evlist.h +++ b/tools/perf/lib/include/internal/evlist.h @@ -31,10 +31,13 @@ typedef void (*perf_evlist_mmap__cb_idx_t)(struct perf_evlist*, struct perf_mmap_param*, int, bool); typedef struct perf_mmap* (*perf_evlist_mmap__cb_new_t)(struct perf_evlist*, bool, int); +typedef int +(*perf_evlist_mmap__cb_mmap_t)(struct perf_mmap*, struct perf_mmap_param*, int, int); struct perf_evlist_mmap_ops { perf_evlist_mmap__cb_idx_t idx; perf_evlist_mmap__cb_new_t new; + perf_evlist_mmap__cb_mmap_t mmap; }; int perf_evlist__alloc_pollfd(struct perf_evlist *evlist); -- 2.21.0