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.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 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 98AE2C433DF for ; Mon, 12 Oct 2020 09:05:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4268720790 for ; Mon, 12 Oct 2020 09:05:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729016AbgJLJFG (ORCPT ); Mon, 12 Oct 2020 05:05:06 -0400 Received: from mga01.intel.com ([192.55.52.88]:45501 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726428AbgJLJFF (ORCPT ); Mon, 12 Oct 2020 05:05:05 -0400 IronPort-SDR: Elq6fIDi/Wyfo/WxQYAs/L3XCDKFsGN45HMgQJuGek6A3+O4ECAqSRJmz1AWWsLlJlKCHjHd1m RZ3AMVRzoNGA== X-IronPort-AV: E=McAfee;i="6000,8403,9771"; a="183166436" X-IronPort-AV: E=Sophos;i="5.77,366,1596524400"; d="scan'208";a="183166436" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Oct 2020 02:05:05 -0700 IronPort-SDR: PHMNhXqveA+YrccAdC264ItdcwakJ566OPLIZpXvoG/lKPJhRU8genOgX4vC8465PpSbVBzrq4 nS9/Sx0DPbzw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,366,1596524400"; d="scan'208";a="313380820" Received: from linux.intel.com ([10.54.29.200]) by orsmga003.jf.intel.com with ESMTP; 12 Oct 2020 02:05:04 -0700 Received: from [10.249.225.186] (abudanko-mobl.ccr.corp.intel.com [10.249.225.186]) by linux.intel.com (Postfix) with ESMTP id 5EA1F5805EC; Mon, 12 Oct 2020 02:05:02 -0700 (PDT) Subject: [PATCH v1 11/15] perf evlist: introduce evlist__ctlfd_update() to update ctl fd status To: Arnaldo Carvalho de Melo , Jiri Olsa Cc: Namhyung Kim , Alexander Shishkin , Andi Kleen , Adrian Hunter , Peter Zijlstra , Ingo Molnar , linux-kernel References: <810f3a69-0004-9dff-a911-b7ff97220ae0@linux.intel.com> From: Alexey Budankov Organization: Intel Corp. Message-ID: Date: Mon, 12 Oct 2020 12:05:01 +0300 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.12.1 MIME-Version: 1.0 In-Reply-To: <810f3a69-0004-9dff-a911-b7ff97220ae0@linux.intel.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Introduce evlist__ctlfd_update() to update ctl fd poll status in evlist pollfd array using other pollfd object. Signed-off-by: Alexey Budankov --- tools/perf/util/evlist.c | 16 ++++++++++++++++ tools/perf/util/evlist.h | 1 + 2 files changed, 17 insertions(+) diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index 8bdf3d2c907c..758a4896fedd 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c @@ -1970,6 +1970,22 @@ int evlist__ctlfd_process(struct evlist *evlist, enum evlist_ctl_cmd *cmd) return err; } +int evlist__ctlfd_update(struct evlist *evlist, struct pollfd *update) +{ + int ctlfd_pos = evlist->ctl_fd.pos; + struct pollfd *entries = evlist->core.pollfd.entries; + + if (!evlist__ctlfd_initialized(evlist)) + return 0; + + if (entries[ctlfd_pos].fd != update->fd || + entries[ctlfd_pos].events != update->events) + return -1; + + entries[ctlfd_pos].revents = update->revents; + return 0; +} + struct evsel *evlist__find_evsel(struct evlist *evlist, int idx) { struct evsel *evsel; diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h index e1a450322bc5..9b73d6ccf066 100644 --- a/tools/perf/util/evlist.h +++ b/tools/perf/util/evlist.h @@ -380,6 +380,7 @@ void evlist__close_control(int ctl_fd, int ctl_fd_ack, bool *ctl_fd_close); int evlist__initialize_ctlfd(struct evlist *evlist, int ctl_fd, int ctl_fd_ack); int evlist__finalize_ctlfd(struct evlist *evlist); bool evlist__ctlfd_initialized(struct evlist *evlist); +int evlist__ctlfd_update(struct evlist *evlist, struct pollfd *update); int evlist__ctlfd_process(struct evlist *evlist, enum evlist_ctl_cmd *cmd); int evlist__ctlfd_ack(struct evlist *evlist); -- 2.24.1