Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp796505ybe; Fri, 13 Sep 2019 06:31:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqwBBsDXacdfHIo15zTqRMDV8XvB9E0ZV3P2ydsUt6PlB9AOK7rzO64D5o4f8jAAwB96M2yz X-Received: by 2002:a50:886d:: with SMTP id c42mr45303522edc.24.1568381512322; Fri, 13 Sep 2019 06:31:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568381512; cv=none; d=google.com; s=arc-20160816; b=oysrYHiDf/WjNiqRKMUYXobWIx+kIyXbj1tvKBzpm81b59rD7IHWblidCOVuNP7unt yiVNBPItj0hx/BFYG4NnlsYVO80VEPnHeeR9LKe3MkN2Ao9eOdBKUlWTLaneb1xEOIYq 9tZlKQxJLV9J1YU519dGo6pSEvntqTO2ZK6RE1vH8ruJEuJtzRnulb0fbebAihJnxwHO X7q+m/Hd5QuLJm5mGmgTIGTmIhDg0daWnPKOqaWhedHlRgXWxg5EhqioLHrYpHFtK8eX SsTyOl5PKCfUPpakX12ZUWPKwHEHDIJIK0idgGJ5aREq0FV8tZIfgks/15se68mPaMtZ Dmqw== 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:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=d8ImEDBiHo8bnWSiJh8cb/IyTsIvYYRJYTYWsOQtZk0=; b=UfG31KYVkjHctSWuanCNzOazNhe4737DP6RnEwJqXwZFiLxBVZacqEC2grD3L0I2cK MbfPl0+D21+2Vd0owpLCtoIOJRdSDv0GZ+kIczm1BwghIEWAflhZGNlXPTWexwG6CPMy +hz21oCE/clCz5bHYvy0iRYqXl5yntVU2KTnjjlzHARmDEcfZ+WS8XtAAEGXgDMDTNxd 6yyliCne+tQlCn5Cw+Lvrjyrax9pqkMXMZXhb+q4R23B2/qXQrlQNWPWpHqP/1EChwxD ffQq6zjAu9LlOuw48vWSgRVQXEIl12ha2MdIaVLquz6SLxJzu7Wiup/mT8wnWALjVYIs OdJw== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id br19si15192728ejb.43.2019.09.13.06.31.22; Fri, 13 Sep 2019 06:31:52 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391379AbfIMN2r (ORCPT + 99 others); Fri, 13 Sep 2019 09:28:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60550 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391158AbfIMNYf (ORCPT ); Fri, 13 Sep 2019 09:24:35 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0E2E63082E72; Fri, 13 Sep 2019 13:24:35 +0000 (UTC) Received: from krava.brq.redhat.com (unknown [10.43.17.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id D85D75C1D4; Fri, 13 Sep 2019 13:24:31 +0000 (UTC) From: Jiri Olsa To: Arnaldo Carvalho de Melo Cc: lkml , Ingo Molnar , Namhyung Kim , Alexander Shishkin , Peter Zijlstra , Michael Petlan Subject: [PATCH 14/73] libperf: Add refcnt to struct perf_mmap Date: Fri, 13 Sep 2019 15:22:56 +0200 Message-Id: <20190913132355.21634-15-jolsa@kernel.org> In-Reply-To: <20190913132355.21634-1-jolsa@kernel.org> References: <20190913132355.21634-1-jolsa@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Fri, 13 Sep 2019 13:24:35 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Move refcnt from tools/perf's mmap to libperf's perf_mmap struct. Link: http://lkml.kernel.org/n/tip-re5o204iamdxla8iw277b301@git.kernel.org Signed-off-by: Jiri Olsa --- tools/perf/lib/include/internal/mmap.h | 1 + tools/perf/util/evlist.c | 2 +- tools/perf/util/mmap.c | 18 +++++++++--------- tools/perf/util/mmap.h | 1 - 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/tools/perf/lib/include/internal/mmap.h b/tools/perf/lib/include/internal/mmap.h index 153348724bf3..96a8a278340c 100644 --- a/tools/perf/lib/include/internal/mmap.h +++ b/tools/perf/lib/include/internal/mmap.h @@ -17,6 +17,7 @@ struct perf_mmap { int mask; int fd; int cpu; + refcount_t refcnt; }; #endif /* __LIBPERF_INTERNAL_MMAP_H */ diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index 57b117532ade..f6e0bceec156 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c @@ -718,7 +718,7 @@ static struct mmap *evlist__alloc_mmap(struct evlist *evlist, * Each PERF_EVENT_IOC_SET_OUTPUT points to this mmap and * thus does perf_mmap__get() on it. */ - refcount_set(&map[i].refcnt, 0); + refcount_set(&map[i].core.refcnt, 0); } return map; } diff --git a/tools/perf/util/mmap.c b/tools/perf/util/mmap.c index dc8320891344..d6406d216cfe 100644 --- a/tools/perf/util/mmap.c +++ b/tools/perf/util/mmap.c @@ -89,7 +89,7 @@ union perf_event *perf_mmap__read_event(struct mmap *map) /* * Check if event was unmapped due to a POLLHUP/POLLERR. */ - if (!refcount_read(&map->refcnt)) + if (!refcount_read(&map->core.refcnt)) return NULL; /* non-overwirte doesn't pause the ringbuffer */ @@ -111,14 +111,14 @@ static bool perf_mmap__empty(struct mmap *map) void perf_mmap__get(struct mmap *map) { - refcount_inc(&map->refcnt); + refcount_inc(&map->core.refcnt); } void perf_mmap__put(struct mmap *map) { - BUG_ON(map->core.base && refcount_read(&map->refcnt) == 0); + BUG_ON(map->core.base && refcount_read(&map->core.refcnt) == 0); - if (refcount_dec_and_test(&map->refcnt)) + if (refcount_dec_and_test(&map->core.refcnt)) perf_mmap__munmap(map); } @@ -130,7 +130,7 @@ void perf_mmap__consume(struct mmap *map) perf_mmap__write_tail(map, old); } - if (refcount_read(&map->refcnt) == 1 && perf_mmap__empty(map)) + if (refcount_read(&map->core.refcnt) == 1 && perf_mmap__empty(map)) perf_mmap__put(map); } @@ -321,7 +321,7 @@ void perf_mmap__munmap(struct mmap *map) munmap(map->core.base, perf_mmap__mmap_len(map)); map->core.base = NULL; map->core.fd = -1; - refcount_set(&map->refcnt, 0); + refcount_set(&map->core.refcnt, 0); } auxtrace_mmap__munmap(&map->auxtrace_mmap); } @@ -367,7 +367,7 @@ int perf_mmap__mmap(struct mmap *map, struct mmap_params *mp, int fd, int cpu) * evlist layer can't just drop it when filtering events in * perf_evlist__filter_pollfd(). */ - refcount_set(&map->refcnt, 2); + refcount_set(&map->core.refcnt, 2); map->prev = 0; map->core.mask = mp->mask; map->core.base = mmap(NULL, perf_mmap__mmap_len(map), mp->prot, @@ -479,7 +479,7 @@ int perf_mmap__read_init(struct mmap *map) /* * Check if event was unmapped due to a POLLHUP/POLLERR. */ - if (!refcount_read(&map->refcnt)) + if (!refcount_read(&map->core.refcnt)) return -ENOENT; return __perf_mmap__read_init(map); @@ -537,7 +537,7 @@ void perf_mmap__read_done(struct mmap *map) /* * Check if event was unmapped due to a POLLHUP/POLLERR. */ - if (!refcount_read(&map->refcnt)) + if (!refcount_read(&map->core.refcnt)) return; map->prev = perf_mmap__read_head(map); diff --git a/tools/perf/util/mmap.h b/tools/perf/util/mmap.h index bab46642e639..117ba39f0f7a 100644 --- a/tools/perf/util/mmap.h +++ b/tools/perf/util/mmap.h @@ -22,7 +22,6 @@ struct aiocb; */ struct mmap { struct perf_mmap core; - refcount_t refcnt; u64 prev; u64 start; u64 end; -- 2.21.0