Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp4260474ybp; Mon, 7 Oct 2019 05:56:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqzGFtCCcJAxN2nhf7h9AnSmLa7xh1lvy8dZDv1US6m5kirjy0ConP9g8CiftPNr9HWefZyk X-Received: by 2002:a17:907:2126:: with SMTP id qo6mr24196754ejb.256.1570453019723; Mon, 07 Oct 2019 05:56:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570453019; cv=none; d=google.com; s=arc-20160816; b=CJyEXNeVuOK0qcBL0gwz8COLcgIPs162CwDj/01Njj26r4lseF3/PTZp5vQB62qVls 3gKO/jpbeNL3HReen6TRDN6oq1kTGb06doj7Glggb4GrEXGzlhemGegJW+rAUEPXRQBe TuqSPUJQPddFfZLUjjV1wUDohUxfMpt/1BSdhMnNUOFTG/4DxKXVy0YaiFnRZfzc+301 C+5nojCg++nBkCQU30t7ob+69VrOjQ5qH63bEuLLX0Eb6yuO50OU1Tl0ExQLBomPXb4o jlIZBz+1B5DD/123HE2b60eUOtQ4fl1pshImP/WNBTXyOPfdwwg8wEd2aFy0BC88RaRm lCbQ== 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=u9nPvZtoFYfn6m3ewPeWnAvqhpSVnDPMi/Z8NQha+7I=; b=AF3nteBZX2s0YgdSbKWJtOdPqRdPm2b9Jfu06xd59iSeDhy9gn/LSCAlmpaxPoBvjx pp6tWA+LSWhbSOUC7LSOTulROSbGBAsN9s7HhAXXY7EdsrE+uxWDiYMxBSrO+iW/3kms Ait5WTEun9p8x00ceM65aTkJPjw1HQqB2LJiQatpDYA4r5s5pXdkXkpd1USxkp4HszWy FJEwsLFfWnJwdS6JG+olvq5v1HoS5D6a4jUZURX8Kgnxf1twM9LofTFgst7m43lfOT17 4V5ruOYfPpWdD8eKPhF7z9v99232RrechuwtkCdFE4CoLN4Jt3tXfu0lETrt89NZt28Z EWFQ== 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 f57si8676277ede.78.2019.10.07.05.56.36; Mon, 07 Oct 2019 05:56:59 -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 S1728328AbfJGMyc (ORCPT + 99 others); Mon, 7 Oct 2019 08:54:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48984 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727715AbfJGMya (ORCPT ); Mon, 7 Oct 2019 08:54:30 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 61364308FBA6; Mon, 7 Oct 2019 12:54:30 +0000 (UTC) Received: from krava.brq.redhat.com (unknown [10.43.17.61]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1DC6E5D9CC; Mon, 7 Oct 2019 12:54:27 +0000 (UTC) From: Jiri Olsa To: Arnaldo Carvalho de Melo Cc: lkml , Ingo Molnar , Namhyung Kim , Alexander Shishkin , Peter Zijlstra , Michael Petlan Subject: [PATCH 19/36] perf tools: Add perf_evlist__mmap_cb_get function Date: Mon, 7 Oct 2019 14:53:27 +0200 Message-Id: <20191007125344.14268-20-jolsa@kernel.org> In-Reply-To: <20191007125344.14268-1-jolsa@kernel.org> References: <20191007125344.14268-1-jolsa@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Mon, 07 Oct 2019 12:54:30 +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_get 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 71fdc6c92920..a59303de3421 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c @@ -726,6 +726,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_get(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) { @@ -924,6 +947,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, + .get = perf_evlist__mmap_cb_get, }; if (!evlist->mmap) -- 2.21.0