Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp1162635ybe; Fri, 13 Sep 2019 12:02:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqw+M0yd2zqFUU+Wf5F6SEQ5Pv8ag3Yj3daBHKKNbuLOSENNHa3VTrMz7CJ/yC4aSJUd25GM X-Received: by 2002:a17:906:414:: with SMTP id d20mr41072304eja.165.1568401373009; 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=TXrl2auNc19JZ5RryexO3JYS2xBkgsRpA/Fq5DXLUWgQhA99leora7szHiD50SqJ/i 1EJpIrSFDCkNgwiNLz2BLCMbEXFzig6Nb0bVo53z7oysp+5ha8IIKYDQe9djUmWFB35b xdWvhWvgFg5yd69MKWH0BSAQn3l1tDP8/4hreozZ6ykjGphND40Y6WhBk7bf4H0hM0zg qJSaOQUb214O3ky3jUzFHGxKwoUmI0rH8ETAUh/I0Z+4wE/bVtKC2Ta8/AqSB6DKbKoR ht/6oxz11KElb+J8L8H+HtkLPBQUbsaiZDVoOnC2/mD+T+KWVFqhKHAcI/tjRmOSnG+8 adtg== 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=BEmzarlv+y7/yCp2w1tiqjbJQdNW2oZVXKTclDgxJ9E=; b=OPZ7oIEXcNLRHAi2NpMeliId8bEo3sJMfTOwYwdDFEw6EidCez6XgcqqJqsL4v61y3 UsM67sO+xj1JGYOCL24db1BrGNBwfo0xrrzdQyt/Hq+cuts8DGgGBPkIZii/4QWMcl8k hnNid1eAk2589nb3fo3N3S56r8VMLy4q//Pym2aeAsjON4GtOOL2ta5mJExaI9i0D6qz N7i8gUt4V7VOB7A3TDXndbv9yTz1VMxOwsb07SmV5BJS+yd/rY5I491wZQzuxPdO29qn YWarvP+W3Ie2wpWfIVEXJsu0ewTrc43iRGlNT51B9JczjnsiOn01keVyt6NwR5zK5Mmo vgQQ== 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 o46si18551895edc.124.2019.09.13.12.02.29; Fri, 13 Sep 2019 12:02: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 S2391136AbfIMN2E (ORCPT + 99 others); Fri, 13 Sep 2019 09:28:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54608 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391404AbfIMNZj (ORCPT ); Fri, 13 Sep 2019 09:25:39 -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 2EACC308218D; Fri, 13 Sep 2019 13:25:39 +0000 (UTC) Received: from krava.brq.redhat.com (unknown [10.43.17.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id 866A15C1D4; Fri, 13 Sep 2019 13:25:37 +0000 (UTC) From: Jiri Olsa To: Arnaldo Carvalho de Melo Cc: lkml , Ingo Molnar , Namhyung Kim , Alexander Shishkin , Peter Zijlstra , Michael Petlan Subject: [PATCH 40/73] libperf: Add struct perf_mmap_param Date: Fri, 13 Sep 2019 15:23:22 +0200 Message-Id: <20190913132355.21634-41-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.47]); Fri, 13 Sep 2019 13:25:39 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Adding libperf's version of mmap params 'struct perf_mmap_param' object with the basics: prot and mask. It's encapsulated in current struct mmap_params object. Link: http://lkml.kernel.org/n/tip-jl518fuinj826rsmve5qhrff@git.kernel.org Signed-off-by: Jiri Olsa --- tools/perf/lib/include/internal/mmap.h | 5 +++++ tools/perf/util/evlist.c | 14 +++++++++----- tools/perf/util/mmap.c | 4 ++-- tools/perf/util/mmap.h | 3 ++- 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/tools/perf/lib/include/internal/mmap.h b/tools/perf/lib/include/internal/mmap.h index e95fc51e5bd0..8e06eb840c47 100644 --- a/tools/perf/lib/include/internal/mmap.h +++ b/tools/perf/lib/include/internal/mmap.h @@ -29,6 +29,11 @@ struct perf_mmap { char event_copy[PERF_SAMPLE_MAX_SIZE] __aligned(8); }; +struct perf_mmap_param { + int prot; + int mask; +}; + void perf_mmap__init(struct perf_mmap *map, bool overwrite); #endif /* __LIBPERF_INTERNAL_MMAP_H */ diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index 0d1ae00d22f3..c0c0882dc343 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c @@ -642,7 +642,7 @@ static int evlist__mmap_per_evsel(struct evlist *evlist, int idx, int fd; int cpu; - mp->prot = PROT_READ | PROT_WRITE; + mp->core.prot = PROT_READ | PROT_WRITE; if (evsel->core.attr.write_backward) { output = _output_overwrite; maps = evlist->overwrite_mmap; @@ -655,7 +655,7 @@ static int evlist__mmap_per_evsel(struct evlist *evlist, int idx, if (evlist->bkw_mmap_state == BKW_MMAP_NOTREADY) perf_evlist__toggle_bkw_mmap(evlist, BKW_MMAP_RUNNING); } - mp->prot &= ~PROT_WRITE; + mp->core.prot &= ~PROT_WRITE; } if (evsel->core.system_wide && thread) @@ -896,8 +896,12 @@ int evlist__mmap_ex(struct evlist *evlist, unsigned int pages, * Its value is decided by evsel's write_backward. * So &mp should not be passed through const pointer. */ - struct mmap_params mp = { .nr_cblocks = nr_cblocks, .affinity = affinity, .flush = flush, - .comp_level = comp_level }; + struct mmap_params mp = { + .nr_cblocks = nr_cblocks, + .affinity = affinity, + .flush = flush, + .comp_level = comp_level + }; if (!evlist->mmap) evlist->mmap = evlist__alloc_mmap(evlist, false); @@ -909,7 +913,7 @@ int evlist__mmap_ex(struct evlist *evlist, unsigned int pages, evlist->core.mmap_len = evlist__mmap_size(pages); pr_debug("mmap size %zuB\n", evlist->core.mmap_len); - mp.mask = evlist->core.mmap_len - page_size - 1; + mp.core.mask = evlist->core.mmap_len - page_size - 1; auxtrace_mmap_params__init(&mp.auxtrace_mp, evlist->core.mmap_len, auxtrace_pages, auxtrace_overwrite); diff --git a/tools/perf/util/mmap.c b/tools/perf/util/mmap.c index 4cc3b54b2f73..2f34a93a72f4 100644 --- a/tools/perf/util/mmap.c +++ b/tools/perf/util/mmap.c @@ -369,8 +369,8 @@ 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->mask; - map->core.base = mmap(NULL, perf_mmap__mmap_len(map), mp->prot, + map->core.mask = mp->core.mask; + map->core.base = mmap(NULL, perf_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", diff --git a/tools/perf/util/mmap.h b/tools/perf/util/mmap.h index e335c341d073..965acb46df81 100644 --- a/tools/perf/util/mmap.h +++ b/tools/perf/util/mmap.h @@ -65,7 +65,8 @@ enum bkw_mmap_state { }; struct mmap_params { - int prot, mask, nr_cblocks, affinity, flush, comp_level; + struct perf_mmap_param core; + int nr_cblocks, affinity, flush, comp_level; struct auxtrace_mmap_params auxtrace_mp; }; -- 2.21.0