Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp39427pxx; Mon, 26 Oct 2020 02:44:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxEbAIxReu0LN2HfWlcPkEeIwGuxFBJg2Cw/yYiVkNeuFWX0KyZ2gwCQWvn1lrpVJh13Nk4 X-Received: by 2002:a17:906:4811:: with SMTP id w17mr14326837ejq.431.1603705494703; Mon, 26 Oct 2020 02:44:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603705494; cv=none; d=google.com; s=arc-20160816; b=fxFvPhccsluZeOYRRKhfLVau+pNOB14m1oh1rKfrkwTyoGQLxXuyZtIBlpppl6xDw9 1l24ewcEknyiOHm3MFXZZR1rUwBtjIenpTJP4szDQXVlic4dngXstzZr8G1EqweDBWcr XDeKOS2AMj0ho3/vDxkFL0Qd5Jrm6kcXKzZEhbdyoTm9Gmr8ZirbLkYKLlpAeXlu8+V1 aF+rVHYDgNUlUOwLCugQaIrtowgEMdY9jl1+t8B1kFnwLUJ+GH4xe03cD+ssb5C1dq90 sAD2UTnDA5g80qOLu30ViX7xMeuBsx4duXxcS9hkFuZQGa0yg0KRiajKK170M5zjeTp9 adCw== 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 :from:references:cc:to:subject:dkim-signature; bh=r6LXcxUBFULLz9MajPuPGZldQp5EFd4JcICdU+XliWA=; b=TKAN6adbQUpVRl9W9ESKIChpqRTbHR1bhP73SOc4Ssap0dCgUZk809QOipGSUlJ6uB VnIZ9hULEML9wjybzkhqnf5rycUTXDFdT7rbbNrsc3MsTvel8f9LBewVvMgCo7icmDJm 7/YGyBYJcdxvUxTJXpsNO4ueOZAwGlcJ4z2+QJprIngArJKhu++9jdD+eF9TYNbCUTBt PJGhYab6q6uUrxvMl/rOKoQ/npDlKtl2vqxzyv3dsiHDNbVs5D9W74va0TlDhZT6l7yN 3gK8mt7R3q25FCZpdTP5I3XuY/7nr8L5xXQOlSuRiZ4p1jQxY9nJV27VVaaYdiR/8+u3 Jf+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=cKUvRpw7; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lg21si6942264ejb.136.2020.10.26.02.44.31; Mon, 26 Oct 2020 02:44:54 -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=@gmail.com header.s=20161025 header.b=cKUvRpw7; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1769485AbgJZIVd (ORCPT + 99 others); Mon, 26 Oct 2020 04:21:33 -0400 Received: from mail-lj1-f196.google.com ([209.85.208.196]:42449 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1769297AbgJZIVc (ORCPT ); Mon, 26 Oct 2020 04:21:32 -0400 Received: by mail-lj1-f196.google.com with SMTP id h20so8812427lji.9 for ; Mon, 26 Oct 2020 01:21:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:organization:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=r6LXcxUBFULLz9MajPuPGZldQp5EFd4JcICdU+XliWA=; b=cKUvRpw74n4m6xMHyyRmm6ZAkVenzokix5npG5c2OIZjGN1JJYN+H6mjYGmDi0+dAc clKFDYG+g0NLxygz0iHEZRXOh6rdOkjosujsEp9H40mHHrS+yplz5YJpdABE/J2XkviS sUEuobrk/dU1GwNRRoLrjbJXU6fn58yKXP1fMSMMiDOks/frHcAOC6xmKjAVPmRfNfZU 9PXaYveOs6hrmOntKb7jEscH8Wu/mYGQ8dqNxvku1pyPWzBK+lGLQyPYLqhUFhLALpmz VhFh3nut+YNLfiPq3vNqmjdNvd9D3jVecECItccAjc7xlh3e5lsH23yK2WhNBkyyDJ9N a9sw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:organization :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=r6LXcxUBFULLz9MajPuPGZldQp5EFd4JcICdU+XliWA=; b=kDCODAjM0KhnbGU2cv/LZRjZ5sFTnTiLnjrwzMp0MDUVbMacP1vPyTxIyU9o+hJ5+R wKKtbmvmuCUYnG6224eNsyH9hjTP6/m99jsvWvtH179lXdFx1V/IrgK5BSlaMgaSTuYR BH3JPyf1BxKI8+qQci4Y5hy3Mlr6amqZ5VO7KhU769oq09zRBzhIZX28xfAwed099+mr nMCsiq+Qbwk1Qo6ksVrGZf4Inevdmt8BBLtZw0nihJIWeRWugGBFxQvGO+nTh1Q3KxdT 1pB1JfsB1Q5ftasD8NGZnf6tPfTUZE8oE138XgOnkyUExiwl8LV83tLw2cntLVnlRWNv naQg== X-Gm-Message-State: AOAM530g6ttwfoKjBIKlR5xzJsJlsjvqrxK5qITJstdaxa7HyWwqoKXE hnPC+yDuB5Fy/7tprLTfW6k= X-Received: by 2002:a2e:b015:: with SMTP id y21mr5656138ljk.367.1603700490083; Mon, 26 Oct 2020 01:21:30 -0700 (PDT) Received: from [192.168.0.10] (89-109-58-109.dynamic.mts-nn.ru. [89.109.58.109]) by smtp.gmail.com with ESMTPSA id y3sm1092748ljn.6.2020.10.26.01.21.29 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 26 Oct 2020 01:21:29 -0700 (PDT) Subject: Re: [PATCH v2 12/15] perf record: introduce thread local variable for trace streaming To: Jiri Olsa , Alexey Budankov Cc: Arnaldo Carvalho de Melo , Namhyung Kim , Alexander Shishkin , Adrian Hunter , Andi Kleen , Peter Zijlstra , Ingo Molnar , linux-kernel , budankov.lore@gmail.com References: <1ec29ed6-0047-d22f-630b-a7f5ccee96b4@linux.intel.com> <20201024154357.GD2589351@krava> From: Alexei Budankov Organization: Intel Corp. Message-ID: <6eb97205-4d13-6487-8e15-a85f63d3f0cc@gmail.com> Date: Mon, 26 Oct 2020 11:21:28 +0300 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.4.0 MIME-Version: 1.0 In-Reply-To: <20201024154357.GD2589351@krava> 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 On 24.10.2020 18:43, Jiri Olsa wrote: > 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 This does look like data parallelism [1] which is very true for threaded trace streaming so your prototype design looks optimal. For this specific place incrementing global counter in memory is less performant and faces scalability limitations as a number of cores grow. Not sure why you have changed your mind. Alexei [1] https://en.wikipedia.org/wiki/Data_parallelism#:~:text=Data%20parallelism%20is%20parallelization%20across,on%20each%20element%20in%20parallel.