Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp5974223pxj; Wed, 23 Jun 2021 13:17:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyijkM0q9QR82J32T1EBjXQbLK55J5lGOBgjVsrWemEbxXexeIihKy4AvWaQEfX7BkabMZT X-Received: by 2002:a05:6402:896:: with SMTP id e22mr2058420edy.201.1624479438026; Wed, 23 Jun 2021 13:17:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624479438; cv=none; d=google.com; s=arc-20160816; b=lqOB7F9z/L38SwssKF8RJjtTN6qJwxHn4OgS6Ou6WTiXfYVDcm363tnTHYhpRLdp7c AaxQ0fzN9PzdWQVO6w/zVvXduEcqKa9WHLfE4+uw2gHGHyjTkLz+jIe9jJIkjRrBiQeZ 73mZ5k0qwilzKE6svhwqitJ7G6IcfKzd6fvYA9scYKWU7dbDSkmGCaLKGPO+ZkkP+ZTn 0yzij0MlpNDzK0qS49MPgcQHZoOxvlELOo8zyDs9F3P9mhuwpaZaNX8LVeVc8dpmMQj2 tUUMgplZtVfljlYnZiz2KQNHqBkNdWaSKsYtrHVaQ5LTSKy5ZilyUQCFiO0i+k1IkGv9 3KBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version; bh=5RY3tWwIuihPcox2Au/c1e4a7Ggnf7W7JLrTgPdHZrU=; b=Co9M1Du+jgR+tK0nvzFEgF9jlUymltOtGLRnyCVSuhYBG8zV6NC8gUJgSVAjz5R41U qUqYk+LLJoitm8WXdgxvwN+gOdMkObVUcdYnmC2FHGpEa7nlBLoIW/1RAU25SWfDO1+A xD1dzBJFDEIWZW8F8CkeouqtpetebU54XCccd4StwZEqpSaedr7UqB9xByOtujDQOGAO OKrYJqKh38mqdLvUALYmgaLFARS1Fpx9pbRc71L/2Drq72nqqk+0Qdv7L0BiHh4kMZeC WR+0Gd5w9L5bJky1XI635/waaDT68WCA2yFYOYzDB7hglYc0uec/gtvTHsuDvRuBSwm0 3Bkg== ARC-Authentication-Results: i=1; mx.google.com; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f11si582544eje.327.2021.06.23.13.16.55; Wed, 23 Jun 2021 13:17:18 -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; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229850AbhFWUSN (ORCPT + 99 others); Wed, 23 Jun 2021 16:18:13 -0400 Received: from mail-lj1-f170.google.com ([209.85.208.170]:43882 "EHLO mail-lj1-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229523AbhFWUSN (ORCPT ); Wed, 23 Jun 2021 16:18:13 -0400 Received: by mail-lj1-f170.google.com with SMTP id f13so4610412ljp.10 for ; Wed, 23 Jun 2021 13:15:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=5RY3tWwIuihPcox2Au/c1e4a7Ggnf7W7JLrTgPdHZrU=; b=oRE9jXFZbVNjXcRaFiCT+iHjuo9QLGzGGbGMb63gCjMGyedX0c/ot3zAvLA28gWYGH Hz/QbWGyUQnOzGKkc93fiFmRfq2wLShZiYQyc8gGBwxqDHmNCajTz3mgysMTxIGtupI+ lX1Hg+Q/2KkaphXVpvYGQE6WBLxDBoR6oR0Hy8gfmvK7gYyKzeXmPgJLUiuwiFFdnZdu +ItKEiOFBiyDHcBH+K8rcB8c3LJJRGEk5hvfSYgomWFH/SDA2BbmmY9qD+3RcCFMcnDs tjwUlvx5sLkE04845HpuQclZjAK9kjEyqmgdPBQgx8LBrlFdlhFs3eQEU/DjpHQuHgOD fpSA== X-Gm-Message-State: AOAM5300mweplypPF9uDaMkyTYSo5bf5crxqfi8sGiZ1lt4I7kdocqUi WzTSb2uLFOMgWbeQogguLnJ0TuurJBqtxcQyBPU= X-Received: by 2002:a2e:9984:: with SMTP id w4mr1015410lji.393.1624479353243; Wed, 23 Jun 2021 13:15:53 -0700 (PDT) MIME-Version: 1.0 References: <20210622153918.688500-1-jolsa@kernel.org> In-Reply-To: <20210622153918.688500-1-jolsa@kernel.org> From: Namhyung Kim Date: Wed, 23 Jun 2021 13:15:41 -0700 Message-ID: Subject: Re: [RFC 00/10] perf: Add build id parsing fault detection/fix To: Jiri Olsa Cc: Arnaldo Carvalho de Melo , lkml , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Michael Petlan , Ian Rogers Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 22, 2021 at 8:39 AM Jiri Olsa wrote: > > hi, > this *RFC* patchset adds support to detect faults during > mmap2's build id parsing and a way to fix such maps in > generated perf.data. > > It adds support to record build id faults count for session > and store it in perf.data and perf inject support to find > these maps and reads build ids for them in user space. > > It's probably best explained by the workflow: > > Record data with --buildid-mmap option: > > # perf record --buildid-mmap ... > ... > [ perf record: Woken up 1 times to write data ] > [ perf record: Failed to parse 4 build ids] > [ perf record: Captured and wrote 0.008 MB perf.data ] > > Check if there's any build id fault reported: > > # perf report --header-only > ... > # build id mmap stats: FAULTS 4, LOST 0, NOT FIXED > > There is, check the stats: > > # perf report --stat > > Aggregated stats: > TOTAL events: 104 > .... > BUILD_ID fails: 4 (14.3%) > > Yep, let's fix it: Depending on the failure, it might not need to be fixed. Say, one process mmapped a file A and succeeded. And then another process mmaped the same file A, but it failed to get a build-id (mmap itself was ok). And vice versa is fine too. So even if it sees failures, we didn't lose anything. > > # perf inject --buildid-mmap2 -i perf.data -o perf-fixed.data Not sure this is really needed since `perf inject -j` can add BUILD_ID records without fixing MMAP2. > > And verify: > > # perf report -i perf-fixed.data --stats > > Aggregated stats: > TOTAL events: 104 > .... > > Good, let's see how many we fixed: > > # perf report --header-only -i perf-fixed.data > ... > # build id mmap stats: FAULTS 4, LOST 0, FIXED(4) > > > I don't have a good way to test it, just by artificially > adding the faults in kernel code, but Ian and Namhyung > might have setup that could generate that.. would be great > to have a perf test for this. > > Also available in here: > git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git > perf/buildid_stats > > thoughts? > > thanks, > jirka > > > --- > Jiri Olsa (10): > perf: Track build id faults for mmap2 event > perf: Move build_id_parse to check only regular files > perf: Add new read_format bit to read build id faults > perf: Add new read_format bit to read lost events > tools: Sync perf_event.h uapi > libperf: Do not allow PERF_FORMAT_GROUP in perf_evsel__read > perf record: Add support to read build id fails > perf record: Add new HEADER_BUILD_ID_MMAP feature > perf report: Display build id fails stats > perf inject: Add --buildid-mmap2 option to fix failed build ids > > include/linux/perf_event.h | 2 ++ > include/uapi/linux/perf_event.h | 20 +++++++++++++------- > kernel/events/core.c | 49 +++++++++++++++++++++++++++++++++++++++++++------ > kernel/events/ring_buffer.c | 3 +++ > tools/include/uapi/linux/perf_event.h | 20 +++++++++++++------- > tools/lib/perf/evsel.c | 10 ++++++++++ > tools/lib/perf/include/perf/evsel.h | 11 ++++++++++- > tools/perf/Documentation/perf-inject.txt | 3 +++ > tools/perf/Documentation/perf.data-file-format.txt | 19 +++++++++++++++++++ > tools/perf/builtin-inject.c | 45 +++++++++++++++++++++++++++++++++++++++++++-- > tools/perf/builtin-record.c | 97 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > tools/perf/builtin-report.c | 35 +++++++++++++++++++++++++++++++++++ > tools/perf/util/env.h | 6 ++++++ > tools/perf/util/evsel.c | 12 ++++++++++++ > tools/perf/util/header.c | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > tools/perf/util/header.h | 1 + > tools/perf/util/map.h | 15 +++++++++++++++ > tools/perf/util/perf_event_attr_fprintf.c | 3 ++- > 18 files changed, 407 insertions(+), 24 deletions(-) >