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=-6.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no 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 8E43BC4363A for ; Wed, 21 Oct 2020 11:26:07 +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 13E4121741 for ; Wed, 21 Oct 2020 11:26:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="yVYJ8Sfy"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Yio+nME5" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 13E4121741 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=tvZGH6mHtfcPA6CJhKRWv4hnFBvvChdZssh+nLXgTqM=; b=yVYJ8SfyqKxa9zYZhsHG9bmgo f8Ye4roW5j/6IkP+TV46MMyAo95p2U5W+L0DRYUQ18A73edAJ3k854fZGwBTNbl9ci2boOB2ykcGf RyVoCBURmnGH4Ji8RpK9FhysyMbPTGxLD92ivmkDvDXA5uiB+VXGxj9K/jFm3ZwCkdzqWXgEoYNf2 kJoTXmqSSUIM2RHapA1QP02U+5Ivny2SRFJSvnDv3xwRcBpnXk1JRKPByJX3APAr9+HQ5s1Il1wwC 2wL81Mz6K2IvJwoXSuIJkwOdG2RkGeGbJwCT0+2UVb4+NyCejuL/aXZY/yiRuZibYsiu/wk9HjNdD cQhyU/gdA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kVCEb-0003q6-8U; Wed, 21 Oct 2020 11:24:49 +0000 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kVCEY-0003oy-9G for linux-arm-kernel@lists.infradead.org; Wed, 21 Oct 2020 11:24:47 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603279483; 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=u6TlWgmRgjJNkPTgDCE0HEDRwt3qdOMZjYScgM6yuio=; b=Yio+nME5ZHn/xuDnY62swo6Oo4w0fEiQbld0vF6p18bG1t3sOo1IyxaDe4RdTvwjFKls7+ unhin4SiDZnTiscebnLRbCDRNAnYbNfNm7pjV6F+MIon2dwLeyaOtepfE69XAanSjvsfnS /qJLNSfppPpk9nZASXHD/0liV2/ZJSc= 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-424-jBEaReK0PNyc0nfnF23nMw-1; Wed, 21 Oct 2020 07:24:37 -0400 X-MC-Unique: jBEaReK0PNyc0nfnF23nMw-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 59C27879521; Wed, 21 Oct 2020 11:24:35 +0000 (UTC) Received: from krava (unknown [10.40.194.101]) by smtp.corp.redhat.com (Postfix) with SMTP id 5E1316EF6B; Wed, 21 Oct 2020 11:24:31 +0000 (UTC) Date: Wed, 21 Oct 2020 13:24:30 +0200 From: Jiri Olsa To: Rob Herring Subject: Re: [PATCH v4 4/9] libperf: Add libperf_evsel__mmap() Message-ID: <20201021112430.GE2189784@krava> References: <20201001140116.651970-1-robh@kernel.org> <20201001140116.651970-5-robh@kernel.org> <20201014110527.GA1349644@krava> <20201019201541.GN1461394@krava> <20201020153527.GD2113901@krava> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201021_072446_407141_94C1F8AE X-CRM114-Status: GOOD ( 35.00 ) 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 , Itaru Kitayama , 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 Tue, Oct 20, 2020 at 12:11:47PM -0500, Rob Herring wrote: SNIP > > > > > > > > > > The mmapped read will actually fail and then we fallback here. My main > > > > > concern though is adding more overhead on a feature that's meant to be > > > > > low overhead (granted, it's not much). Maybe we could add checks on > > > > > the mmap that we've opened the event with pid == 0 and cpu == -1 (so > > > > > only 1 FD)? > > > > > > > > but then you limit this just for single fd.. having mmap as xyarray > > > > would not be that bad and perf_evsel__mmap will call perf_mmap__mmap > > > > for each defined cpu/thread .. so it depends on user how fast this > > > > will be - how many maps needs to be created/mmaped > > > > > > Given userspace access fails for anything other than the calling > > > thread and all cpus, how would more than 1 mmap be useful here? > > > > I'm not sure what you mean by fail in here.. you need mmap for each > > event fd you want to read from > > Yes, but that's one mmap per event (evsel) which is different than per > cpu/thread. right, and you need mmap per fd IIUC > > > in the example below we read stats from all cpus via perf_evsel__read, > > if we insert this call after perf_evsel__open: > > > > perf_evsel__mmap(cpus, NULL); > > > > that maps page for each event, then perf_evsel__read > > could go through the fast code, no? > > No, because we're not self-monitoring (pid == 0 and cpu == -1). With > the following change: > > diff --git a/tools/lib/perf/tests/test-evsel.c > b/tools/lib/perf/tests/test-evsel.c > index eeca8203d73d..1fca9c121f7c 100644 > --- a/tools/lib/perf/tests/test-evsel.c > +++ b/tools/lib/perf/tests/test-evsel.c > @@ -17,6 +17,7 @@ static int test_stat_cpu(void) > { > struct perf_cpu_map *cpus; > struct perf_evsel *evsel; > + struct perf_event_mmap_page *pc; > struct perf_event_attr attr = { > .type = PERF_TYPE_SOFTWARE, > .config = PERF_COUNT_SW_CPU_CLOCK, > @@ -32,6 +33,15 @@ static int test_stat_cpu(void) > err = perf_evsel__open(evsel, cpus, NULL); > __T("failed to open evsel", err == 0); > > + pc = perf_evsel__mmap(evsel, 0); > + __T("failed to mmap evsel", pc); > + > +#if defined(__i386__) || defined(__x86_64__) || defined(__aarch64__) > + __T("userspace counter access not supported", pc->cap_user_rdpmc); > + __T("userspace counter access not enabled", pc->index); > + __T("userspace counter width not set", pc->pmc_width >= 32); > +#endif I'll need to check, I'm surprised this would depend on the way you open the event jirka > + > perf_cpu_map__for_each_cpu(cpu, tmp, cpus) { > struct perf_counts_values counts = { .val = 0 }; > > I get: > > - running test-evsel.c...FAILED test-evsel.c:40 userspace counter > access not supported > > If I set it to pid==0, userspace counter access is also disabled. > > Maybe there is some use for mmap beyond fast path read for > self-monitoring or what evlist mmap does, but I don't know what that > would be. > > Note that we could get rid of the mmap API and just do the mmap behind > the scenes whenever we get the magic setup that works. The main > downside with that is you can't check if the fast path is enabled or > not (though we could have a perf_evsel__is_fast_read(evsel, cpu, > thread) instead). > > Rob > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel