Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp5435072ybp; Mon, 14 Oct 2019 22:41:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqxOazgElgogP3FMexA6NVxbG0GEo92gNTBnJJ4PSlhqdyoBQ7zMsoJWPeaJyy8+6YbvV1Af X-Received: by 2002:a17:906:27ca:: with SMTP id k10mr21636620ejc.21.1571118095097; Mon, 14 Oct 2019 22:41:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571118095; cv=none; d=google.com; s=arc-20160816; b=ZtVzeZ9LgtghJOdwjKJuRUfyL/AgSfNCnY/7tgSENwwx1umULsbPhhBNnZBJD0wRIr Hil5ZEgiJ2LBTAV/R1Nw01N9T5pDSYp5xH90S2SdRUbZezknAjAvDboBULph647VMiZd O2p73P6JMu6g5pFOrCaN64hP3O1bvCKVJCcQL2VAYrE0sektED+a5/7UKa4XlpRe7q41 MKscb+PACqN/SB9maiwTLw4rGgQfwF2eyLum0+t5f3eXu3WfUdmaKlfzlUl+pdRl821/ MSka324m5iHZMOEscalL9HPGZvjg7cwybIjZg1CpQ5jYtKOlbaxBSdDQXo9hZYAjjmWL dg+A== 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=Jgn8O6nLWJ2H7bc41eFS3jN63AT4o/6rOpfpHrTvdOA=; b=usEfJ8xppiRi4oJs+BKGqNhHgnVhCUyt4YJsiMxTHtGr9is6HadDT/m5ePJfkHcism 305tKwSxt1tBP96bR4jWxNgzmPrLR+ydCHMP+dTtzSSvTUu2iCYfpgoVmhgRR5cW9nno P/HHJNmmrI0C6sXPOFWEPaLFdzrEf1znUNEndpVBcaSNeZeQNWrEgNlzLYWHS3cxMlJD 9yA9xb8g+oHdFgZ+qA4YJyhZKo5DSOr0qHjXqj0Xg1tdD2t4948E/vIrB1Cx8pY3bO4n YuHU+rAQ/OPvGemM/r/q7FzrfjinH6yfaIxCACXoD5y4/X3lPN3sddvVu9PPm/h85rla 5zdQ== 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 e11si12627699ejr.383.2019.10.14.22.41.11; Mon, 14 Oct 2019 22:41:35 -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 S1728510AbfJOFcE (ORCPT + 99 others); Tue, 15 Oct 2019 01:32:04 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:41958 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728415AbfJOFb4 (ORCPT ); Tue, 15 Oct 2019 01:31:56 -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 1iKFQw-000092-Q6; Tue, 15 Oct 2019 07:31:46 +0200 Received: from [127.0.1.1] (localhost [IPv6:::1]) by tip-bot2.lab.linutronix.de (Postfix) with ESMTP id CD7071C04D1; Tue, 15 Oct 2019 07:31:40 +0200 (CEST) Date: Tue, 15 Oct 2019 05:31:40 -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__unmap() 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-7-jolsa@kernel.org> References: <20191007125344.14268-7-jolsa@kernel.org> MIME-Version: 1.0 Message-ID: <157111750072.12254.5147371764550354694.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: 59d7ea620b58fa7d107834a81528e3098f1c27b0 Gitweb: https://git.kernel.org/tip/59d7ea620b58fa7d107834a81528e3098f1c27b0 Author: Jiri Olsa AuthorDate: Mon, 07 Oct 2019 14:53:14 +02:00 Committer: Arnaldo Carvalho de Melo CommitterDate: Thu, 10 Oct 2019 10:05:57 -03:00 libperf: Adopt perf_mmap__unmap() function from tools/perf Move perf_mmap__unmap() from tools/perf to libperf, to internal header internal/mmap.h. It will be used in the following patches. And rename the existing perf's function to mmap__munmap(). 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-7-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/lib/include/internal/mmap.h | 1 + tools/perf/lib/mmap.c | 10 ++++++++++ tools/perf/util/evlist.c | 4 ++-- tools/perf/util/mmap.c | 11 +++-------- tools/perf/util/mmap.h | 2 +- 5 files changed, 17 insertions(+), 11 deletions(-) diff --git a/tools/perf/lib/include/internal/mmap.h b/tools/perf/lib/include/internal/mmap.h index 2e68974..5c2ca9a 100644 --- a/tools/perf/lib/include/internal/mmap.h +++ b/tools/perf/lib/include/internal/mmap.h @@ -39,6 +39,7 @@ size_t perf_mmap__mmap_len(struct perf_mmap *map); void perf_mmap__init(struct perf_mmap *map, bool overwrite); int perf_mmap__mmap(struct perf_mmap *map, struct perf_mmap_param *mp, int fd, int cpu); +void perf_mmap__munmap(struct perf_mmap *map); void perf_mmap__get(struct perf_mmap *map); #endif /* __LIBPERF_INTERNAL_MMAP_H */ diff --git a/tools/perf/lib/mmap.c b/tools/perf/lib/mmap.c index b765e05..6eb228d 100644 --- a/tools/perf/lib/mmap.c +++ b/tools/perf/lib/mmap.c @@ -32,6 +32,16 @@ int perf_mmap__mmap(struct perf_mmap *map, struct perf_mmap_param *mp, return 0; } +void perf_mmap__munmap(struct perf_mmap *map) +{ + if (map && map->base != NULL) { + munmap(map->base, perf_mmap__mmap_len(map)); + map->base = NULL; + map->fd = -1; + refcount_set(&map->refcnt, 0); + } +} + void perf_mmap__get(struct perf_mmap *map) { refcount_inc(&map->refcnt); diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index dc5b360..0b877d3 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c @@ -601,11 +601,11 @@ static void evlist__munmap_nofree(struct evlist *evlist) if (evlist->mmap) for (i = 0; i < evlist->core.nr_mmaps; i++) - perf_mmap__munmap(&evlist->mmap[i]); + mmap__munmap(&evlist->mmap[i]); if (evlist->overwrite_mmap) for (i = 0; i < evlist->core.nr_mmaps; i++) - perf_mmap__munmap(&evlist->overwrite_mmap[i]); + mmap__munmap(&evlist->overwrite_mmap[i]); } void evlist__munmap(struct evlist *evlist) diff --git a/tools/perf/util/mmap.c b/tools/perf/util/mmap.c index be691b5..2c73b5b 100644 --- a/tools/perf/util/mmap.c +++ b/tools/perf/util/mmap.c @@ -115,7 +115,7 @@ void perf_mmap__put(struct mmap *map) BUG_ON(map->core.base && refcount_read(&map->core.refcnt) == 0); if (refcount_dec_and_test(&map->core.refcnt)) - perf_mmap__munmap(map); + mmap__munmap(map); } void perf_mmap__consume(struct mmap *map) @@ -306,19 +306,14 @@ static void perf_mmap__aio_munmap(struct mmap *map __maybe_unused) } #endif -void perf_mmap__munmap(struct mmap *map) +void mmap__munmap(struct mmap *map) { + perf_mmap__munmap(&map->core); perf_mmap__aio_munmap(map); if (map->data != NULL) { munmap(map->data, mmap__mmap_len(map)); map->data = NULL; } - if (map->core.base != NULL) { - munmap(map->core.base, mmap__mmap_len(map)); - map->core.base = NULL; - map->core.fd = -1; - refcount_set(&map->core.refcnt, 0); - } auxtrace_mmap__munmap(&map->auxtrace_mmap); } diff --git a/tools/perf/util/mmap.h b/tools/perf/util/mmap.h index a73402e..6a18b29 100644 --- a/tools/perf/util/mmap.h +++ b/tools/perf/util/mmap.h @@ -43,7 +43,7 @@ struct mmap_params { }; int mmap__mmap(struct mmap *map, struct mmap_params *mp, int fd, int cpu); -void perf_mmap__munmap(struct mmap *map); +void mmap__munmap(struct mmap *map); void perf_mmap__put(struct mmap *map);