Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4819875pxj; Tue, 22 Jun 2021 08:41:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyAwYjO2tPsp0hiwI1S2uxM4IWefFgwEbO0rWZEtepLWrTSkyjxIbGTVkBgD24W2B1qIbJ7 X-Received: by 2002:a92:901:: with SMTP id y1mr3287692ilg.212.1624376482924; Tue, 22 Jun 2021 08:41:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624376482; cv=none; d=google.com; s=arc-20160816; b=ajlJtf3NBwCClbjvZJKBgUNUva1xym3hZc9HzYc56anB7Tq+P3agDCt1QkL+O8voAW JiIQVjaOhu5C5Yz99mqM4IXQvrOF9MSKnd71FT61hZ4/r+HIbB9v7TnGXbpGMUYl996O cmLOAxI2CamOKajfUp31xyHGAWS4GSZyKSzRsEWva6NLmfE/lXzCugxQnIHFU17N/nvz WEhpUMEu8rajGgknv6BHrbe3Z0PWea5aqlBTDLUOKFqnv2Rc3PYsGqxyvWw+pK3FfqD2 ytgnBeMvSiBmCBgdXjQCJkweY6PJLNWpZfmnm5FM2RI82Rdd5Tl53R/DVlzZ0wnuLcgG K/lQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Y/k6JHWhmjZJbOSP+z4S9aloGNHBLWUVWp/g3fFFYBc=; b=ljksNayPZcIu4J4GMVYBcZT5ku/FRBkRRM8ktYU6ES8LYYQlYV99S1Mm3V7ZXz9lzm CwLkWaKd1JIhvalTdEE/Yo8uqV1tJTjvBLCPpYM8ZBbg7+DJyzHv2Pl1FfT2pnpAFVH4 fQe+eX8J7dkn7R5pYshJ+hx3nzNxGFPHby2lXhGiyhJtiaKx6rxt1qgGf4Bh8yN8PC5J oiuyfKHKeJb7Dx3izg0LFjhW55APrv24mxPKOsdQ7cDXf8o3OR+yjcYe1Z+ecnVTYBLl jhjNomfGw6Tz2NRg/2Q4IBIWmJRsm3mMMAfFj0xYdFnLyr4lROd6FRXBqo7GBSsaldkx CdJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=YXHp0G4H; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w132si21276857jab.61.2021.06.22.08.41.10; Tue, 22 Jun 2021 08:41:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=YXHp0G4H; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232288AbhFVPmI (ORCPT + 99 others); Tue, 22 Jun 2021 11:42:08 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:29356 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232286AbhFVPl5 (ORCPT ); Tue, 22 Jun 2021 11:41:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1624376381; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Y/k6JHWhmjZJbOSP+z4S9aloGNHBLWUVWp/g3fFFYBc=; b=YXHp0G4HyblKZAcg+HAbaFhOPJG58pju+2lwpzVGSwE1UPA9qpoRbJsFkNHXMm3GNsidff upR4T6NH+bIab7NMj9bR8ff9/hrP2B7skb7AMnyHojBqQJ5PgJvdMHTVAhkVMVl7AoQoXm wg2DXtVYStVCz8O8jsmCE8gyXFOidng= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-124-xc5jVErgOgm3eHtKJ36eUw-1; Tue, 22 Jun 2021 11:39:40 -0400 X-MC-Unique: xc5jVErgOgm3eHtKJ36eUw-1 Received: by mail-wr1-f72.google.com with SMTP id b3-20020a05600018a3b029011a84f85e1cso5764535wri.10 for ; Tue, 22 Jun 2021 08:39:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Y/k6JHWhmjZJbOSP+z4S9aloGNHBLWUVWp/g3fFFYBc=; b=mTm4wT1ArJTiQy9ymB/6UG6wfnLkdfFBPZO5pOU1UikrtucRLZfK+AfVoW3AAreyvf KQBvi5a38/mgHLTi3QhByhygBzljg91Yx1jU+skJauaz/9edf2ENBZX80U61y7HccRn1 /F3FlQm+fX4hFPhuGrvWiKNmFjdYF5y1E2I2AX/oCY0eo8cHoxrWcRY+Q1SPH00FNjiD ytBSqY6vpjqAXi34xDNDVe4Vph9gU78bMwkWUD3NjcqsBUPt4nhwPVzTUl9tGsanfZDs R/jX0pU/9mCzxOT0ejg8lv09KELRxB12rgiL3KnM0JQDz4WqqB/j1OPyqi80m2vD9W4e crvQ== X-Gm-Message-State: AOAM5333ZLcXmlMueLGv2h7+/sLFsHLWjDiSClUddJ7NZrRBHp/ohb7B ItkPXAhZQ1lbVGd0W37UnSZ0I4kQXzg1leNCCtXBybrZKeviId5bp7btzPGbPd3qk2NARrekBpC e6KjtdUvSwIqkJEDV229FWCIg X-Received: by 2002:a5d:4b44:: with SMTP id w4mr5538094wrs.78.1624376378535; Tue, 22 Jun 2021 08:39:38 -0700 (PDT) X-Received: by 2002:a5d:4b44:: with SMTP id w4mr5538076wrs.78.1624376378394; Tue, 22 Jun 2021 08:39:38 -0700 (PDT) Received: from krava.redhat.com ([5.171.243.0]) by smtp.gmail.com with ESMTPSA id e3sm11647962wro.26.2021.06.22.08.39.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Jun 2021 08:39:38 -0700 (PDT) From: Jiri Olsa X-Google-Original-From: Jiri Olsa To: Arnaldo Carvalho de Melo Cc: lkml , Peter Zijlstra , Ingo Molnar , Mark Rutland , Namhyung Kim , Alexander Shishkin , Michael Petlan , Ian Rogers Subject: [PATCH 08/10] perf record: Add new HEADER_BUILD_ID_MMAP feature Date: Tue, 22 Jun 2021 17:39:16 +0200 Message-Id: <20210622153918.688500-9-jolsa@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210622153918.688500-1-jolsa@kernel.org> References: <20210622153918.688500-1-jolsa@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Adding new HEADER_BUILD_ID_MMAP feature to store faulst/lost/fixed counts for --buildid-mmap setup. We skip post processing for build_id, so we need to store session stats. The feature data has following format: struct { u32 version; u64 faults; u64 lost; u64 fixed; }; The version is set to 1. The faults has the value of faulted build id retrievals for the session. The lost has the value of faulted lost events for the session. The fixed has the value of fixed build ids by post-processing. The perf report --header-only display for when fixes is 0: # build id mmap stats: FAULTS 4, LOST 0, NOT FIXED If fixed is defined: # build id mmap stats: FAULTS 4, LOST 0, FIXED(4) Signed-off-by: Jiri Olsa --- .../Documentation/perf.data-file-format.txt | 19 +++++ tools/perf/builtin-record.c | 7 ++ tools/perf/util/env.h | 6 ++ tools/perf/util/header.c | 80 +++++++++++++++++++ tools/perf/util/header.h | 1 + 5 files changed, 113 insertions(+) diff --git a/tools/perf/Documentation/perf.data-file-format.txt b/tools/perf/Documentation/perf.data-file-format.txt index e6ff8c898ada..223fea2ba662 100644 --- a/tools/perf/Documentation/perf.data-file-format.txt +++ b/tools/perf/Documentation/perf.data-file-format.txt @@ -438,6 +438,25 @@ struct { other bits are reserved and should ignored for now HEADER_FEAT_BITS = 256, + HEADER_BUILD_ID_MMAP = 32, + + It contains stats values for session with --buildid-mmap option. + +struct { + u32 version; + u64 faults; + u64 lost; + u64 fixed; +}; + + The version is set to 1. + The faults has the value of faulted build id retrievals for the session. + The lost has the value of faulted lost events for the session. + The fixed has the value of fixed build ids by post-processing. + + other bits are reserved and should ignored for now + HEADER_FEAT_BITS = 256, + Attributes This is an array of perf_event_attrs, each attr_size bytes long, which defines diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index bf3958ce18e3..cae1a38a9e2a 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -1221,6 +1221,9 @@ static void record__init_features(struct record *rec) if (!rec->opts.use_clockid) perf_header__clear_feat(&session->header, HEADER_CLOCK_DATA); + if (!rec->buildid_mmap) + perf_header__clear_feat(&session->header, HEADER_BUILD_ID_MMAP); + perf_header__clear_feat(&session->header, HEADER_DIR_FORMAT); if (!record__comp_enabled(rec)) perf_header__clear_feat(&session->header, HEADER_COMPRESSED); @@ -1296,6 +1299,7 @@ evlist__read_session_stats(struct evlist *evlist, struct session_stats *st) static void read_session_stats(struct record *rec) { + struct perf_session *session = rec->session; struct session_stats st; if (evlist__read_session_stats(rec->evlist, &st)) @@ -1310,6 +1314,9 @@ static void read_session_stats(struct record *rec) fprintf(stderr, "[ perf record: Lost %lu chunks]\n", st.lost); } + + session->header.env.build_id_mmap.faults = st.build_id_faults; + session->header.env.build_id_mmap.lost = st.lost; } static void diff --git a/tools/perf/util/env.h b/tools/perf/util/env.h index 6824a7423a2d..8d45c774ad75 100644 --- a/tools/perf/util/env.h +++ b/tools/perf/util/env.h @@ -128,6 +128,12 @@ struct perf_env { */ bool enabled; } clock; + + struct { + u64 faults; + u64 lost; + u64 fixed; + } build_id_mmap; }; enum perf_compress_type { diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index 0158d2945bab..ac4f62170107 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c @@ -1528,6 +1528,39 @@ static int write_hybrid_cpu_pmu_caps(struct feat_fd *ff, return 0; } +static int write_build_id_mmap(struct feat_fd *ff, + struct evlist *evlist __maybe_unused) +{ + u64 data64; + u32 data32; + int ret; + + /* version */ + data32 = 1; + + ret = do_write(ff, &data32, sizeof(data32)); + if (ret < 0) + return ret; + + /* faults */ + data64 = ff->ph->env.build_id_mmap.faults; + + ret = do_write(ff, &data64, sizeof(data64)); + if (ret < 0) + return ret; + + /* lost */ + data64 = ff->ph->env.build_id_mmap.lost; + + ret = do_write(ff, &data64, sizeof(data64)); + if (ret < 0) + return ret; + + /* fixed */ + data64 = ff->ph->env.build_id_mmap.fixed; + return do_write(ff, &data64, sizeof(data64)); +} + static void print_hostname(struct feat_fd *ff, FILE *fp) { fprintf(fp, "# hostname : %s\n", ff->ph->env.hostname); @@ -2048,6 +2081,19 @@ static void print_hybrid_cpu_pmu_caps(struct feat_fd *ff, FILE *fp) } } +static void print_build_id_mmap(struct feat_fd *ff, FILE *fp) +{ + fprintf(fp, "# build id mmap stats: FAULTS %" PRIu64 ", LOST %" PRIu64 ",%s FIXED", + ff->ph->env.build_id_mmap.faults, + ff->ph->env.build_id_mmap.lost, + ff->ph->env.build_id_mmap.fixed ? "" : " NOT"); + + if (ff->ph->env.build_id_mmap.fixed) + fprintf(fp, "(%" PRIu64 ")", ff->ph->env.build_id_mmap.fixed); + + fprintf(fp, "\n"); +} + static void print_pmu_mappings(struct feat_fd *ff, FILE *fp) { const char *delimiter = "# pmu mappings: "; @@ -3265,6 +3311,39 @@ static int process_hybrid_cpu_pmu_caps(struct feat_fd *ff, return ret; } +static int process_build_id_mmap(struct feat_fd *ff, + void *data __maybe_unused) +{ + u32 data32; + u64 data64; + + /* version */ + if (do_read_u32(ff, &data32)) + return -1; + + if (data32 != 1) + return -1; + + /* faults */ + if (do_read_u64(ff, &data64)) + return -1; + + ff->ph->env.build_id_mmap.faults = data64; + + /* lost */ + if (do_read_u64(ff, &data64)) + return -1; + + ff->ph->env.build_id_mmap.lost = data64; + + /* fixed */ + if (do_read_u64(ff, &data64)) + return -1; + + ff->ph->env.build_id_mmap.fixed = data64; + return 0; +} + #define FEAT_OPR(n, func, __full_only) \ [HEADER_##n] = { \ .name = __stringify(n), \ @@ -3328,6 +3407,7 @@ const struct perf_header_feature_ops feat_ops[HEADER_LAST_FEATURE] = { FEAT_OPR(CLOCK_DATA, clock_data, false), FEAT_OPN(HYBRID_TOPOLOGY, hybrid_topology, true), FEAT_OPR(HYBRID_CPU_PMU_CAPS, hybrid_cpu_pmu_caps, false), + FEAT_OPR(BUILD_ID_MMAP, build_id_mmap, false), }; struct header_print_data { diff --git a/tools/perf/util/header.h b/tools/perf/util/header.h index ae6b1cf19a7d..a9fe37bb03cc 100644 --- a/tools/perf/util/header.h +++ b/tools/perf/util/header.h @@ -47,6 +47,7 @@ enum { HEADER_CLOCK_DATA, HEADER_HYBRID_TOPOLOGY, HEADER_HYBRID_CPU_PMU_CAPS, + HEADER_BUILD_ID_MMAP, HEADER_LAST_FEATURE, HEADER_FEAT_BITS = 256, }; -- 2.31.1