Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp5461558ybp; Mon, 14 Oct 2019 23:12:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqxowowflHl5bGB1r8fc7sr34X/mkWr0pbT/Q77peO15NXEqSQHZjcvzxt9fYhaNeOrMZnS1 X-Received: by 2002:a17:906:1343:: with SMTP id x3mr32905462ejb.113.1571119968554; Mon, 14 Oct 2019 23:12:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571119968; cv=none; d=google.com; s=arc-20160816; b=h7iWPkmAc7WmNlqniI+8Y6n7KpIUEb5/Ues3S/MHBfvfM6wcQWP9s6cWyD959iMMVC rNyppP/VTJFww/jHBGYFIceiAoCxd2JpX/5G/cqNwm9NBhh1LG5RkhxHnaozmlrgaVvA NIvkesKjeortauNVCWNM/vK2/OpmDvKJWbxYLseaN3Clb83Uh5NngPDrMPx5d7FnnvO6 e9deXDOstr7tbdTTy7sV+8oYCm35vugJuW/2Odm7M4eYAqL7WRyWMl5VXnH5bx7wJY1y VDBfzIu+hat4pJoOfe/gw5eGUNYv6cismZtYz2ypKP4vtrZn5K+F5Vnrk2nlEHIvdFHH 0Akg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :robot-unsubscribe:robot-id:message-id:mime-version:references :in-reply-to:cc:subject:to:reply-to:from:date; bh=GNCJnU6bVm0dQxWZ6KC4Eg6hJ86sE+Y1RlbHtyBHx1I=; b=eOZGRdU2yEmC1MTSB19Q/oQvdAsJlzm3l5CaQyYSK6bN3I7NL902o0iJlNb1/z05mW 5UXu/rXClFxyMDf1yLacMQcAdstiH1RrxkGinaOMB1goBfookL1+yzul0ZlqNHefbbMv AazkjIulrGRdNkB4pl2934oKWvGQeMmdAhpIiZbPMBxArZjXe8j+W/XW5QLbJTUxyNRd R6YAlJl1NOrePWqRVGuNsMTE0b6oyd4+ixbCv2M9DyUfsf67VRq/VsCcODU2TmDvqWSd rLYcD/a6wyL1uDIBQF68MfeCs1zvTBpaTrD1g3wOpXJ1sr6yOtGweji2G6pBvoPJVLIC rz0Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 34si13595778edk.26.2019.10.14.23.12.24; Mon, 14 Oct 2019 23:12:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728552AbfJOFcI (ORCPT + 99 others); Tue, 15 Oct 2019 01:32:08 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:42026 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728459AbfJOFcC (ORCPT ); Tue, 15 Oct 2019 01:32:02 -0400 Received: from [5.158.153.53] (helo=tip-bot2.lab.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1iKFQy-0000Ab-KY; Tue, 15 Oct 2019 07:31:48 +0200 Received: from [127.0.1.1] (localhost [IPv6:::1]) by tip-bot2.lab.linutronix.de (Postfix) with ESMTP id 6C3CA1C04D4; Tue, 15 Oct 2019 07:31:41 +0200 (CEST) Date: Tue, 15 Oct 2019 05:31:41 -0000 From: "tip-bot2 for Jiri Olsa" Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: perf/core] libperf: Adopt perf_mmap__mmap_len() function from tools/perf Cc: Jiri Olsa , Alexander Shishkin , Michael Petlan , Namhyung Kim , Peter Zijlstra , Arnaldo Carvalho de Melo , Ingo Molnar , Borislav Petkov , linux-kernel@vger.kernel.org In-Reply-To: <20191007125344.14268-4-jolsa@kernel.org> References: <20191007125344.14268-4-jolsa@kernel.org> MIME-Version: 1.0 Message-ID: <157111750137.12254.17060612108241104664.tip-bot2@tip-bot2> X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the perf/core branch of tip: Commit-ID: bf59b3053e63783520c2810fc3f676553bc7eedd Gitweb: https://git.kernel.org/tip/bf59b3053e63783520c2810fc3f676553bc7eedd Author: Jiri Olsa AuthorDate: Mon, 07 Oct 2019 14:53:11 +02:00 Committer: Arnaldo Carvalho de Melo CommitterDate: Thu, 10 Oct 2019 09:41:38 -03:00 libperf: Adopt perf_mmap__mmap_len() function from tools/perf Move perf_mmap__mmap_len() from tools/perf wto libperf, it will be used in the following patches. And rename the existing perf's function to mmap__mmap_len(). Signed-off-by: Jiri Olsa Cc: Alexander Shishkin Cc: Michael Petlan Cc: Namhyung Kim Cc: Peter Zijlstra Link: http://lore.kernel.org/lkml/20191007125344.14268-4-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-record.c | 4 ++-- tools/perf/lib/include/internal/mmap.h | 2 ++ tools/perf/lib/mmap.c | 6 ++++++ tools/perf/util/mmap.c | 20 ++++++++++---------- tools/perf/util/mmap.h | 2 +- 5 files changed, 21 insertions(+), 13 deletions(-) diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index 2333286..f05e8b7 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -276,7 +276,7 @@ static int record__aio_pushfn(struct mmap *map, void *to, void *buf, size_t size if (record__comp_enabled(aio->rec)) { size = zstd_compress(aio->rec->session, aio->data + aio->size, - perf_mmap__mmap_len(map) - aio->size, + mmap__mmap_len(map) - aio->size, buf, size); } else { memcpy(aio->data + aio->size, buf, size); @@ -488,7 +488,7 @@ static int record__pushfn(struct mmap *map, void *to, void *bf, size_t size) struct record *rec = to; if (record__comp_enabled(rec)) { - size = zstd_compress(rec->session, map->data, perf_mmap__mmap_len(map), bf, size); + size = zstd_compress(rec->session, map->data, mmap__mmap_len(map), bf, size); bf = map->data; } diff --git a/tools/perf/lib/include/internal/mmap.h b/tools/perf/lib/include/internal/mmap.h index b26806b..e7a6726 100644 --- a/tools/perf/lib/include/internal/mmap.h +++ b/tools/perf/lib/include/internal/mmap.h @@ -34,6 +34,8 @@ struct perf_mmap_param { int mask; }; +size_t perf_mmap__mmap_len(struct perf_mmap *map); + void perf_mmap__init(struct perf_mmap *map, bool overwrite); #endif /* __LIBPERF_INTERNAL_MMAP_H */ diff --git a/tools/perf/lib/mmap.c b/tools/perf/lib/mmap.c index 3da6177..cc4284d 100644 --- a/tools/perf/lib/mmap.c +++ b/tools/perf/lib/mmap.c @@ -1,5 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 #include +#include void perf_mmap__init(struct perf_mmap *map, bool overwrite) { @@ -7,3 +8,8 @@ void perf_mmap__init(struct perf_mmap *map, bool overwrite) map->overwrite = overwrite; refcount_set(&map->refcnt, 0); } + +size_t perf_mmap__mmap_len(struct perf_mmap *map) +{ + return map->mask + 1 + page_size; +} diff --git a/tools/perf/util/mmap.c b/tools/perf/util/mmap.c index a496ced..a8e81c4 100644 --- a/tools/perf/util/mmap.c +++ b/tools/perf/util/mmap.c @@ -23,9 +23,9 @@ #include "../perf.h" #include /* page_size */ -size_t perf_mmap__mmap_len(struct mmap *map) +size_t mmap__mmap_len(struct mmap *map) { - return map->core.mask + 1 + page_size; + return perf_mmap__mmap_len(&map->core); } /* When check_messup is true, 'end' must points to a good entry */ @@ -170,7 +170,7 @@ static int perf_mmap__aio_enabled(struct mmap *map) #ifdef HAVE_LIBNUMA_SUPPORT static int perf_mmap__aio_alloc(struct mmap *map, int idx) { - map->aio.data[idx] = mmap(NULL, perf_mmap__mmap_len(map), PROT_READ|PROT_WRITE, + map->aio.data[idx] = mmap(NULL, mmap__mmap_len(map), PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, 0, 0); if (map->aio.data[idx] == MAP_FAILED) { map->aio.data[idx] = NULL; @@ -183,7 +183,7 @@ static int perf_mmap__aio_alloc(struct mmap *map, int idx) static void perf_mmap__aio_free(struct mmap *map, int idx) { if (map->aio.data[idx]) { - munmap(map->aio.data[idx], perf_mmap__mmap_len(map)); + munmap(map->aio.data[idx], mmap__mmap_len(map)); map->aio.data[idx] = NULL; } } @@ -196,7 +196,7 @@ static int perf_mmap__aio_bind(struct mmap *map, int idx, int cpu, int affinity) if (affinity != PERF_AFFINITY_SYS && cpu__max_node() > 1) { data = map->aio.data[idx]; - mmap_len = perf_mmap__mmap_len(map); + mmap_len = mmap__mmap_len(map); node_mask = 1UL << cpu__get_node(cpu); if (mbind(data, mmap_len, MPOL_BIND, &node_mask, 1, 0)) { pr_err("Failed to bind [%p-%p] AIO buffer to node %d: error %m\n", @@ -210,7 +210,7 @@ static int perf_mmap__aio_bind(struct mmap *map, int idx, int cpu, int affinity) #else /* !HAVE_LIBNUMA_SUPPORT */ static int perf_mmap__aio_alloc(struct mmap *map, int idx) { - map->aio.data[idx] = malloc(perf_mmap__mmap_len(map)); + map->aio.data[idx] = malloc(mmap__mmap_len(map)); if (map->aio.data[idx] == NULL) return -1; @@ -315,11 +315,11 @@ void perf_mmap__munmap(struct mmap *map) { perf_mmap__aio_munmap(map); if (map->data != NULL) { - munmap(map->data, perf_mmap__mmap_len(map)); + munmap(map->data, mmap__mmap_len(map)); map->data = NULL; } if (map->core.base != NULL) { - munmap(map->core.base, perf_mmap__mmap_len(map)); + munmap(map->core.base, mmap__mmap_len(map)); map->core.base = NULL; map->core.fd = -1; refcount_set(&map->core.refcnt, 0); @@ -371,7 +371,7 @@ int perf_mmap__mmap(struct mmap *map, struct mmap_params *mp, int fd, int cpu) refcount_set(&map->core.refcnt, 2); map->core.prev = 0; map->core.mask = mp->core.mask; - map->core.base = mmap(NULL, perf_mmap__mmap_len(map), mp->core.prot, + map->core.base = mmap(NULL, mmap__mmap_len(map), mp->core.prot, MAP_SHARED, fd, 0); if (map->core.base == MAP_FAILED) { pr_debug2("failed to mmap perf event ring buffer, error %d\n", @@ -389,7 +389,7 @@ int perf_mmap__mmap(struct mmap *map, struct mmap_params *mp, int fd, int cpu) map->comp_level = mp->comp_level; if (map->comp_level && !perf_mmap__aio_enabled(map)) { - map->data = mmap(NULL, perf_mmap__mmap_len(map), PROT_READ|PROT_WRITE, + map->data = mmap(NULL, mmap__mmap_len(map), PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, 0, 0); if (map->data == MAP_FAILED) { pr_debug2("failed to mmap data buffer, error %d\n", diff --git a/tools/perf/util/mmap.h b/tools/perf/util/mmap.h index 4ff75d8..2b97dc6 100644 --- a/tools/perf/util/mmap.h +++ b/tools/perf/util/mmap.h @@ -67,7 +67,7 @@ union perf_event *perf_mmap__read_event(struct mmap *map); int perf_mmap__push(struct mmap *md, void *to, int push(struct mmap *map, void *to, void *buf, size_t size)); -size_t perf_mmap__mmap_len(struct mmap *map); +size_t mmap__mmap_len(struct mmap *map); int perf_mmap__read_init(struct mmap *md); void perf_mmap__read_done(struct mmap *map);