Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp1377383pxy; Thu, 29 Apr 2021 06:01:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyxIc/RKDAQWLmIMX/lDk9exwA1P0Kr5j2vA5rePqWMwLxRHxlOvDgH4z9+4OIA1WFI26wT X-Received: by 2002:a17:906:a006:: with SMTP id p6mr35193019ejy.350.1619701265234; Thu, 29 Apr 2021 06:01:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619701265; cv=none; d=google.com; s=arc-20160816; b=FMzrlNLhzSsQUIsXRXQDwtp7R1qr/ZR0G1SHPLsfrxpiZEu7shB1PMKm/jODkl5rsy z9iGTXF/y/f+axjUPtpOxwGBNi6gPcUe1s+JXcBHu+7AYsjLPE83AgnHsJHioVsQLocs 9kQVskRL7sC/iB3FqU8cWBvfO73Qi4IBAB9SwDkYBPKbA6UPBI4DpJoGJ1MT8YRw5Q4G lbx28fJDrL9oY/zB8fD5DauYW1ADuM9Pephy0y0ZLmXwcRDk84bvrnr5YQlVhbC8Y7xI thWpy3xvGnWkioUlcdw4hTEnkc4t3LJtU1HBiBVuE9AeWGIC2wSMrrQUoe0r0dAfXYpd cfIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:organization:references:in-reply-to:message-id :date:subject:cc:to:from:ironport-sdr:ironport-sdr; bh=WFklSRL3A8urZEsN3TfcszWaaK46xpZsQZyKBHCLaGQ=; b=s7AQRWmlttDEAHKhjoYezQzfUVakvCp6ygR+H8mc8AxjxUFOzyLK15BQnv7mHJF3g2 h/CgJuu9BsmmydnkLr6X9U35UE8XU7UgAvTDNr4Yq3rZnZw4g+xebkyH0ppp2151Wm/n 33/jdxf+Kzl7TWPmr5wPBJBYSTJKUbvhitcDQfLhO0eoQXmPYFqcSZeGhf8JuExibG3v 9VxpPwYOTxbULeXsxpLaCcxymyEkpdeyQmn8BkZsoKOT8N5GoA8YaVdOP2+KSE8dcqQk ifc55KsgbXXyX9TdqBQcVIayZ/fjwBB3P9cy57kzoAj6Hz9LZys4gvFulw6yzyLMtQzE 1TCA== 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 g18si3045506edp.374.2021.04.29.06.00.24; Thu, 29 Apr 2021 06:01:05 -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; 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 S238304AbhD2M7m (ORCPT + 99 others); Thu, 29 Apr 2021 08:59:42 -0400 Received: from mga17.intel.com ([192.55.52.151]:50834 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237370AbhD2M7b (ORCPT ); Thu, 29 Apr 2021 08:59:31 -0400 IronPort-SDR: Y4WVEkubBLNA+k5Ek1y4J8HDGFmVI9aUB8b/SI2r8mYvMXeXobi4KkbBNHLbJKqNDajU9wwxAc sb0BiF3Zko4A== X-IronPort-AV: E=McAfee;i="6200,9189,9969"; a="177107441" X-IronPort-AV: E=Sophos;i="5.82,259,1613462400"; d="scan'208";a="177107441" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Apr 2021 05:58:44 -0700 IronPort-SDR: kwXc05OeD7R6lWh99Cc8uY3eHfnq2lYNmvuI9cohdrVpCCeSxKlOyhV46DT+bS4Yg6tKqlJXOf SKTyrBbNHoCA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,259,1613462400"; d="scan'208";a="537361630" Received: from ahunter-desktop.fi.intel.com ([10.237.72.174]) by orsmga004.jf.intel.com with ESMTP; 29 Apr 2021 05:58:42 -0700 From: Adrian Hunter To: Arnaldo Carvalho de Melo , Jiri Olsa , Andi Kleen Cc: linux-kernel@vger.kernel.org Subject: [PATCH 06/12] perf auxtrace: Allow buffers to be mapped read / write Date: Thu, 29 Apr 2021 15:58:48 +0300 Message-Id: <20210429125854.13905-7-adrian.hunter@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210429125854.13905-1-adrian.hunter@intel.com> References: <20210429125854.13905-1-adrian.hunter@intel.com> Organization: Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org To support in-place update, allow buffers to be mapped read / write. Signed-off-by: Adrian Hunter --- tools/perf/util/auxtrace.c | 5 +++-- tools/perf/util/auxtrace.h | 6 +++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/tools/perf/util/auxtrace.c b/tools/perf/util/auxtrace.c index 48b88e2bca1e..ade655d58780 100644 --- a/tools/perf/util/auxtrace.c +++ b/tools/perf/util/auxtrace.c @@ -1120,8 +1120,9 @@ int auxtrace_queue_data(struct perf_session *session, bool samples, bool events) auxtrace_queue_data_cb, &qd); } -void *auxtrace_buffer__get_data(struct auxtrace_buffer *buffer, int fd) +void *auxtrace_buffer__get_data_rw(struct auxtrace_buffer *buffer, int fd, bool rw) { + int prot = rw ? PROT_READ | PROT_WRITE : PROT_READ; size_t adj = buffer->data_offset & (page_size - 1); size_t size = buffer->size + adj; off_t file_offset = buffer->data_offset - adj; @@ -1130,7 +1131,7 @@ void *auxtrace_buffer__get_data(struct auxtrace_buffer *buffer, int fd) if (buffer->data) return buffer->data; - addr = mmap(NULL, size, PROT_READ, MAP_SHARED, fd, file_offset); + addr = mmap(NULL, size, prot, MAP_SHARED, fd, file_offset); if (addr == MAP_FAILED) return NULL; diff --git a/tools/perf/util/auxtrace.h b/tools/perf/util/auxtrace.h index 9ac2ac1bd793..472c0973b1f1 100644 --- a/tools/perf/util/auxtrace.h +++ b/tools/perf/util/auxtrace.h @@ -533,7 +533,11 @@ int auxtrace_queue_data(struct perf_session *session, bool samples, bool events); struct auxtrace_buffer *auxtrace_buffer__next(struct auxtrace_queue *queue, struct auxtrace_buffer *buffer); -void *auxtrace_buffer__get_data(struct auxtrace_buffer *buffer, int fd); +void *auxtrace_buffer__get_data_rw(struct auxtrace_buffer *buffer, int fd, bool rw); +static inline void *auxtrace_buffer__get_data(struct auxtrace_buffer *buffer, int fd) +{ + return auxtrace_buffer__get_data_rw(buffer, fd, false); +} void auxtrace_buffer__put_data(struct auxtrace_buffer *buffer); void auxtrace_buffer__drop_data(struct auxtrace_buffer *buffer); void auxtrace_buffer__free(struct auxtrace_buffer *buffer); -- 2.17.1