Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3249739pxb; Mon, 1 Mar 2021 05:36:52 -0800 (PST) X-Google-Smtp-Source: ABdhPJzh/SOPl4abc1Md/7KZVbLkHlqhb5o1m0kiP8XTqZyofQoI3IAhSFF8RvWamjBL3ProRTIU X-Received: by 2002:a05:6402:95b:: with SMTP id h27mr1837643edz.93.1614605812006; Mon, 01 Mar 2021 05:36:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614605812; cv=none; d=google.com; s=arc-20160816; b=dNlNJ6yDJfnioO+4x5ZJVwaiQo11ZLfqCtWx0UV/Q33jlMbVaW6RIQkgRYLFVHplku kaHKg/C5LTkdY44m5GZuQraPP92pqYp3tsEh2XtyfC0uTX8f32ganB9ogAYC/ic3/sXO fWD9GaQpuFSI4SMnHIBi7wvcu+yN4KMXdgQ8a+uXSmOpNH4+sJDbS/7PRLNeqrK5PqU5 yyc8Po89i4UMaFSf6RbjIHV6zmD1+nXOc+6JW1CHNiSlPNRWNnvwR2GeWU9sXUW4aXtd nc3ie1C+mdYVpo9m1zALMIpjB43s6y9Wz0VBrUbttfs1e+HumD6ILgf746heaNcLKJLF CsHQ== 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:ironport-sdr:ironport-sdr; bh=zGHnRSxCn7dPF2+FZ2uT8bdLOqYW7hMCV8pka+6fVKM=; b=Fnn9Z61CDIObTVTpI/s8JXjU6BXCQOnsQppPzWiXYI7SCUrF9VxUPy+MdQVtRERxa0 bDrcG37MScAp6U5UuqQ2u8wPPYsfefXjGXe2n6r1MO2FZtfzfujPjbmknMw2/swciP6o VUqygLmU3jd6eiNiKpwHHnTXVv12jSazCTx0SKf2p42zFcr2c6Yo3D7LuNXfczOrbIvZ PHgLz9iWc01U4TKtmIEff9rkRq3oi3A4bYSOc9WSvhBgK4+ToBF3rNcdRFDoSkNKdh2k Osf9PvlhvsDlE7/Fns4fWXJYbihWwYF2xWpOjlp+TE82F1tLH5vvqcQCbw1Ex5dkUy7H OGlw== 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 ap16si11432017ejc.684.2021.03.01.05.36.29; Mon, 01 Mar 2021 05:36:51 -0800 (PST) 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 S235821AbhCANfX (ORCPT + 99 others); Mon, 1 Mar 2021 08:35:23 -0500 Received: from mga12.intel.com ([192.55.52.136]:52702 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235788AbhCANe6 (ORCPT ); Mon, 1 Mar 2021 08:34:58 -0500 IronPort-SDR: 3mwROtW2oImpT2UeKA3yI9prNDEVyCDfls2QBB2PkWG+ahiknVtVYrSZgAfRqwkIygf2/280If zh82HDL2NJcQ== X-IronPort-AV: E=McAfee;i="6000,8403,9909"; a="165693921" X-IronPort-AV: E=Sophos;i="5.81,215,1610438400"; d="scan'208";a="165693921" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Mar 2021 05:33:07 -0800 IronPort-SDR: GGaEyhRd3vcdCX0Nvx+OskmMNaHiwSC+BZukEPScoH2fv6AcMlt4W+2WVDfeq7s8mF8yWwefqZ HKqLDAhzM4/Q== X-IronPort-AV: E=Sophos;i="5.81,215,1610438400"; d="scan'208";a="406226018" Received: from abaydur-mobl1.ccr.corp.intel.com (HELO [10.249.226.70]) ([10.249.226.70]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Mar 2021 05:33:04 -0800 Subject: Re: [PATCH v3 07/12] perf record: init data file at mmap buffer object To: Namhyung Kim Cc: Alexei Budankov , Arnaldo Carvalho de Melo , Jiri Olsa , Alexander Shishkin , Peter Zijlstra , Ingo Molnar , linux-kernel , Andi Kleen , Adrian Hunter , Alexander Antonov References: <7d197a2d-56e2-896d-bf96-6de0a4db1fb8@linux.intel.com> <20201120104942.GF94830@google.com> <64b0859f-aad3-43fa-4e4c-81614d0c75e4@linux.intel.com> From: "Bayduraev, Alexey V" Organization: Intel Corporation Message-ID: Date: Mon, 1 Mar 2021 16:33:01 +0300 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 01.03.2021 14:44, Namhyung Kim wrote: > Hello, > > On Mon, Mar 1, 2021 at 8:16 PM Bayduraev, Alexey V > wrote: >> >> Hi, >> >> On 20.11.2020 13:49, Namhyung Kim wrote: >>> On Mon, Nov 16, 2020 at 03:19:41PM +0300, Alexey Budankov wrote: >> >> >> >>>> >>>> @@ -1400,8 +1417,12 @@ static int record__mmap_read_evlist(struct record *rec, struct evlist *evlist, >>>> /* >>>> * Mark the round finished in case we wrote >>>> * at least one event. >>>> + * >>>> + * No need for round events in directory mode, >>>> + * because per-cpu maps and files have data >>>> + * sorted by kernel. >>> >>> But it's not just for single cpu since task can migrate so we need to >>> look at other cpu's data too. Thus we use the ordered events queue >>> and round events help to determine when to flush the data. Without >>> the round events, it'd consume huge amount of memory during report. >>> >>> If we separate tracking records and process them first, we should be >>> able to process samples immediately without sorting them in the >>> ordered event queue. This will save both cpu cycles and memory >>> footprint significantly IMHO. >>> >>> Thanks, >>> Namhyung >>> >> >> As far as I understand, to split tracing records (FORK/MMAP/COMM) into >> a separate file, we need to implement a runtime trace decoder on the >> perf-record side to recognize such tracing records coming from the kernel. >> Is that what you mean? > > No, I meant separating the mmap buffers so that the record process > can save the data without decoding. > Thanks, Do you think this can be implemented only on the user side by creating a dummy event and manipulating by mmap/comm/task flags of struct perf_event_attr? Or some changes on the kernel side are necessary? Regards, Alexey >> >> IMHO this can be tricky to implement and adds some overhead that can lead >> to possible data loss. Do you have any other ideas how to optimize memory >> consumption on perf-report side without a runtime trace decoder? >> Maybe "round events" would somehow help in directory mode? >> >> BTW In our tool we use another approach: two-pass trace file loading. >> The first loads tracing records, the second loads samples. > > Yeah, something like that. With the separated data, we can do it > more efficiently IMHO. > > Thanks, > Namhyung >