Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1677861ybt; Thu, 25 Jun 2020 11:25:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw5n+HrVFpUPjkIH5nnavwc+WtxsN3armPz1tT0Do7ADTL2MOUHpXZB+SDvVUrhAQfJVdB5 X-Received: by 2002:a05:6402:158d:: with SMTP id c13mr28860812edv.103.1593109548155; Thu, 25 Jun 2020 11:25:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593109548; cv=none; d=google.com; s=arc-20160816; b=HwfxTU4BnFZwhf8SxBBFcZGrEKAO6gYPyNSeEwqvinUn9EunqKiaBgmm9/L2AHb07H xK1XrgfSVvQ6EeolneCE7iJVytIEcWOG3gcgjB/BproyDGO4dVL23qFKTFHTlAldRfNN H7Sw9x7fDaOuN13kEZlMT8OExmub2CakiXrBUej2w3G7uzu62PpggkS9Xyq1Q+gu5Trz 0KijAEBu0nP3CH11KDw1rUEqEf/sVR91eiWgTUGiU73DND2CKb2Ie1Um4BzBD8TD3sKR kCiDbiUIT0+0re4/s0AVZrDeELmf04ig2TZgYeD3syFgZ0+r7j7b+XSH+mbm/uO1N8bY fPYw== 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=l1emsNKKRVQODfeJuv9joSCPbwXeNurKbQv14gCACCM=; b=KhedDi3AkWfobq+Z94aSeM16sCXerdNHHKqi+Xmu2gXpkW1CjflhQ/XzG3KmmFfkyy HGKL09oBU5plxTwKx/g26mTPsiH8Aw5j6sQLSsMACV0M4vEdqQXOh2oFE4g0jnZkzUx2 0K4XsZ8IDT8xqikIubcFhIBFwnCtLEhM2ncyG2BzX71rPBrCOPeKKvW7/VX92qOVQ+JF Y5LpppSzz3VzfjKnczbnvEzjsyb6f83t7OORj0F400ejUSQ25+8K/mOpn0k4ipiANC4J RsULY3a2wGyDoy85m7HfJT785F5NgXP13s+A6sG/Y7Z0kcBYWlOCsU0qE875PuxeYGtH 4dRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=B64WNWJq; 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 a16si6989249eju.669.2020.06.25.11.25.23; Thu, 25 Jun 2020 11:25:48 -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=B64WNWJq; 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 S2406696AbgFYROP (ORCPT + 99 others); Thu, 25 Jun 2020 13:14:15 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:31045 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2406692AbgFYROO (ORCPT ); Thu, 25 Jun 2020 13:14:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593105253; 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=l1emsNKKRVQODfeJuv9joSCPbwXeNurKbQv14gCACCM=; b=B64WNWJqCLjX9tFTv6kXMuBKND+Wt4fHjQBcqxvrlxbtYYXK00zCrYy49DQu+Dmlxy42eI Kp9gfLQtAtu5sfubl43w9HWN+uNcGbbKdhOSI/3SnGpr16irM4We77OHagIC6+8raUSNmi IHp1THv+BA42otYbSkpMeDVDeDOhZ2k= 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-260-UBiyFTg6OpK_UbWbNz2lAA-1; Thu, 25 Jun 2020 13:14:09 -0400 X-MC-Unique: UBiyFTg6OpK_UbWbNz2lAA-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DD0BB800D5C; Thu, 25 Jun 2020 17:14:07 +0000 (UTC) Received: from krava (unknown [10.40.192.78]) by smtp.corp.redhat.com (Postfix) with SMTP id 28A5B5D9D3; Thu, 25 Jun 2020 17:14:05 +0000 (UTC) Date: Thu, 25 Jun 2020 19:14:05 +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 v8 01/13] tools/libperf: avoid moving of fds at fdarray__filter() call Message-ID: <20200625171405.GL2719003@krava> References: <0781a077-aa82-5b4a-273e-c17372a72b93@linux.intel.com> <3d36dc7a-4249-096c-7554-80e6d290eac5@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 24, 2020 at 08:19:32PM +0300, Alexey Budankov wrote: > > On 17.06.2020 11:35, Alexey Budankov wrote: > > > > Skip fds with zeroed revents field from count and avoid fds moving > > at fdarray__filter() call so fds indices returned by fdarray__add() > > call stay the same and can be used for direct access and processing > > of fd revents status field at entries array of struct fdarray object. > > > > Signed-off-by: Alexey Budankov > > --- > > tools/lib/api/fd/array.c | 11 +++++------ > > tools/perf/tests/fdarray.c | 20 ++------------------ > > 2 files changed, 7 insertions(+), 24 deletions(-) > > > > diff --git a/tools/lib/api/fd/array.c b/tools/lib/api/fd/array.c > > index 58d44d5eee31..97843a837370 100644 > > --- a/tools/lib/api/fd/array.c > > +++ b/tools/lib/api/fd/array.c > > @@ -93,22 +93,21 @@ int fdarray__filter(struct fdarray *fda, short revents, > > return 0; > > > > for (fd = 0; fd < fda->nr; ++fd) { > > + if (!fda->entries[fd].revents) > > + continue; > > + > > So it looks like this condition also filters out non signaling events fds, not only > control and others fds, and this should be somehow avoided so such event related fds > would be counted. Several options have been proposed so far: > > 1) Explicit typing of fds via API extension and filtering based on the types: > a) with separate fdarray__add_stat() call > b) with type arg of existing fdarray__add() call > c) various memory management design is possible > > 2) Playing tricks with fd positions inside entries and assumptions on fdarray API calls ordering > - looks more like a hack than a designed solution > > 3) Rewrite of fdarray class to allocate separate object for every added fds > - can be replaced with nonscrewing of fds by __filter() > > 4) Distinct between fds types at fdarray__filter() using .revents == 0 condition > - seems to have corner cases and thus not applicable > > 5) Extension of fdarray__poll(, *arg_ptr, arg_size) with arg of fds array to atomically poll > on fdarray_add()-ed fds and external arg fds and then external arg fds processing > > 6) Rewrite of fdarray class on epoll() call basis > - introduces new scalability restrictions for Perf tool hum, how many fds for polling do you expect in your workloads? jirka