Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp275304ybg; Mon, 1 Jun 2020 00:38:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyjqvV86JHEHYFWWUy843Cq5i5oE4DH0lAy3sZ1byQCrWZcW/WXaQVV4FqCugPJX+xKb15a X-Received: by 2002:a17:906:55c9:: with SMTP id z9mr3962529ejp.276.1590997103228; Mon, 01 Jun 2020 00:38:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590997103; cv=none; d=google.com; s=arc-20160816; b=lUINgM1POJF1qDO+kKOgNP4+Yb1SGpISGq84p+/gJ+mTFChXYwU+s89zISIBzTJUPv /2FyD3HJPhCV5iq0LsB1qUMIjvlQnUc+8lgqQjfSUgLrl7E9c2G1LMyiyulYzOITqt1J Cif3VHBFty20Zhboj7CHN1nWjgb3BaaYJgglEQHkG3s4M2HbhVKvx6UCtOUWrqqZDu4Y x4BylYLq67CSfGaPuBI317YL4jI8gAeGRK8t2wda+yuyMfHq5SYgHoEQdRUl0gzyffjV NofKaXd4jE7Ci2cJwvJH3+w/H4Ptv7ktAERAsyspY5eiz/PwxRa00Kikg/j9c+THlpap qe3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:organization:from:references:cc:to:subject:ironport-sdr :ironport-sdr; bh=gM95B4RItQIi4KHaqseDmiikFcwGl+TL7SgIO5z025U=; b=s9MrfBAsArh0u4JpVEBKJwFlSr6aKrnBdw5J97eSp9c9i4wqTe0PbuVn/AU4m0nB/p RvaiLHyoN0cV1ghUdeMTBylIkT3H7awz2YXuBit1yj9/I4+04eqSn5Mm2hD5Pff6/iyS Tqwqd3tOt+QCC789Gbc36R9rVgQx/rsaxqXCjlb+6eA8PF2Z7pPMSql5XLV6bTFijOtp bBxnxMvO9az58Y5GNSegLYpz/PECwJPVlHhHMmyF0DPaglvHi+FxTwsqVZFk6nN8/3KB Qnaa2lD9GIocRjlAS4DdfiAzSeM0fLQio+YpTTsNcgaDBkVuq8ZWUkOeBfftcJLRlP7b Yikg== 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 k13si10123953edh.53.2020.06.01.00.37.59; Mon, 01 Jun 2020 00:38:23 -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 S1726901AbgFAHeL (ORCPT + 99 others); Mon, 1 Jun 2020 03:34:11 -0400 Received: from mga12.intel.com ([192.55.52.136]:18801 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725283AbgFAHeK (ORCPT ); Mon, 1 Jun 2020 03:34:10 -0400 IronPort-SDR: 9tZuvrGp8G3zUqqOMTCb1ORI5YYusO6tGJ+MjBOf9f9pp4Fdi7fkaoLgKS7cswXfhVxkQdLMaX 50AFFt+v5vJg== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2020 00:34:08 -0700 IronPort-SDR: Cac736ptcxbsLp+gZlilKceM85eh+ueZdoNBBewTgzs2ETGZfwXL8ZeimMB8ZgEhxqSmZL2Cav eesdnnVx/cCw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,460,1583222400"; d="scan'208";a="415718629" Received: from linux.intel.com ([10.54.29.200]) by orsmga004.jf.intel.com with ESMTP; 01 Jun 2020 00:34:08 -0700 Received: from [10.249.230.65] (abudanko-mobl.ccr.corp.intel.com [10.249.230.65]) by linux.intel.com (Postfix) with ESMTP id B5BDA580522; Mon, 1 Jun 2020 00:34:06 -0700 (PDT) Subject: Re: [PATCH v4 01/10] tools/libperf: introduce static poll file descriptors To: Jiri Olsa Cc: Arnaldo Carvalho de Melo , Namhyung Kim , Alexander Shishkin , Peter Zijlstra , Ingo Molnar , Andi Kleen , linux-kernel References: <653fe5f3-c986-a841-1ed8-0a7d2fa24c00@linux.intel.com> <024af6a7-8085-c28d-5067-6ab3225bdc82@linux.intel.com> <20200531181912.GC881900@krava> From: Alexey Budankov Organization: Intel Corp. Message-ID: Date: Mon, 1 Jun 2020 10:34:05 +0300 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.8.1 MIME-Version: 1.0 In-Reply-To: <20200531181912.GC881900@krava> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 31.05.2020 21:19, Jiri Olsa wrote: > On Mon, May 25, 2020 at 05:17:31PM +0300, Alexey Budankov wrote: > > SBIP > >> +int fdarray__add_stat(struct fdarray *fda, int fd, short revents) >> +{ >> + int pos = fda->nr_stat; >> + >> + if (pos >= FDARRAY__STAT_ENTRIES_MAX) >> + return -1; >> + >> + fda->stat_entries[pos].fd = fd; >> + fda->stat_entries[pos].events = revents; >> + fda->nr_stat++; >> + >> + return pos; >> +} >> + >> int fdarray__filter(struct fdarray *fda, short revents, >> void (*entry_destructor)(struct fdarray *fda, int fd, void *arg), >> void *arg) >> @@ -113,7 +133,27 @@ int fdarray__filter(struct fdarray *fda, short revents, >> >> int fdarray__poll(struct fdarray *fda, int timeout) >> { >> - return poll(fda->entries, fda->nr, timeout); >> + int nr, i, pos, res; >> + >> + nr = fda->nr; >> + >> + for (i = 0; i < fda->nr_stat; i++) { >> + if (fda->stat_entries[i].fd != -1) { >> + pos = fdarray__add(fda, fda->stat_entries[i].fd, >> + fda->stat_entries[i].events); >> + if (pos >= 0) >> + fda->priv[pos].idx = i; >> + } >> + } > > hum, so every time we call evlist__poll we end up in here > adding more stuff to entries? It depends on whether static fds were added by perf_evlist__add_pollfd_stat() or not. If they weren't then poll() checks only event fds added by perf_evlist__add_pollfd(). If static fds have been added and there are valid (!=-1) fds still then they are appended to fds array. After return from poll() its result copied back to static fds storage so fds state could be checked separately from event fds. ~Alexey