Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp2184659ybm; Sun, 31 May 2020 11:24:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwluh7NNpxD3/Fmm0xkWEsQ5sioISh0E2PqUEhIamIH+ZskLrbjkZPNQatvTUbooGayCx3q X-Received: by 2002:aa7:cac8:: with SMTP id l8mr18481898edt.103.1590949490513; Sun, 31 May 2020 11:24:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590949490; cv=none; d=google.com; s=arc-20160816; b=LZFjzHAao+1rVGnh9lu73fw3XIZtz38e/8zFV41KDR/0/PeSVra/1inDs1yfJVQC31 o3u105d5tBU05y5CcZrU3NOQVl7JFVCN8NlOWOpfxxuHqlYVqlGo9nwbEcVBM3Skd9dD 0Js0E8nDzt5mlxcorgtnbljiXnkmVxgmgbMspg1oh8QGg8pOHwF2chaL8VzZgPwIm/DL oaGxlW5Bnmz8G6vV3+DuQVsP3SMKm217R5Oua0teV8jz3st6Y9tKRkN7NvVgJg87u3CP RVUnzpl0UINNkPsGZH3wbWQr5nSsGMcvLAOjdQQOezY3ntj7zoanBFAxU2dBJu8PWLXe dRwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=nJlzPFi1GzBnXpJrMl3pAkK/ydATTI/Qh7Ges7bcjcQ=; b=v6YodNnDt5v0oK8Go89r6Ieuvb/qgBozhqwI2Yts0DGcspg3FLPD0s/VJYy5iu7ZEi LRaKGV13Lmj1FJ/MGlEWp5i3h2jPxYGgWF3/O+yWlS1tJosXycALeIWlXsr3kDO2+N8t O4Zi1tMkWAzp0sowPuXr6BBZoydiQqirW7GDZd1HDQvSLQhJwnTSFWeyNw1i3TO+gwUl sQuFATrP1PJonq9Fr9orj1KryyL5NCJ6X3beYBaSJe9Rc0xIp6LzOLF4wiQ1rXUQFalm VB+jhuRaCj9dAOjrBas0GrTmeWcb6Ox8aM4jJSjYBW+qwO7+09/WQF/COMZGUJyF2ves pgqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=UewlZAQJ; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l10si9552695edv.152.2020.05.31.11.24.27; Sun, 31 May 2020 11:24:50 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=UewlZAQJ; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728318AbgEaSTY (ORCPT + 99 others); Sun, 31 May 2020 14:19:24 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:58968 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726008AbgEaSTX (ORCPT ); Sun, 31 May 2020 14:19:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1590949162; 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=nJlzPFi1GzBnXpJrMl3pAkK/ydATTI/Qh7Ges7bcjcQ=; b=UewlZAQJgaJyFDKwZZ6F9G8p8+F5kxu7GIIdzdWNbNAPM8MdKxdF7NSMUHg+dT8+lbZi3H xXrZhYnyfbM/Projfu6Cr1XRLfNEmYwwwotjlYriD/aNl6vcknASTQSs4qa/3dURj7hP/j IbKGrSYSAtwpWNcT4uCqRYV3/oQNgC4= 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-370-ZNufbv33PF6AiEx3J36KTw-1; Sun, 31 May 2020 14:19:17 -0400 X-MC-Unique: ZNufbv33PF6AiEx3J36KTw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B71F3107ACF2; Sun, 31 May 2020 18:19:15 +0000 (UTC) Received: from krava (unknown [10.40.192.36]) by smtp.corp.redhat.com (Postfix) with SMTP id A602D7C09A; Sun, 31 May 2020 18:19:13 +0000 (UTC) Date: Sun, 31 May 2020 20:19:12 +0200 From: Jiri Olsa To: Alexey Budankov Cc: Arnaldo Carvalho de Melo , Namhyung Kim , Alexander Shishkin , Peter Zijlstra , Ingo Molnar , Andi Kleen , linux-kernel Subject: Re: [PATCH v4 01/10] tools/libperf: introduce static poll file descriptors Message-ID: <20200531181912.GC881900@krava> References: <653fe5f3-c986-a841-1ed8-0a7d2fa24c00@linux.intel.com> <024af6a7-8085-c28d-5067-6ab3225bdc82@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <024af6a7-8085-c28d-5067-6ab3225bdc82@linux.intel.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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? jirka > + > + res = poll(fda->entries, fda->nr, timeout); > + > + for (i = nr; i < fda->nr; i++) > + fda->stat_entries[fda->priv[i].idx] = fda->entries[i]; > + > + fda->nr = nr; > + > + return res; > } SNIP