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=-10.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT 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 C750AC47404 for ; Fri, 11 Oct 2019 20:11:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9658921E6F for ; Fri, 11 Oct 2019 20:11:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570824704; bh=vuNxoTb6DytwxDoRyfb9fYEMcmy7VWkF2Z4Z5Mc6VWI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=PbA9FZWdY50ZBIs8APw8tl6TCL5zOnIadD2P3nqMAwuALgNe79KhzIIInD4ZyP8ah sihQFV5RjJMQxr8fXnYpTv4qeF3SFNBaiIkrBwSeUa3pB6I7P+BJqlysHNhHnBvRv8 toSKy0Se3EUVDGKxONNNlkfspX5AKnectX3uFg2Y= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729853AbfJKULm (ORCPT ); Fri, 11 Oct 2019 16:11:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:47834 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729806AbfJKULk (ORCPT ); Fri, 11 Oct 2019 16:11:40 -0400 Received: from quaco.ghostprotocols.net (189-94-137-67.3g.claro.net.br [189.94.137.67]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8C99F22475; Fri, 11 Oct 2019 20:11:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570824699; bh=vuNxoTb6DytwxDoRyfb9fYEMcmy7VWkF2Z4Z5Mc6VWI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zygZY1Bmlxdq9fYSgJYQ8gg+YWV/Sd4l7pLiXLnAm0dNym2xX3kOlW7CV+6rVAZK+ kW6GO9F+UyXkYd7w0VskqsV0Xa4eNCAd+Lg3CJwK3MdklrNUfqgiaM/fsxQrZfNbid KMmag0Mjys/4JjbqF33HDOWZHLm8vXDBi9uA9Ek8= From: Arnaldo Carvalho de Melo To: Ingo Molnar , Thomas Gleixner Cc: Jiri Olsa , Namhyung Kim , Clark Williams , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Alexander Shishkin , Michael Petlan , Peter Zijlstra , Arnaldo Carvalho de Melo Subject: [PATCH 64/69] libperf: Move the pollfd allocation from tools/perf to libperf Date: Fri, 11 Oct 2019 17:05:54 -0300 Message-Id: <20191011200559.7156-65-acme@kernel.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191011200559.7156-1-acme@kernel.org> References: <20191011200559.7156-1-acme@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jiri Olsa It's needed in libperf only, so move it to the perf_evlist__mmap_ops() function. Signed-off-by: Jiri Olsa Cc: Alexander Shishkin Cc: Michael Petlan Cc: Namhyung Kim Cc: Peter Zijlstra Link: http://lore.kernel.org/lkml/20191007125344.14268-24-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/lib/evlist.c | 5 +++++ tools/perf/util/evlist.c | 4 ---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/tools/perf/lib/evlist.c b/tools/perf/lib/evlist.c index f9a802d2ceb5..5ae1da97d2e6 100644 --- a/tools/perf/lib/evlist.c +++ b/tools/perf/lib/evlist.c @@ -34,6 +34,7 @@ void perf_evlist__init(struct perf_evlist *evlist) INIT_HLIST_HEAD(&evlist->heads[i]); INIT_LIST_HEAD(&evlist->entries); evlist->nr_entries = 0; + fdarray__init(&evlist->pollfd, 64); } static void __perf_evlist__propagate_maps(struct perf_evlist *evlist, @@ -114,6 +115,7 @@ void perf_evlist__delete(struct perf_evlist *evlist) return; perf_evlist__munmap(evlist); + fdarray__exit(&evlist->pollfd); free(evlist); } @@ -525,6 +527,9 @@ int perf_evlist__mmap_ops(struct perf_evlist *evlist, return -ENOMEM; } + if (evlist->pollfd.entries == NULL && perf_evlist__alloc_pollfd(evlist) < 0) + return -ENOMEM; + if (perf_cpu_map__empty(cpus)) return mmap_per_thread(evlist, ops, mp); diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index 3f4f11f27b94..5192c6583c96 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c @@ -58,7 +58,6 @@ void evlist__init(struct evlist *evlist, struct perf_cpu_map *cpus, { perf_evlist__init(&evlist->core); perf_evlist__set_maps(&evlist->core, cpus, threads); - fdarray__init(&evlist->core.pollfd, 64); evlist->workload.pid = -1; evlist->bkw_mmap_state = BKW_MMAP_NOTREADY; } @@ -829,9 +828,6 @@ int evlist__mmap_ex(struct evlist *evlist, unsigned int pages, if (!evlist->mmap) return -ENOMEM; - if (evlist->core.pollfd.entries == NULL && perf_evlist__alloc_pollfd(&evlist->core) < 0) - return -ENOMEM; - evlist->core.mmap_len = evlist__mmap_size(pages); pr_debug("mmap size %zuB\n", evlist->core.mmap_len); mp.core.mask = evlist->core.mmap_len - page_size - 1; -- 2.21.0