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.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 B6339C433DB for ; Fri, 12 Mar 2021 14:00:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 93BA264FD6 for ; Fri, 12 Mar 2021 14:00:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231640AbhCLN7a (ORCPT ); Fri, 12 Mar 2021 08:59:30 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:53048 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231657AbhCLN7C (ORCPT ); Fri, 12 Mar 2021 08:59:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615557541; 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=ZkWwYtFvqkHq9ObLbq6+N/UVWKingHbDr05c7oaciLw=; b=N/lLXkjD9M2/RfZEyupgh5e0Ylgwo5d6mVkj0W2NQrXB85iWjldt1i/4P6efUTQBs0yzxS pcaoFC0LV0k3b0woPoSLwXO3B/Ua7aQqaaKJW3ja2F8nAKoq1OaBG3fMQTkcwl8zZfDiSr Fp2jYPAG+o6E4s3SP7cdH3zJ/9j1bj0= 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-317-XZtaKWphNDWk7l_pFVo8Og-1; Fri, 12 Mar 2021 08:58:57 -0500 X-MC-Unique: XZtaKWphNDWk7l_pFVo8Og-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 334AB8912FC; Fri, 12 Mar 2021 13:58:52 +0000 (UTC) Received: from krava (unknown [10.40.192.54]) by smtp.corp.redhat.com (Postfix) with SMTP id 27FAD60877; Fri, 12 Mar 2021 13:58:47 +0000 (UTC) Date: Fri, 12 Mar 2021 14:58:47 +0100 From: Jiri Olsa To: Rob Herring Cc: Will Deacon , Catalin Marinas , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Ian Rogers , Alexander Shishkin , honnappa.nagarahalli@arm.com, Zachary.Leaf@arm.com, Raphael Gault , Jonathan Cameron , Namhyung Kim , Itaru Kitayama , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v6 04/10] libperf: Add evsel mmap support Message-ID: References: <20210311000837.3630499-1-robh@kernel.org> <20210311000837.3630499-5-robh@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210311000837.3630499-5-robh@kernel.org> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Mar 10, 2021 at 05:08:31PM -0700, Rob Herring wrote: SNIP > + > static int > sys_perf_event_open(struct perf_event_attr *attr, > pid_t pid, int cpu, int group_fd, > @@ -137,6 +147,8 @@ void perf_evsel__free_fd(struct perf_evsel *evsel) > { > xyarray__delete(evsel->fd); > evsel->fd = NULL; > + xyarray__delete(evsel->mmap); > + evsel->mmap = NULL; > } > > void perf_evsel__close(struct perf_evsel *evsel) > @@ -156,6 +168,45 @@ void perf_evsel__close_cpu(struct perf_evsel *evsel, int cpu) > perf_evsel__close_fd_cpu(evsel, cpu); > } > > +int perf_evsel__mmap(struct perf_evsel *evsel, int pages) > +{ > + int ret, cpu, thread; > + struct perf_mmap_param mp = { > + .prot = PROT_READ | PROT_WRITE, > + .mask = (pages * page_size) - 1, > + }; I don't mind using evsel->fd for dimensions below, but we need to check in here that it's defined, that perf_evsel__open was called jirka > + > + if (evsel->mmap == NULL && > + perf_evsel__alloc_mmap(evsel, xyarray__max_x(evsel->fd), xyarray__max_y(evsel->fd)) < 0) > + return -ENOMEM; > + > + for (cpu = 0; cpu < xyarray__max_x(evsel->fd); cpu++) { > + for (thread = 0; thread < xyarray__max_y(evsel->fd); thread++) { > + int fd = FD(evsel, cpu, thread); > + struct perf_mmap *map = MMAP(evsel, cpu, thread); > + > + if (fd < 0) > + continue; > + > + perf_mmap__init(map, NULL, false, NULL); > + > + ret = perf_mmap__mmap(map, &mp, fd, cpu); > + if (ret) > + return -1; > + } > + } > + > + return 0; > +} > + SNIP 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=-9.0 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=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 E0072C433DB for ; Fri, 12 Mar 2021 14:01:28 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 5553864FB8 for ; Fri, 12 Mar 2021 14:01:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5553864FB8 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=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:Cc: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=HXJ/4+YIy72Tjti6ZNBmvHWrdTpfYM4kL0YvRWFUyCA=; b=EqAPEBLoDBmUu1UdS80Q0XfS2 Ne4jFLm4uXym9lnrlTIbHlOAIFweSn6YuKNifHik8U58ywTcAvDwEMhSGvvMK81qccUtlD9HWKrcf Jc4ht4kKinrY5Zluhp3nk833RKqdrtMogbmo47cvofvq5ACUPUy9uoWdnhITANHkwkSqcCF4Xa2RY AnZJj4/5pl+MKCb8dZnRZE6s1EMjEJvR+Ljhu6g0iyZLdfnwMWb0x+WTRIG5HWj6NPc8tHyEjsrua oscfNmxwgtHG+F7lWN/5xNFShHX9hTjy+4qb5gv8C5D186S4FrxtvTYvUA5OSJh9wwsAZbvWOYAII fv1XfOugQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lKiJx-00BZkx-3c; Fri, 12 Mar 2021 13:59:17 +0000 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lKiJp-00BZjE-Dn for linux-arm-kernel@lists.infradead.org; Fri, 12 Mar 2021 13:59:11 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615557542; 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=ZkWwYtFvqkHq9ObLbq6+N/UVWKingHbDr05c7oaciLw=; b=C+uXBa8efJnA7mh7ORNDhTJEFhzCcsIw9MceNvjMbjRWCBCu/6oalvTF3tkdQn2iMSDonS 8bVyBCQs/4fhY66ggiXvp+xP27TaMLqiI52/NbZmKrIvcD4a4VXOK0lXE3UA3G4OikCk9+ mdQSOhtLBit5bIApi4zPVfAFn5wssVs= 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-317-XZtaKWphNDWk7l_pFVo8Og-1; Fri, 12 Mar 2021 08:58:57 -0500 X-MC-Unique: XZtaKWphNDWk7l_pFVo8Og-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 334AB8912FC; Fri, 12 Mar 2021 13:58:52 +0000 (UTC) Received: from krava (unknown [10.40.192.54]) by smtp.corp.redhat.com (Postfix) with SMTP id 27FAD60877; Fri, 12 Mar 2021 13:58:47 +0000 (UTC) Date: Fri, 12 Mar 2021 14:58:47 +0100 From: Jiri Olsa To: Rob Herring Cc: Will Deacon , Catalin Marinas , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Ian Rogers , Alexander Shishkin , honnappa.nagarahalli@arm.com, Zachary.Leaf@arm.com, Raphael Gault , Jonathan Cameron , Namhyung Kim , Itaru Kitayama , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v6 04/10] libperf: Add evsel mmap support Message-ID: References: <20210311000837.3630499-1-robh@kernel.org> <20210311000837.3630499-5-robh@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210311000837.3630499-5-robh@kernel.org> 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-20210312_135910_127490_CA258849 X-CRM114-Status: GOOD ( 18.37 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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, Mar 10, 2021 at 05:08:31PM -0700, Rob Herring wrote: SNIP > + > static int > sys_perf_event_open(struct perf_event_attr *attr, > pid_t pid, int cpu, int group_fd, > @@ -137,6 +147,8 @@ void perf_evsel__free_fd(struct perf_evsel *evsel) > { > xyarray__delete(evsel->fd); > evsel->fd = NULL; > + xyarray__delete(evsel->mmap); > + evsel->mmap = NULL; > } > > void perf_evsel__close(struct perf_evsel *evsel) > @@ -156,6 +168,45 @@ void perf_evsel__close_cpu(struct perf_evsel *evsel, int cpu) > perf_evsel__close_fd_cpu(evsel, cpu); > } > > +int perf_evsel__mmap(struct perf_evsel *evsel, int pages) > +{ > + int ret, cpu, thread; > + struct perf_mmap_param mp = { > + .prot = PROT_READ | PROT_WRITE, > + .mask = (pages * page_size) - 1, > + }; I don't mind using evsel->fd for dimensions below, but we need to check in here that it's defined, that perf_evsel__open was called jirka > + > + if (evsel->mmap == NULL && > + perf_evsel__alloc_mmap(evsel, xyarray__max_x(evsel->fd), xyarray__max_y(evsel->fd)) < 0) > + return -ENOMEM; > + > + for (cpu = 0; cpu < xyarray__max_x(evsel->fd); cpu++) { > + for (thread = 0; thread < xyarray__max_y(evsel->fd); thread++) { > + int fd = FD(evsel, cpu, thread); > + struct perf_mmap *map = MMAP(evsel, cpu, thread); > + > + if (fd < 0) > + continue; > + > + perf_mmap__init(map, NULL, false, NULL); > + > + ret = perf_mmap__mmap(map, &mp, fd, cpu); > + if (ret) > + return -1; > + } > + } > + > + return 0; > +} > + SNIP _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel