Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp1411972ybe; Fri, 13 Sep 2019 16:34:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqxpyHSLTIwbjpi3fmvwkIDE/RRTRrXxvuDWLgtjUBnyAeI+fHNn+sWDcS6ADEl4+EonKWdq X-Received: by 2002:aa7:de0b:: with SMTP id h11mr49580927edv.109.1568417688703; Fri, 13 Sep 2019 16:34:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568417688; cv=none; d=google.com; s=arc-20160816; b=HId8n315qptRHaCC9J4rlrxD9fTYDsc7ccQgO0Vz6zckvhorH2zHPJt6KtYwmUVTt4 hegtuXZ7xv4jWrMHfdxXhFPRi1/f4HLEPxat1YcAwIYSspL1bAFRqYL4sxr2gHbcxlBl oEexxYW/RfhGY/rL9Tq9gDomU69Hy64MWFHllS19OlzW+sIdAhpFnmwAFqoEhsW9JU+B pWfyklQN3pys3HpQBH0oIAzWuHZuab9wgNsPvszh/zRuibB827YTLqBn6yig7B3a3/6V 25MK1Mm6rHWPBUT5phmkMN1pj7u1TmxVaN5iCoG6E8/HPKYPD/z7imipOdeuquiaBoQ/ SF3Q== 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=E6rnN7RfsEXLJLxkcjOt0PkJxMm3dYJJvGF1kavHr5I=; b=M57sTmpYpPKKgcBR47CLB7sQuWzfZIArVelyh7ePjZW0P5c8sEJBtrgibmYa9Z+d5Y 8QBrZ/v1NCi9UFnaQB+4X5c7pmHBklbAjd6JKxOTcv1T5TRpYaIgMTntppno3Hhd/S/U E3rdF3utbSB/F1Z77TcVEYl4J87vI4Em/5WXxqd9vsbZ/UWaDPebSvVcmFPbRs9IotHE dnNZV1g3muCFv3XSTccVYcVxsDtd9PSMMmQ5Jdny+Yhq/xyyCFw6u2eBn49krUI//4u6 wWAdfO8TZynXtpnLXRW44NZuaZUwztMD6PeL/qNRnseTkLg+mNniz4c4ZCrO7EBxpA98 PgfA== 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 c6si17543636edc.291.2019.09.13.16.34.24; Fri, 13 Sep 2019 16:34:48 -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 S2391522AbfIMN0K (ORCPT + 99 others); Fri, 13 Sep 2019 09:26:10 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36412 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391511AbfIMN0J (ORCPT ); Fri, 13 Sep 2019 09:26:09 -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 B49FB300BEA4; Fri, 13 Sep 2019 13:26:08 +0000 (UTC) Received: from krava.brq.redhat.com (unknown [10.43.17.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id 19B8D5C1D4; Fri, 13 Sep 2019 13:26:06 +0000 (UTC) From: Jiri Olsa To: Arnaldo Carvalho de Melo Cc: lkml , Ingo Molnar , Namhyung Kim , Alexander Shishkin , Peter Zijlstra , Michael Petlan Subject: [PATCH 53/73] libperf: Add perf_evlist__mmap_ops function Date: Fri, 13 Sep 2019 15:23:35 +0200 Message-Id: <20190913132355.21634-54-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.42]); Fri, 13 Sep 2019 13:26:08 +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. Link: http://lkml.kernel.org/n/tip-mjpp6cdpckq2yj52tpab1eq6@git.kernel.org Signed-off-by: Jiri Olsa --- tools/perf/lib/evlist.c | 28 +++++++++++++++++------- tools/perf/lib/include/internal/evlist.h | 8 +++++++ 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/tools/perf/lib/evlist.c b/tools/perf/lib/evlist.c index 168bc5d0a1c8..0f103c10d8ca 100644 --- a/tools/perf/lib/evlist.c +++ b/tools/perf/lib/evlist.c @@ -443,15 +443,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 (!evlist->mmap && perf_evlist__alloc_maps(evlist)) - return -ENOMEM; + if (!ops) + return -EINVAL; perf_evlist__for_each_entry(evlist, evsel) { if ((evsel->attr.read_format & PERF_FORMAT_ID) && @@ -460,13 +461,24 @@ 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; + + if (!evlist->mmap && perf_evlist__alloc_maps(evlist)) + return -ENOMEM; + 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 b136d1b4ea72..5a8706a81c0d 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