Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp1162642ybe; Fri, 13 Sep 2019 12:02:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqxtB9ldvAZPxsgd+iQuUhIrdNSgjwjKzZ5RwnsIpgOjhA7dMPZP7wDnbeB1Oc9SqnIpzZML X-Received: by 2002:a17:906:b254:: with SMTP id ce20mr40840075ejb.129.1568401373515; Fri, 13 Sep 2019 12:02:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568401373; cv=none; d=google.com; s=arc-20160816; b=AnES553+AXHPAe0YoaTfNkIsWLVhMQZtTCK53cebLOOabLnRFiP7/csn6Ih19Zw3qD cSBNVa5ZsjzQQAhTt0k1rE96nA54OGL/uPPdlG4DCZ91MbapJbvekU36BXSF3Fv2v0gq Y7RKQcrsws8ne3WpERLzBL8gjQ/BYd8kzp3xU5SqBJJPxs9lWYw4oE6YsHICs6Xn2ecQ zYARdPufP1I2ncV91T42qYaU5juFf3K6UvlF7HDRUnd0+DChryPj9BhTy+huYknwuSoK jRJyCQ+1ZHsosmRGPEa2ftWbONka4xHiHx+SzT1QFJ07rRV6UuHnqT2JHL7KOQE1i12l 08uw== 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=l/lC31f4yWIM9XbbdSKBOXLRPiQ10EfgHKAwVSkDqck=; b=FJYeF423i4IWgzzmVX2EKDhFuuZ3H0vzyOCpKEArcc+AHcPJl8JykNy/cvrEGxBujc oMAuo+99tgh34vsh2LtSoqTzUK7fwuAKDGb7qWpqj+2CfROvr69tyXrJoo63nD8RQ6xB 83lYMoxCs3KUwGixBvI0KcNdEOiXiURN+Gq77lgoxseFtyC+8ecQcDzZNYDP7FQ4+6ZX or+7QTsaAhEHlTbll8QUccrF1ZZn3fkcvqYC25quUq9QJffaBgz+6XAcsV0356NFm/e1 eZb1KfOf84n0tJ5OP6VMJrDguvPptJGiVOnjdiRQZ/y9oAY/68pLCL9qWtOJ/xBQDvoN Uo/g== 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 g4si17189609edq.197.2019.09.13.12.02.29; Fri, 13 Sep 2019 12:02:53 -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 S2403787AbfIMN0X (ORCPT + 99 others); Fri, 13 Sep 2019 09:26:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49726 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2403778AbfIMN0V (ORCPT ); Fri, 13 Sep 2019 09:26:21 -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 40F94308A9E2; Fri, 13 Sep 2019 13:26:21 +0000 (UTC) Received: from krava.brq.redhat.com (unknown [10.43.17.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1F99D5C1D4; Fri, 13 Sep 2019 13:26:18 +0000 (UTC) From: Jiri Olsa To: Arnaldo Carvalho de Melo Cc: lkml , Ingo Molnar , Namhyung Kim , Alexander Shishkin , Peter Zijlstra , Michael Petlan Subject: [PATCH 58/73] perf tools: Add perf_evlist__mmap_cb_new function Date: Fri, 13 Sep 2019 15:23:40 +0200 Message-Id: <20190913132355.21634-59-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.41]); Fri, 13 Sep 2019 13:26:21 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Adding perf_evlist__mmap_cb_new function to return 'struct perf_mmap' object during perf_evlist__mmap_ops call. The array of 'struct mmap' is allocated via evlist__alloc_mmap, in this callback we simply returns pointer to the base object. Link: http://lkml.kernel.org/n/tip-tiyl8aymuk3fv9j033yo8d1v@git.kernel.org Signed-off-by: Jiri Olsa --- tools/perf/util/evlist.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index 850dacf7bf97..52a6af91e877 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c @@ -725,6 +725,29 @@ perf_evlist__mmap_cb_idx(struct perf_evlist *_evlist, auxtrace_mmap_params__set_idx(&mp->auxtrace_mp, evlist, idx, per_cpu); } +static struct perf_mmap* +perf_evlist__mmap_cb_new(struct perf_evlist *_evlist, bool overwrite, int idx) +{ + struct evlist *evlist = container_of(_evlist, struct evlist, core); + struct mmap *maps = evlist->mmap; + + if (overwrite) { + maps = evlist->overwrite_mmap; + + if (!maps) { + maps = evlist__alloc_mmap(evlist, true); + if (!maps) + return NULL; + + evlist->overwrite_mmap = maps; + if (evlist->bkw_mmap_state == BKW_MMAP_NOTREADY) + perf_evlist__toggle_bkw_mmap(evlist, BKW_MMAP_RUNNING); + } + } + + return &maps[idx].core; +} + static int evlist__mmap_per_cpu(struct evlist *evlist, struct mmap_params *mp) { @@ -923,6 +946,7 @@ int evlist__mmap_ex(struct evlist *evlist, unsigned int pages, }; struct perf_evlist_mmap_ops ops __maybe_unused = { .idx = perf_evlist__mmap_cb_idx, + .new = perf_evlist__mmap_cb_new, }; if (!evlist->mmap) -- 2.21.0