Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp4639693pxt; Wed, 11 Aug 2021 10:27:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxa3vM58lUM9bM+5n/mfTP/t6sLgNyjgQW2VYfT0DMP5ujUdNMzb5SBz6bjVTB3gOfHuQXB X-Received: by 2002:a92:d3cb:: with SMTP id c11mr524750ilh.178.1628702856830; Wed, 11 Aug 2021 10:27:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628702856; cv=none; d=google.com; s=arc-20160816; b=nMAUwGCUJKgZ5OupNdyiOil0zBGzFK/z37F69aqXeiJP5zfMik34cdgFUlShBbee1n sF5+58nJbQC6IKRNZRxKOudqQTP0ZXL6p246ARGX0Ju9/e/mlEioS1rknSVVR47kTvIc SfzS3Ki4KKUeiMLM9QMJhWeO7c2L+2wSytyoiCHHrEaMs6sRfZkAuL3f638mtwkbTRx/ 7hE6ZIEONsgy4rNHSh+y0psWvv6UVfoE9xrv9NXiRhS3/oeXTzL5NQlxr8tbAWTQZ6UV V/z8AaB4fZl3hWQDXpPhCwIASgMo9oAirS/Lc05eS7mrSJoZRO2mafj797eH1cTDPgnm l2eg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id:dkim-signature; bh=DWvqc34M0ZK2EGSXjdGxz7cbJSBM1coi0S6xSk7PUWs=; b=LXeGonYz9n4nfq+VrMoF5UvCKtdxFb7iqFgsTCxndE3ihE1d/1QBwDdMGMrLaHL1PI CHOeN8zM0nGi2D3JaRVCkpdgsPPTaJRp0ZFBcqR68oH9mfHtElZoYsP/X6KRoTjTXrdL mmYeoccXYv1GolmgAe8oa1MRYhdlMlXphIyVzfvG4yjXwT3OEo4Ijt6CVWRsJVCpCNrn pVCDhqOnhK/DSYvCat/4FCRshGXjWnxYLjjJltjnNrbu0dqcPxzPZ2NPa8UBhb9ll7KB /SJz97svIWY8Sd6c5hohNrogOC37e2WKBzPQ3byrrIoeMYxJiNTyfxCQHoO1oal6TdTS c3Qg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=BK9QzVTR; 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 n2si85712jaj.0.2021.08.11.10.27.04; Wed, 11 Aug 2021 10:27:36 -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=BK9QzVTR; 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 S231203AbhHKRZM (ORCPT + 99 others); Wed, 11 Aug 2021 13:25:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229835AbhHKRZL (ORCPT ); Wed, 11 Aug 2021 13:25:11 -0400 Received: from mail-ej1-x62d.google.com (mail-ej1-x62d.google.com [IPv6:2a00:1450:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D870C061765 for ; Wed, 11 Aug 2021 10:24:47 -0700 (PDT) Received: by mail-ej1-x62d.google.com with SMTP id e19so5770219ejs.9 for ; Wed, 11 Aug 2021 10:24:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:subject:from:to:cc:date:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=DWvqc34M0ZK2EGSXjdGxz7cbJSBM1coi0S6xSk7PUWs=; b=BK9QzVTRpGyzDkoBFfdJJkKd90zIOGHtmLD9BA3YYgN3PCg5d76bwIyeGlRJxeb8gp FXb7ULf9R+RyPA4/UtYT3dlDeB7q7FTQsgm48gX0gR03Lv46niVG1xV05iQAWQrhj9EO xoJlSt9js7AswkJOjVbAAKUhxWOqEkKr+WUJOgNY+Y2RMLvUKG6DgXXNgjUlWTP5ml+w q2lali5/xGa1iinUbYkHppl4b8LTWSposqgeuKy+A0s+Rgofj6PsfQ24R6aU52pSm9s7 LvHdkOUbve5lAE3r83irFFPInmsLWa+3WLfOV4EaB2IfqFtpeYcrD3birjbv8a7usSt9 JXNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=DWvqc34M0ZK2EGSXjdGxz7cbJSBM1coi0S6xSk7PUWs=; b=E4Bh53+I/qgY1HZ/n9uuHMe0SGAUfenwbtLXvoGACk9IgWoUUfzbyeu7bZIi6ZNUCr 5PJBIP/UdYL9ZGAb9oFlkRK4MDPE1QwF3T5JrghuRHnM3Qv7ZrwpxCHLqquxwXm80yhB V0TzlF65W1Lv4f+RHTFsBeeuRU8Qw5kOm6OPJN8b3qcdyJohgELlZ2bIbmUtZ6ozihJw 4Dt7eFSPwkJcN01zCDjumdkoeVz/LP8Y20oeLdSwrFbf45BEwJQqdLFGuv9WSZFmmJUh UBnnzf39/1hcq7ZxEk7S59UJQL0rCDM/OB8ZgVi883qRkRXKmJPuSJofq8V5Bk9TF7pK rT2A== X-Gm-Message-State: AOAM530BXdJ4oq+ON1X/7qM4f7vBDIZZ3VC7XoXYiTG4/TeM/BfzGXfO 0P7wLX+dQin0W2XfeTNCMLo= X-Received: by 2002:a17:907:7e89:: with SMTP id qb9mr4620756ejc.333.1628702685767; Wed, 11 Aug 2021 10:24:45 -0700 (PDT) Received: from [172.16.0.82] (nat-allievi.sssup.it. [193.205.81.9]) by smtp.gmail.com with ESMTPSA id fi23sm12984ejc.83.2021.08.11.10.24.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Aug 2021 10:24:45 -0700 (PDT) Message-ID: <2039de9b117b11131b7ecc054cca800a3a71831f.camel@gmail.com> Subject: Re: [PATCH v10 08/24] perf record: Introduce data file at mmap buffer object From: Riccardo Mancini To: Alexey Bayduraev , Arnaldo Carvalho de Melo Cc: Jiri Olsa , Namhyung Kim , Alexander Shishkin , Peter Zijlstra , Ingo Molnar , linux-kernel , Andi Kleen , Adrian Hunter , Alexander Antonov , Alexei Budankov Date: Wed, 11 Aug 2021 19:24:42 +0200 In-Reply-To: <9f112977fb46418f6275fef45612c662d03db66d.1626072009.git.alexey.v.bayduraev@linux.intel.com> References: <9f112977fb46418f6275fef45612c662d03db66d.1626072009.git.alexey.v.bayduraev@linux.intel.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.40.3 (3.40.3-1.fc34) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Mon, 2021-07-12 at 09:46 +0300, Alexey Bayduraev wrote: > Introduce data file and compressor objects into mmap object so > they could be used to process and store data stream from the > corresponding kernel data buffer. Make use of the introduced > per mmap file and compressor when they are initialized and > available. > > Acked-by: Andi Kleen > Acked-by: Namhyung Kim > Signed-off-by: Alexey Bayduraev > --- >  tools/perf/builtin-record.c | 3 +++ >  tools/perf/util/mmap.c      | 6 ++++++ >  tools/perf/util/mmap.h      | 3 +++ >  3 files changed, 12 insertions(+) Testing this patch I encounter an issue with the perf test 19 ("import python"): $ ./perf test 19 -vvv Couldn't bump rlimit(MEMLOCK), failures may take place when creating BPF maps, etc 19: 'import perf' in python : --- start --- test child forked, pid 147201 python usage test: "echo "import sys ; sys.path.append('python'); import perf" | '/usr/bin/python2' " Traceback (most recent call last): File "", line 1, in ImportError: python/perf.so: undefined symbol: zstd_fini test child finished with -1 ---- end ---- 'import perf' in python: FAILED! The problem is caused by the fact that the perf.so library for Python is not compiled with -lzstd, but it includes mmap.c. Since I don't think zstd_* functionality is used by Python, we can provide stub functions instead of adding the zstd dependency to the Python library. Thanks, Riccardo > > diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c > index cb8d320d20a9..d67a09e26792 100644 > --- a/tools/perf/builtin-record.c > +++ b/tools/perf/builtin-record.c > @@ -197,6 +197,9 @@ static int record__write(struct record *rec, struct mmap > *map __maybe_unused, >  { >         struct perf_data_file *file = &rec->session->data->file; >   > +       if (map && map->file) > +               file = map->file; > + >         if (perf_data_file__write(file, bf, size) < 0) { >                 pr_err("failed to write perf data, error: %m\n"); >                 return -1; > diff --git a/tools/perf/util/mmap.c b/tools/perf/util/mmap.c > index ab7108d22428..a2c5e4237592 100644 > --- a/tools/perf/util/mmap.c > +++ b/tools/perf/util/mmap.c > @@ -230,6 +230,8 @@ void mmap__munmap(struct mmap *map) >  { >         bitmap_free(map->affinity_mask.bits); >   > +       zstd_fini(&map->zstd_data); > + >         perf_mmap__aio_munmap(map); >         if (map->data != NULL) { >                 munmap(map->data, mmap__mmap_len(map)); > @@ -291,6 +293,10 @@ int mmap__mmap(struct mmap *map, struct mmap_params *mp, > int fd, int cpu) >         map->core.flush = mp->flush; >   >         map->comp_level = mp->comp_level; > +       if (zstd_init(&map->zstd_data, map->comp_level)) { > +               pr_debug2("failed to init mmap commpressor, error %d\n", errno); > +               return -1; > +       } >   >         if (map->comp_level && !perf_mmap__aio_enabled(map)) { >                 map->data = mmap(NULL, mmap__mmap_len(map), > PROT_READ|PROT_WRITE, > diff --git a/tools/perf/util/mmap.h b/tools/perf/util/mmap.h > index 9d5f589f02ae..c4aed6e89549 100644 > --- a/tools/perf/util/mmap.h > +++ b/tools/perf/util/mmap.h > @@ -13,6 +13,7 @@ >  #endif >  #include "auxtrace.h" >  #include "event.h" > +#include "util/compress.h" >   >  struct aiocb; >   > @@ -43,6 +44,8 @@ struct mmap { >         struct mmap_cpu_mask    affinity_mask; >         void            *data; >         int             comp_level; > +       struct perf_data_file *file; > +       struct zstd_data      zstd_data; >  }; >   >  struct mmap_params {