From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 697D5C4363D for ; Tue, 22 Sep 2020 15:30:47 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EC2F020757 for ; Tue, 22 Sep 2020 15:30:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Jl/6z9/5"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="IoYTiDH5" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EC2F020757 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=7guYmhnpT0hV2zuK/ErJbLk6hYHzQLL+IcNmmUu9iI0=; b=Jl/6z9/5ZkIM38GrAgMOFuX+o ojvyqMnSikSq9SpaSP4A1+gtgNbzycLYbJ7ibOTVZHZNHBXViZEw5hAVoQHPnd9Ru8nNXabvu6erG yi2g49240iiergjX5iKcGqYiZL8BK7ZMexEQg4IwrcqTliSlKlHNbp5l+yJC54lErkI+FRB31Za6b D+hAyPTFUlIZ5sAFAUXCwZcg/O7Sau4JW0HiOnd4a6r+tuwh/f2syTyEFQSq9ZAj4/gRwclAMhnDO kOPusOlvDCcDBHLS8RzLgGznjsVEroy7EyXipgNoND2eIl3/BTEBcxg/yMIHuDodgAoiwdbirZeHb JlZcpLx/g==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kKkE0-0003fw-Jx; Tue, 22 Sep 2020 15:29:00 +0000 Received: from mail.kernel.org ([198.145.29.99]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kKkDx-0003es-9X for linux-arm-kernel@lists.infradead.org; Tue, 22 Sep 2020 15:28:58 +0000 Received: from mail-oi1-f175.google.com (mail-oi1-f175.google.com [209.85.167.175]) (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 96AC82220D 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-f175.google.com with SMTP id u126so21431746oif.13 for ; Tue, 22 Sep 2020 08:28:56 -0700 (PDT) X-Gm-Message-State: AOAM532kbfUG88LmAhcHTT2Lgesg5ONYl/ewYNbq/cEWS3tPHrwtQvUF MTu6dAT0qjK/NjXeJ1xcXA/Xokv4Np7Z/QoqTQ== X-Google-Smtp-Source: ABdhPJw4/nlvLO9CJjXzd4jkAzXXDCF++MXpsyrquogcjlMkZsAq6klLBGLhwbLMTcRqWr2RSrstVEvhZI4GnXfczuY= 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200922_112857_515699_6A6E10A8 X-CRM114-Status: GOOD ( 26.59 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Ian Rogers , Peter Zijlstra , Catalin Marinas , "linux-kernel@vger.kernel.org" , Arnaldo Carvalho de Melo , Alexander Shishkin , Raphael Gault , Ingo Molnar , Honnappa Nagarahalli , Jonathan Cameron , Namhyung Kim , Will Deacon , linux-arm-kernel Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel