Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp1377838pxu; Sat, 24 Oct 2020 08:49:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxs8r7NvUGClrVnSeyZSqL3ZdXjfFiCH7cmfk0rkv7qxxql+rivUhQQEeepiyMKzc49pGj6 X-Received: by 2002:a17:907:42d2:: with SMTP id ng2mr7224494ejb.124.1603554544564; Sat, 24 Oct 2020 08:49:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603554544; cv=none; d=google.com; s=arc-20160816; b=RJBTqJ8rp6zeVzwEl2tYBDc807pR+n8gm+ao+yPwL6GoIyLgFKiB+WqONP8dAj4UgD rMcyLrDP0h1lOonnhSt6Ar+50Ib9a/3MRVoAy8cPoDzKoSrNVJdTaz1mCYo7rDW4tKt6 yZuTkuLLeMiWerf0LqO/NJ9bHcOQxvv10P+pmR/3XhltzFkLG1TOEWNSKfLnO2gPppMC xs4Ox55TRVCgV+uVC67pbYKdrZd0mioHmcRWfst/DP/fD4p3bxV9PAinRrRxUHauQz1L B59ND4x3sQGpEa8cNNST42f4OqCISSowjcEYg6IM4GrXux5Jd9yeQ5pUAc/JbByPpJ6T P1ew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=8xLHDe8rVD+OjMq0aaRegU8pV9lJncI+VX4k02mtvQY=; b=zqK8aQaPeRjbdaxrwm08ZnyaDTdye8MDwONsiplSOF5nH+W2PWB6SxDZGvg1ELOw85 8AaOKl03LOX8BJOjT4kcYMewI6XmT1XITnPbX9B2jcsQ9tMcF8FzQpOS3PAhZY/fpw4g pY5PSvpxHXQHXvp8iCOt4RI3PRUuzg3uLxHVyOU+x34PM6pmc0IY951TRvtgpg78AbwV IYr2H9XCBTSJA/IsO9m7GCohZ+mdgObl8Ye1Q+cJUognybTnBHQX5Cynwe7LlnCTSntj YhG+ffChQ+/t7Ru5/qg0BUbdoRhNWMW935IejVJLJG5eCC8sMNtxRfoxO9RCSpVuRzQl lBBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=DGNgTSP3; 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 ba2si3210979edb.503.2020.10.24.08.48.42; Sat, 24 Oct 2020 08:49:04 -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=DGNgTSP3; 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 S1761985AbgJXPoI (ORCPT + 99 others); Sat, 24 Oct 2020 11:44:08 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:57476 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1761980AbgJXPoH (ORCPT ); Sat, 24 Oct 2020 11:44:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603554246; 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=8xLHDe8rVD+OjMq0aaRegU8pV9lJncI+VX4k02mtvQY=; b=DGNgTSP3duGVtn0jYfSM0hx0CVwwNHEooFynwuCJJPRzbTlvB7pQGBqy/VBpkNr+a2ioIj UXdffso6ez3xcdZ/gBAcigik0gtfEwvJoHoyrl6qyEzWVG6YiqWdbzENyGl9B5hZiBJlJG YxZ+3aUsLFYpG/KDGwwjDs1BppqMIuM= 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-301-xU-ie3EkN3OmGZ7mrA7RuQ-1; Sat, 24 Oct 2020 11:44:02 -0400 X-MC-Unique: xU-ie3EkN3OmGZ7mrA7RuQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A72D11006CB0; Sat, 24 Oct 2020 15:44:00 +0000 (UTC) Received: from krava (unknown [10.40.192.80]) by smtp.corp.redhat.com (Postfix) with SMTP id A436610013D0; Sat, 24 Oct 2020 15:43:58 +0000 (UTC) Date: Sat, 24 Oct 2020 17:43:57 +0200 From: Jiri Olsa To: Alexey Budankov Cc: Arnaldo Carvalho de Melo , Namhyung Kim , Alexander Shishkin , Adrian Hunter , Andi Kleen , Peter Zijlstra , Ingo Molnar , linux-kernel Subject: Re: [PATCH v2 12/15] perf record: introduce thread local variable for trace streaming Message-ID: <20201024154357.GD2589351@krava> References: <1ec29ed6-0047-d22f-630b-a7f5ccee96b4@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.84 on 10.5.11.22 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 21, 2020 at 07:07:00PM +0300, Alexey Budankov wrote: > > Introduce thread local variable and use it for threaded trace streaming. > > Signed-off-by: Alexey Budankov > --- > tools/perf/builtin-record.c | 71 ++++++++++++++++++++++++++++++++----- > 1 file changed, 62 insertions(+), 9 deletions(-) > > diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c > index 89cb8e913fb3..3b7e9026f25b 100644 > --- a/tools/perf/builtin-record.c > +++ b/tools/perf/builtin-record.c > @@ -101,6 +101,8 @@ struct thread_data { > u64 bytes_written; > }; > > +static __thread struct thread_data *thread; > + > struct record { > struct perf_tool tool; > struct record_opts opts; > @@ -587,7 +589,11 @@ static int record__pushfn(struct mmap *map, void *to, void *bf, size_t size) > } > } > > - rec->samples++; > + if (thread) > + thread->samples++; > + else > + rec->samples++; this is really wrong, let's keep just single samples counter ditto for all the other places in this patch SNIP > - if (hits == rec->samples) { > + if (thread) > + hits1 = thread->samples; > + else > + hits1 = rec->samples; > + > + if (hits0 == hits1) { > if (done || draining) > break; > - err = evlist__poll(rec->evlist, -1); > + > + if (thread) > + err = fdarray__poll(&thread->pollfd, -1); > + else > + err = evlist__poll(rec->evlist, -1); same here, why do we have the __thread struct then? jirka