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=-13.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham 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 8152DC433E0 for ; Sat, 23 Jan 2021 22:43:59 +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 12FE322CAF for ; Sat, 23 Jan 2021 22:43:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 12FE322CAF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com 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:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=pby0yYkFWXAOx8+MF9SQ5Z73FlonyQfnq5fBbdBdcTY=; b=h9Brf98NbGnxUp3T8uok8Dj+s Nv1OXVHl1ppmEXnx0S8QY6fvzvdlszA3Qwp1uQSIaHZIqBtpzlPyM0voNCutnL4sqOwBsxGHKdh+u qDNFF6OZbaXC3zWNIlK/uZjizQbzS0BBgWsYiNzuUijIiXAjLbPuwaTiHUj8Q8EMwulQ9XhV89pD2 ShydK1Ps5XRu1hj/JjBWMddyT74avzGfEInXyapTrJOJPc4rR97vWBpxteHoHto54AjoTjwF94G1z z9jhBIeXkuBRxDphQMD4cuzh1P1//nMwlQtfCOi94LFKyED8KlF2LQouLeDSLdAlRUIYKGYt+lrpQ 1YyRi8Zkg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l3Rbw-0006ry-4t; Sat, 23 Jan 2021 22:42:28 +0000 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1l3Rbt-0006rN-FR for linux-arm-kernel@lists.infradead.org; Sat, 23 Jan 2021 22:42:26 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1611441743; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Qupc3tQLbCS2NvC0uQtSj9ojSf/ORyYBsb/uXYHlqFM=; b=UtXPFXnaGwBrlj52k1YCGlmDqsXS4JOAEP7fsaaNJxKr37B4HTSA8uM+1qRxoNzfPp3MHN wWufxcBz0o61Au4iwvrwF2SBebZrCt5vRnXZGnyJllPFW+mph2nRW5EK+Aq16Y4WuSy0fR jkXbrLjvzGJ4RIfdhncC0s9lDTgJbWQ= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-231-vE3e5NSJPhGv14_ZMK67hQ-1; Sat, 23 Jan 2021 17:42:20 -0500 X-MC-Unique: vE3e5NSJPhGv14_ZMK67hQ-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6F04A801817; Sat, 23 Jan 2021 22:42:18 +0000 (UTC) Received: from krava (unknown [10.40.192.55]) by smtp.corp.redhat.com (Postfix) with SMTP id BF7355D723; Sat, 23 Jan 2021 22:42:14 +0000 (UTC) Date: Sat, 23 Jan 2021 23:42:13 +0100 From: Jiri Olsa To: Rob Herring Subject: Re: [PATCH v5 4/9] libperf: Add evsel mmap support Message-ID: <20210123224213.GA138414@krava> References: <20210114020605.3943992-1-robh@kernel.org> <20210114020605.3943992-5-robh@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210114020605.3943992-5-robh@kernel.org> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210123_174225_576075_2B25CA41 X-CRM114-Status: GOOD ( 23.49 ) 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@arm.com, Jonathan Cameron , Namhyung Kim , Itaru Kitayama , Will Deacon , linux-arm-kernel@lists.infradead.org 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 Wed, Jan 13, 2021 at 08:06:00PM -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_base() which > primarily for users/tests to check if userspace access is enabled. > > Signed-off-by: Rob Herring > --- > v5: > - Create an mmap for every underlying event opened. Due to this, we > need a different way to get the mmap ptr, so perf_evsel__mmap_base() > is introduced. > v4: > - Change perf_evsel__mmap size to pages instead of bytes > v3: > - New patch split out from user access patch > --- > tools/lib/perf/Documentation/libperf.txt | 2 + > tools/lib/perf/evsel.c | 47 +++++++++++++++++++++++- > tools/lib/perf/include/internal/evsel.h | 2 + > tools/lib/perf/include/perf/evsel.h | 2 + > tools/lib/perf/libperf.map | 2 + > 5 files changed, 53 insertions(+), 2 deletions(-) > > diff --git a/tools/lib/perf/Documentation/libperf.txt b/tools/lib/perf/Documentation/libperf.txt > index 0c74c30ed23a..a2c73df191ca 100644 > --- a/tools/lib/perf/Documentation/libperf.txt > +++ b/tools/lib/perf/Documentation/libperf.txt > @@ -136,6 +136,8 @@ 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); > + int perf_evsel__mmap(struct perf_evsel *evsel, int pages); > + void *perf_evsel__mmap_base(struct perf_evsel *evsel, int cpu, int thread); > 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..0b5bdf4badae 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) > { > @@ -37,11 +39,17 @@ void perf_evsel__delete(struct perf_evsel *evsel) > free(evsel); > } > > -#define FD(e, x, y) (*(int *) xyarray__entry(e->fd, x, y)) > +struct evsel_fd { > + int fd; > + struct perf_mmap mmap; > +}; nice shortcut ;-) but 'struct perf_mmap' is too big for that I think it's better to add new 'evsel::mmap' xyarray to hold it, add perf_evsel__alloc_mmap to allocate it and call it from perf_evsel__mmap the same way as we callperf_evsel__alloc_fd from perf_evsel__open thanks, jirka _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel