Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp4024769pxk; Tue, 22 Sep 2020 08:32:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyJmHf22o8Ui1J5TdeWaYDOtQ3I74oRTMd+V+Q7UWJI4+NsR0sDuaz2MV4Zzjkw5SubjpPS X-Received: by 2002:a17:906:1c13:: with SMTP id k19mr5518235ejg.384.1600788757404; Tue, 22 Sep 2020 08:32:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600788757; cv=none; d=google.com; s=arc-20160816; b=zE/crVeLrOUBeYy6fxYrxR5mh79NwfFXnU/X6Dej/K3AGXBkA/Q5Do+10eMhhJr3xH 85XgjY/uoCrGn5F7/72bdp/yqGlTdCYn8KVUDu3dg1sDKcu3akh3eATnke6zjSY2Bz6C xFJsV9jV/4QiczWwbUsBAitrX+JKAtY45hPMRTxv4zjxKsDrkYqBIy5D9te0wZKW19Vz nB0xG8YooWWLb++4lsIIsfOwTPG8DhBHQztnQQb+8OgP8nA0NRCLVLkaIKeX/S6beO8q EVZ40SIjlGzFvk3VBK8eFP0xRDNnowU+Xn/57fPmPeKKj04xvq16kVa2UWGQBqDVApl7 BP/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=8iWbBXf8ucYbbg/Dog3ytx9kayyr/XtpQc4F82NeBQA=; b=r4BcQ3tqV0ETo+vd9CignNZkxpqOC6iZNkS0GqKTn8ulj0mV8FMDZ3VLGIO9IflKqm x8HPpK6IGkj7sssk6yfypmsHp4pYo04b+4QgHrmLHXqofAenet6ONYWTjK9BoLp9PMk7 li32PmYzyitGpj+2aRIrtQGcBupqT4g3sLk4BcaQRWO1i/P2j52bSiJI/ONscJQCdnDZ 0aLyMPMiyUASayTP1+GQur1KQTSOS3zDGSt2ogF/tznIjALOd2EEq8/nwjUGUAVj7x/q jZCFnIBZ4ODqv1VY1YOxuj8Y3779McayxXWp8A2rqzxUW8olMS5iALIe7sE1iEJGRjxb x1SQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=IoYTiDH5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id nz19si10582453ejb.516.2020.09.22.08.32.13; Tue, 22 Sep 2020 08:32:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=IoYTiDH5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726676AbgIVP25 (ORCPT + 99 others); Tue, 22 Sep 2020 11:28:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:55906 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726566AbgIVP25 (ORCPT ); Tue, 22 Sep 2020 11:28:57 -0400 Received: from mail-oi1-f169.google.com (mail-oi1-f169.google.com [209.85.167.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A220323A1B for ; Tue, 22 Sep 2020 15:28:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600788536; bh=NfM22O9M2l3O3Bo5eJJMvQ2zjCKnu7yQnJxTZC7yw80=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=IoYTiDH581aeongwCcfXds522JnJN/olcO9Nez1Bs0LbHyg6sUKEAmpP52Dk5VDRs shhy5R6Y47giRfqqGHwP2gKhjKJ+A+C5xGIaw4vPv45tylQVYr/+M5yfk8Ef6lSEPZ /4pHik1b+m49lHSX+0YNSt+WsWgr53z7GOtyezLo= Received: by mail-oi1-f169.google.com with SMTP id a3so21496593oib.4 for ; Tue, 22 Sep 2020 08:28:56 -0700 (PDT) X-Gm-Message-State: AOAM532tPMmDfx5GrVLxkcKMMjtvrpEIuozc1yLOswNvBWy9iN7EV0TK 4bptAmlIfM6G/OEXK+JMg13IAMxIdOo9KcUldg== X-Received: by 2002:aca:fc07:: with SMTP id a7mr2975627oii.106.1600788535975; Tue, 22 Sep 2020 08:28:55 -0700 (PDT) MIME-Version: 1.0 References: <20200911215118.2887710-1-robh@kernel.org> <20200911215118.2887710-6-robh@kernel.org> <20200918143331.GF2626435@krava> In-Reply-To: <20200918143331.GF2626435@krava> From: Rob Herring Date: Tue, 22 Sep 2020 09:28:44 -0600 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v3 05/10] libperf: Add libperf_evsel__mmap() To: Jiri Olsa Cc: Will Deacon , Catalin Marinas , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , "linux-kernel@vger.kernel.org" , linux-arm-kernel , Alexander Shishkin , Namhyung Kim , Raphael Gault , Mark Rutland , Jonathan Cameron , Ian Rogers , Honnappa Nagarahalli Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Sep 18, 2020 at 8:33 AM Jiri Olsa wrote: > > On Fri, Sep 11, 2020 at 03:51:13PM -0600, Rob Herring wrote: > > In order to support usersapce access, an event must be mmapped. While > > there's already mmap support for evlist, the usecase is a bit different > > than the self monitoring with userspace access. So let's add a new > > perf_evsel__mmap() function to mmap an evsel. This allows implementing > > userspace access as a fastpath for perf_evsel__read(). > > > > The mmapped address is returned by perf_evsel__mmap() primarily for > > users/tests to check if userspace access is enabled. > > > > Signed-off-by: Rob Herring > > --- > > v3: > > - New patch split out from user access patch > > --- > > tools/lib/perf/Documentation/libperf.txt | 1 + > > tools/lib/perf/evsel.c | 31 ++++++++++++++++++++++++ > > tools/lib/perf/include/internal/evsel.h | 2 ++ > > tools/lib/perf/include/perf/evsel.h | 2 ++ > > tools/lib/perf/libperf.map | 1 + > > 5 files changed, 37 insertions(+) > > > > diff --git a/tools/lib/perf/Documentation/libperf.txt b/tools/lib/perf/Documentation/libperf.txt > > index 0c74c30ed23a..0b4694ce42b9 100644 > > --- a/tools/lib/perf/Documentation/libperf.txt > > +++ b/tools/lib/perf/Documentation/libperf.txt > > @@ -136,6 +136,7 @@ SYNOPSIS > > struct perf_thread_map *threads); > > void perf_evsel__close(struct perf_evsel *evsel); > > void perf_evsel__close_cpu(struct perf_evsel *evsel, int cpu); > > + void *perf_evsel__mmap(struct perf_evsel *evsel, size_t length); > > int perf_evsel__read(struct perf_evsel *evsel, int cpu, int thread, > > struct perf_counts_values *count); > > int perf_evsel__enable(struct perf_evsel *evsel); > > diff --git a/tools/lib/perf/evsel.c b/tools/lib/perf/evsel.c > > index 4dc06289f4c7..99fa53dc0887 100644 > > --- a/tools/lib/perf/evsel.c > > +++ b/tools/lib/perf/evsel.c > > @@ -11,10 +11,12 @@ > > #include > > #include > > #include > > +#include > > #include > > #include > > #include > > #include > > +#include > > > > void perf_evsel__init(struct perf_evsel *evsel, struct perf_event_attr *attr) > > { > > @@ -156,6 +158,35 @@ void perf_evsel__close_cpu(struct perf_evsel *evsel, int cpu) > > perf_evsel__close_fd_cpu(evsel, cpu); > > } > > > > +void *perf_evsel__mmap(struct perf_evsel *evsel, size_t length) > > +{ > > could you rather use 'int pages' insted of length as we > do in perf_evlist__mmap, so we keep the same interface > > len = (pages + 1) * page_size Sure, but what's the reason it is pages minus 1? It seems a bit odd to pass in 0 here to get 1 page which would be the typical usage. Rob