Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp5490936pxu; Thu, 22 Oct 2020 03:55:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwNpnIQ4k+JHNtGlv8STwrfesULrqIQEupobkYcT+N5Vng/3sGHpMeY070ITTMlDldtXKbv X-Received: by 2002:a17:907:70cb:: with SMTP id yk11mr1303936ejb.122.1603364149613; Thu, 22 Oct 2020 03:55:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603364149; cv=none; d=google.com; s=arc-20160816; b=j+y+WsAbqbiDVgGZ27cZjFTf2Ws6Y/o7qIXsIQPVTvTvo5EV5xc8dBr02pvhFywwjs 6qAZgPxZdTmsF3J39+5K26a2hSc3p/qOzxITQY/+a3lB18t19gj9Onx25+f6koO23v7n 4a41CYUzxObUuTvLksZ7A3twHqrl4zx0BZPiPJtISDIE3/18eAXt2grVMJ//GiWI3hN+ SdYmJE2sinMnWYMx3w0+rQ0Izkk86lfjlMKy0+XViqYC9Y+4N9/F94Ar7JlsN7BESpuX 2J3nnJNmTC+IjEt7oSxUmLV63anO0eGYtZNmJC8ot7mNxzAkaLPVYZOnnQ3BhQmVk7fu wZDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:organization :references:cc:to:from:subject:ironport-sdr:ironport-sdr; bh=ep4Zcaiy6BychF8St0JbhhKcYQbrOvBHABFqjSwGGxM=; b=vigCOQY6WIsT/qVc1PLzDcZBsLnx7YXqKF9VM7ORGvQm2l2B70lIxQJCyoaRUP/obq mjDPurplDmEmLVTCH5Mq7HExKuxi/GLwAPfGSDMkYateDaaX/6gMKA7a1FhY/pNSKtdA imgHLfVjaLvTGCNkBFAlJrqQ5LaaAxKzOnl+Q63wbELXhxHiyD+t1FcxsbH3fwpUwnhu rzYnCn3lJmQ1mzaEwCSwVD8b75PjpYsSMt7qnhl9dOq+xa6dpTFQpKvzjfJNLoPQIURu DjWwShp/nxIYSOBXcwPSkGFkL4MYKT6+mD3+bb7ToiHWHMbCe3z7WHw2NW1RokZOaD89 +BKA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id jx12si610060ejb.293.2020.10.22.03.55.27; Thu, 22 Oct 2020 03:55:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2502777AbgJUQGb (ORCPT + 99 others); Wed, 21 Oct 2020 12:06:31 -0400 Received: from mga01.intel.com ([192.55.52.88]:25455 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2502773AbgJUQGa (ORCPT ); Wed, 21 Oct 2020 12:06:30 -0400 IronPort-SDR: JwajuWQlKouG9fhEmcgokHkOEunDa4E3+q38CPvHzG5bYRzID9nL7qsPzJgfajSFw8zBrDbXon 4/oO7Lub41/Q== X-IronPort-AV: E=McAfee;i="6000,8403,9780"; a="185050954" X-IronPort-AV: E=Sophos;i="5.77,401,1596524400"; d="scan'208";a="185050954" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Oct 2020 09:06:29 -0700 IronPort-SDR: Nmb44Xq+jTtTQTPzf1Wyt9QbnGoKKiUgUTZfIUI0hEM4XfjYm5yCsRun9cqeGU8ilqPnNcVSRu pqUyfXkC5zxg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,401,1596524400"; d="scan'208";a="321058244" Received: from linux.intel.com ([10.54.29.200]) by orsmga006.jf.intel.com with ESMTP; 21 Oct 2020 09:06:29 -0700 Received: from [10.249.231.46] (abudanko-mobl.ccr.corp.intel.com [10.249.231.46]) by linux.intel.com (Postfix) with ESMTP id 3F9F5580107; Wed, 21 Oct 2020 09:06:27 -0700 (PDT) Subject: [PATCH v2 11/15] perf evlist: introduce evlist__ctlfd_update() to update ctl fd status From: Alexey Budankov To: Arnaldo Carvalho de Melo , Jiri Olsa Cc: Namhyung Kim , Alexander Shishkin , Adrian Hunter , Andi Kleen , Peter Zijlstra , Ingo Molnar , linux-kernel References: <1ec29ed6-0047-d22f-630b-a7f5ccee96b4@linux.intel.com> Organization: Intel Corp. Message-ID: <0081ef74-c3cf-1387-76e1-73d8396b6748@linux.intel.com> Date: Wed, 21 Oct 2020 19:06:26 +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: <1ec29ed6-0047-d22f-630b-a7f5ccee96b4@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