From nobody Tue Apr 7 00:50:42 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 964E8ECAAD5 for ; Wed, 31 Aug 2022 21:04:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232082AbiHaVED (ORCPT ); Wed, 31 Aug 2022 17:04:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48538 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231768AbiHaVEA (ORCPT ); Wed, 31 Aug 2022 17:04:00 -0400 Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 95F9EEC4FC; Wed, 31 Aug 2022 14:03:59 -0700 (PDT) Received: by mail-pj1-x102d.google.com with SMTP id l5so11381432pjy.5; Wed, 31 Aug 2022 14:03:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date; bh=db/ALraqmP8bgCYrW21ZT7akOd/xlQBQhbt9mvTG2TE=; b=BQhyBGB+TaHIpwhlilcAY22pHxzQzJpIZjFcqP7OV589Nx94IRtS/MEePXmQhFayYa ORFwzhmDAaN3YxwSMHXUO7XU3lT8QWwEWsUrlahMHWbyMu4LtbSrzoWdYjXDL+JTIAfh phhCKp1M81dy3HURbTAONRfWMdlO9b3Uo0OB7TX03Fp/axyTAXLBHNphGkPJRihOCYAf D31nwbrOQJaG5GEdJctcmTBMa9cKE2dE5ylSOQXiiiAwFAem8Lu7u7vkg+sJmf/pGHa/ yv3uoGBVeyKqYkSQrhqBkN6a6npMWlmjTVX9n8hn08TUfkeebPFLjRTzhtvKxkRLNIsT aDhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date; bh=db/ALraqmP8bgCYrW21ZT7akOd/xlQBQhbt9mvTG2TE=; b=Jy4bvKTrb982uJk3lIqsHRMCOdeHk8z/GVstDHvi0RoO/pi4rsgBwF2miMaCGcTNiE jBUUV3zF0+c/FY+xwO90o5nEDhfg6yHQyhq6doxMBjdgo6UqGSg8K0o+RuxkaxLykvA0 fg0efILQUnzWPFkU1gBgGUYRGBnC6vQhnI4qU42rjAYoNvoJGDPNR4TTmKfHBdizsdKf pIBaFFWW3qDtP5zKOnn4G1xZDxOA3vpKJTlUjDTykBi9ojcZ53CZePZXMshKFNbop1yC Jp4D9ypcc4hZPgxO2wk/N2fSI+15kIhjcdGDh0/m4HzLfbcCG6agUXuoP7idrKBEFf7R Ea2g== X-Gm-Message-State: ACgBeo2E960AwggxYjU7+19Hg9+j78pdbTxYXtSrHnPacLF2rHTgC8CM +4BDXeDevfObn7UNtQMwwig= X-Google-Smtp-Source: AA6agR4F++o+g1sbAOGmKDHcFrWF58RzT4m3IRz/P7oihwJ8NezfGVWCMhJFuvUDWF+1fEaFFCWF7Q== X-Received: by 2002:a17:90b:3ec9:b0:1f5:7e38:1fd1 with SMTP id rm9-20020a17090b3ec900b001f57e381fd1mr5050178pjb.101.1661979838987; Wed, 31 Aug 2022 14:03:58 -0700 (PDT) Received: from youngsil.svl.corp.google.com ([2620:15c:2d4:203:4a6a:d1f4:9cf7:d0fb]) by smtp.gmail.com with ESMTPSA id e27-20020a056a0000db00b0053ae6a3c51asm528931pfj.186.2022.08.31.14.03.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Aug 2022 14:03:58 -0700 (PDT) Sender: Namhyung Kim From: Namhyung Kim To: Arnaldo Carvalho de Melo , Jiri Olsa Cc: Ingo Molnar , Peter Zijlstra , LKML , Ian Rogers , linux-perf-users@vger.kernel.org, Adrian Hunter Subject: [PATCH 1/5] perf tools: Print LOST read format in the verbose mode Date: Wed, 31 Aug 2022 14:03:48 -0700 Message-Id: <20220831210352.145753-2-namhyung@kernel.org> X-Mailer: git-send-email 2.37.2.789.g6183377224-goog In-Reply-To: <20220831210352.145753-1-namhyung@kernel.org> References: <20220831210352.145753-1-namhyung@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" So that we can see it with: $ perf record -vv pwd ... perf_event_attr: size 128 { sample_period, sample_freq } 4000 sample_type IP|TID|TIME|PERIOD read_format ID|LOST disabled 1 inherit 1 exclude_kernel 1 freq 1 enable_on_exec 1 precise_ip 3 sample_id_all 1 exclude_guest 1 Signed-off-by: Namhyung Kim --- tools/perf/util/perf_event_attr_fprintf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/util/perf_event_attr_fprintf.c b/tools/perf/util/pe= rf_event_attr_fprintf.c index 4b0db27b7199..7e5e7b30510d 100644 --- a/tools/perf/util/perf_event_attr_fprintf.c +++ b/tools/perf/util/perf_event_attr_fprintf.c @@ -64,7 +64,7 @@ static void __p_read_format(char *buf, size_t size, u64 v= alue) #define bit_name(n) { PERF_FORMAT_##n, #n } struct bit_names bits[] =3D { bit_name(TOTAL_TIME_ENABLED), bit_name(TOTAL_TIME_RUNNING), - bit_name(ID), bit_name(GROUP), + bit_name(ID), bit_name(GROUP), bit_name(LOST), { .name =3D NULL, } }; #undef bit_name --=20 2.37.2.789.g6183377224-goog From nobody Tue Apr 7 00:50:42 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E90CCECAAD4 for ; Wed, 31 Aug 2022 21:04:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232124AbiHaVEI (ORCPT ); Wed, 31 Aug 2022 17:04:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48582 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232075AbiHaVEC (ORCPT ); Wed, 31 Aug 2022 17:04:02 -0400 Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C5D4CEE4B0; Wed, 31 Aug 2022 14:04:01 -0700 (PDT) Received: by mail-pl1-x631.google.com with SMTP id v5so9043019plo.9; Wed, 31 Aug 2022 14:04:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date; bh=kvFx5eRHToWhr+zoZdy15KN5PCyIzU9FkGCgn6Qywlw=; b=qf7oCb+6U7wyK/WXVyWqIxvfPRJk2TiE5FhIE3SZABQYyTMxEmRbOFfLRJhW2mZcWG ha9i4oq2n/7dTIjos6v31kIR/SUn0Ip1yNXSkp5rueSw4+Rwga55OWOhL32sVQ9zH3n7 m+8WKr9Hq2UFAurZiCm097u98D2LEvw1AbD3NVvWT9SsBoxG/gO/qDdZ2HOE90JMSDIW U+fS78v7jT0N/Wv5+8PJQOMmN1U1WzRfGSkmJMnDyVyhM5RYEES2MPHDGZ/K55EHlwek F5/arKUAeDz0BGt0wPESQex1qE13+nTC7FGfuG/rEgYpUC5HEbethojfvrXoZEOVWqwu YEAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date; bh=kvFx5eRHToWhr+zoZdy15KN5PCyIzU9FkGCgn6Qywlw=; b=vsKrKssllShHrHnCCsEYaFnRzIJknVV/ccKXi9hqsrKT3sf8oDS+m8JQWP1oYFeMws D4itvYvsBApV20VoMdCmquYVYPS+Rbe40rqDblkG2ypBw4ArTu2lBdybR4hFr0/r7Vfg v7zz2nNtTf4NC0kLyDoohyxmrK7UctcRnkVEzITH2PKsj1rii4brIXpfC7gciAfdHmSq mPdJ4SrZPaKz5dSeHPBjKcT3B+WoOkhXaKoT2BW2rO7QUcGZQSB07jBsI4JqYxPU0vY0 Nf3uoB4Se2eh56S3jrr9F1NxPKdMuu2mDd3xkeztX5l2gqcnLG4qMPTsq2PiGXye7546 PC+A== X-Gm-Message-State: ACgBeo1QHHQLuNHhlsq8HfmJD9NeFp0KT0NVJct4He/3FswY6Av5RpRj HzOwldujuQNJAX5CLWBuYdw= X-Google-Smtp-Source: AA6agR4oX6FhX+PN2QqK5aBgnFtb+zcamRp4j012AaFeHV+nP6WS/DMyOaKCIuCLkzPtrGu8PHMd6A== X-Received: by 2002:a17:90b:3e8b:b0:1f5:2a52:9148 with SMTP id rj11-20020a17090b3e8b00b001f52a529148mr4991608pjb.175.1661979841010; Wed, 31 Aug 2022 14:04:01 -0700 (PDT) Received: from youngsil.svl.corp.google.com ([2620:15c:2d4:203:4a6a:d1f4:9cf7:d0fb]) by smtp.gmail.com with ESMTPSA id e27-20020a056a0000db00b0053ae6a3c51asm528931pfj.186.2022.08.31.14.03.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Aug 2022 14:03:59 -0700 (PDT) Sender: Namhyung Kim From: Namhyung Kim To: Arnaldo Carvalho de Melo , Jiri Olsa Cc: Ingo Molnar , Peter Zijlstra , LKML , Ian Rogers , linux-perf-users@vger.kernel.org, Adrian Hunter Subject: [PATCH 2/5] perf record: Set PERF_FORMAT_LOST by default Date: Wed, 31 Aug 2022 14:03:49 -0700 Message-Id: <20220831210352.145753-3-namhyung@kernel.org> X-Mailer: git-send-email 2.37.2.789.g6183377224-goog In-Reply-To: <20220831210352.145753-1-namhyung@kernel.org> References: <20220831210352.145753-1-namhyung@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" As we want to see the number of lost samples in the perf report, set the LOST format when it configs evsel. On old kernels, it'd fallback to disable it. Signed-off-by: Namhyung Kim --- tools/perf/util/evsel.c | 10 +++++++++- tools/perf/util/evsel.h | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index e1bc76ece117..5776bfa70f11 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -1161,6 +1161,7 @@ void evsel__config(struct evsel *evsel, struct record= _opts *opts, attr->sample_id_all =3D perf_missing_features.sample_id_all ? 0 : 1; attr->inherit =3D !opts->no_inherit; attr->write_backward =3D opts->overwrite ? 1 : 0; + attr->read_format =3D PERF_FORMAT_LOST; =20 evsel__set_sample_bit(evsel, IP); evsel__set_sample_bit(evsel, TID); @@ -1856,6 +1857,8 @@ static int __evsel__prepare_open(struct evsel *evsel,= struct perf_cpu_map *cpus, =20 static void evsel__disable_missing_features(struct evsel *evsel) { + if (perf_missing_features.read_lost) + evsel->core.attr.read_format &=3D ~PERF_FORMAT_LOST; if (perf_missing_features.weight_struct) { evsel__set_sample_bit(evsel, WEIGHT); evsel__reset_sample_bit(evsel, WEIGHT_STRUCT); @@ -1907,7 +1910,12 @@ bool evsel__detect_missing_features(struct evsel *ev= sel) * Must probe features in the order they were added to the * perf_event_attr interface. */ - if (!perf_missing_features.weight_struct && + if (!perf_missing_features.read_lost && + (evsel->core.attr.read_format & PERF_FORMAT_LOST)) { + perf_missing_features.read_lost =3D true; + pr_debug2("switching off PERF_FORMAT_LOST support\n"); + return true; + } else if (!perf_missing_features.weight_struct && (evsel->core.attr.sample_type & PERF_SAMPLE_WEIGHT_STRUCT)) { perf_missing_features.weight_struct =3D true; pr_debug2("switching off weight struct support\n"); diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h index d927713b513e..989865e16aad 100644 --- a/tools/perf/util/evsel.h +++ b/tools/perf/util/evsel.h @@ -188,6 +188,7 @@ struct perf_missing_features { bool data_page_size; bool code_page_size; bool weight_struct; + bool read_lost; }; =20 extern struct perf_missing_features perf_missing_features; --=20 2.37.2.789.g6183377224-goog From nobody Tue Apr 7 00:50:42 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 31DAEECAAD5 for ; Wed, 31 Aug 2022 21:04:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232075AbiHaVEM (ORCPT ); Wed, 31 Aug 2022 17:04:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48706 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232115AbiHaVEG (ORCPT ); Wed, 31 Aug 2022 17:04:06 -0400 Received: from mail-pg1-x52e.google.com (mail-pg1-x52e.google.com [IPv6:2607:f8b0:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 053E5F2D6D; Wed, 31 Aug 2022 14:04:04 -0700 (PDT) Received: by mail-pg1-x52e.google.com with SMTP id 78so1047546pgb.13; Wed, 31 Aug 2022 14:04:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date; bh=PljIzC2kef7tvsQZuyC5v+5hanwzmlHbh3BhWszm894=; b=UuvmYcB1J1nrG5wI+zEpzL0ViJbXSxPTcJvz7g4qvlOJSZzVHm25i2E9Pjemeun2mx VVEhAIw0rK/Hm8Rhk9+vQrLkRPgkuPK0hrvFLDpYShP50KLiGjf82xQ0eT22HclGeHve A6QWURZ/4P7gTlb5oQv4VjMw70Ooj+rd539oEYtes96jo/BcNVvRaXp8CIK9Yu1WOhPc 3jwLpRG6ttG7A9GdejfVol5HwHXajjOLya/5MgNa7qnw9pUo7B/y+DrmEc4U+jatokBZ zRQvOtCnnXRLABPrQlgFbP5eAUo17200Ke1B8q0aKasZvDVusfrUt6GfU1qYvjoGilv0 uonQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date; bh=PljIzC2kef7tvsQZuyC5v+5hanwzmlHbh3BhWszm894=; b=Tae2rSmZrDAQBiP/rs5+ZJhJqF1kC47GoyPKu31lmKr+j0q77w3QZOUoMsn5Mq8djF Wp45eDUyxMXD07lXwBUipCWhG0jEzVQFn6JNe3oCcuzcnYPDNWvepakdKvgt/mtEiPFT DNOknimgmsR9pnvgxw886+ogR7/vECrj0ZRDeepYwkZLT7RIn0dldbPzNGZNjBj+eFRz PAi89wzrmRSPXJeKFH/eIzA1sL8uxO7RKlyYt3AE2qNl/lQlNWsZbtA/MYJAWF0e+ztL 9PAJAkud8DF+DJh281ar5hD1oy1e6MUDF8r0JtXqXbaNVvA3bhPe5vwles17MKzfD0bm qJrg== X-Gm-Message-State: ACgBeo0O0GnMa9GhpsOYwm8P8yG3eEw9lJxYUwBXHYuonx34Ez5c8kN6 /KDy5a5zm099s18xhvFK1Fs= X-Google-Smtp-Source: AA6agR7sHvX1Rh3LfdsgqW5KGCobSnEu5m7T/adGfdJ3FA/cNm1anIMbtwtpuZIQMgfJEAw2PI1mGQ== X-Received: by 2002:a05:6a00:3306:b0:538:444d:87d3 with SMTP id cq6-20020a056a00330600b00538444d87d3mr15707684pfb.38.1661979844448; Wed, 31 Aug 2022 14:04:04 -0700 (PDT) Received: from youngsil.svl.corp.google.com ([2620:15c:2d4:203:4a6a:d1f4:9cf7:d0fb]) by smtp.gmail.com with ESMTPSA id e27-20020a056a0000db00b0053ae6a3c51asm528931pfj.186.2022.08.31.14.04.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Aug 2022 14:04:03 -0700 (PDT) Sender: Namhyung Kim From: Namhyung Kim To: Arnaldo Carvalho de Melo , Jiri Olsa Cc: Ingo Molnar , Peter Zijlstra , LKML , Ian Rogers , linux-perf-users@vger.kernel.org, Adrian Hunter Subject: [PATCH 3/5] perf record: Read and inject LOST_SAMPLES events Date: Wed, 31 Aug 2022 14:03:50 -0700 Message-Id: <20220831210352.145753-4-namhyung@kernel.org> X-Mailer: git-send-email 2.37.2.789.g6183377224-goog In-Reply-To: <20220831210352.145753-1-namhyung@kernel.org> References: <20220831210352.145753-1-namhyung@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" When there are lost samples, it can read the number of PERF_FORMAT_LOST and convert it to PERF_RECORD_LOST_SAMPLES and write to the data file at the en= d. Signed-off-by: Namhyung Kim --- tools/perf/builtin-record.c | 60 +++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index bce8c941d558..cb9881543a07 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -10,6 +10,7 @@ =20 #include "util/build-id.h" #include +#include #include "util/parse-events.h" #include "util/config.h" =20 @@ -1852,6 +1853,64 @@ record__switch_output(struct record *rec, bool at_ex= it) return fd; } =20 +static void __record__read_lost_samples(struct record *rec, struct evsel *= evsel, + struct perf_record_lost_samples *lost, + int size, int cpu_idx, int thread_idx) +{ + struct perf_counts_values count; + struct perf_sample_id *sid; + struct perf_sample sample =3D {}; + + if (perf_evsel__read(&evsel->core, cpu_idx, thread_idx, &count) < 0) { + pr_err("read LOST count failed\n"); + return; + } + + if (count.lost =3D=3D 0) + return; + + lost->lost =3D count.lost; + if (evsel->core.ids) { + sid =3D xyarray__entry(evsel->core.sample_id, cpu_idx, thread_idx); + sample.id =3D sid->id; + } + + perf_event__synthesize_id_sample((void *)(lost + 1), + evsel->core.attr.sample_type, &sample); + record__write(rec, NULL, lost, size); +} + +static void record__read_lost_samples(struct record *rec) +{ + struct perf_session *session =3D rec->session; + struct machine *machine =3D &session->machines.host; + struct perf_record_lost_samples *lost; + struct evsel *evsel; + int size =3D sizeof(*lost) + machine->id_hdr_size; + + lost =3D zalloc(size); + lost->header.type =3D PERF_RECORD_LOST_SAMPLES; + lost->header.size =3D size; + + evlist__for_each_entry(session->evlist, evsel) { + struct xyarray *xy =3D evsel->core.sample_id; + + if (xyarray__max_x(evsel->core.fd) !=3D xyarray__max_x(xy) || + xyarray__max_y(evsel->core.fd) !=3D xyarray__max_y(xy)) { + pr_debug("Unmatched FD vs. sample ID: skip reading LOST count\n"); + continue; + } + + for (int x =3D 0; x < xyarray__max_x(xy); x++) { + for (int y =3D 0; y < xyarray__max_y(xy); y++) { + __record__read_lost_samples(rec, evsel, lost, + size, x, y); + } + } + } + +} + static volatile int workload_exec_errno; =20 /* @@ -2710,6 +2769,7 @@ static int __cmd_record(struct record *rec, int argc,= const char **argv) if (rec->off_cpu) rec->bytes_written +=3D off_cpu_write(rec->session); =20 + record__read_lost_samples(rec); record__synthesize(rec, true); /* this will be recalculated during process_buildids() */ rec->samples =3D 0; --=20 2.37.2.789.g6183377224-goog From nobody Tue Apr 7 00:50:42 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 557D6ECAAD1 for ; Wed, 31 Aug 2022 21:04:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231600AbiHaVET (ORCPT ); Wed, 31 Aug 2022 17:04:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48758 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232114AbiHaVEJ (ORCPT ); Wed, 31 Aug 2022 17:04:09 -0400 Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 66D65F3254; Wed, 31 Aug 2022 14:04:07 -0700 (PDT) Received: by mail-pl1-x629.google.com with SMTP id jm11so15235106plb.13; Wed, 31 Aug 2022 14:04:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date; bh=grEQReBW7HRZNQTYFK9rMRzxQVvmokwjNE/r8n6HAfU=; b=HT/8j8Y9wYrNJczNbfE1CLE/nRKc+VOjIFwUKGiH9IPEYjFGpTC6IlaMbRy9PSwEAm Wnzz5AnlEnZ4ryxWZkTGrYQi5aH5bcYsu8S0a6ADTt4P/EfkdhlNaxeXk/SHz27De0uY 7zljsC4kDc5YMvWfahY6L8HBPcFF8ROo3nciysBdBbD8Z1n6dti0yTrrj+lDLrzvFaY5 5eoQvuH4RxD4jhL4LDVw7SpdN9+F1gUswN5iUrL+wEffKv6jsJMzW9y90Y4+8IB7/+h0 gKyZEaWIYcO6MM5QmOVcqAh6igjekvlTJxFvOAQ6C8v55/S+g4lxhM6jadhQPi8xYgFK u/4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date; bh=grEQReBW7HRZNQTYFK9rMRzxQVvmokwjNE/r8n6HAfU=; b=N+ShLXZQyJItruX+9LpzYxvgVtNomjMMtaKgexHPeBRKHUYSLvo/+hzmlnsoloO+ju XeXu1HHb2paGTotcDpiQu7gqaD/YItME0Zg63X0iluP4oFr5lvMEi/WPOFSs9U3HgHhn o3dX/m+Fc61naL/EInBQpDixpfjFnOtXPqbbQWPTcjWZgccQaetP4wfCLaHH+vVFOvnd EFKzJ4KHmgiv95P6iECo912SOGbSOrbTZXpa5OuW/71LNI/DKPuLwnZi9jPD8x1Y/PeK uzSJLvmLUfJRDj7aaY3zc5p9iFJXobAIX3NUPiHAFE9kVzKO8JBafBBpLGASHNsX4r6y x42w== X-Gm-Message-State: ACgBeo3BIsUASfufESPcf8YkrHf+hKQZVYsSA4NgGscbNhbJUN5gWjQ+ v5okLLN37K9bfYuaSN+vjTs= X-Google-Smtp-Source: AA6agR6didWx6FR4VPORqHLoKZWL6BCcRl0sY6J7MZQPrDEn+JIXD5lOQ6NnQQxK55w+F+ZRnvGtSg== X-Received: by 2002:a17:902:ef50:b0:170:9f15:b998 with SMTP id e16-20020a170902ef5000b001709f15b998mr27824548plx.102.1661979846713; Wed, 31 Aug 2022 14:04:06 -0700 (PDT) Received: from youngsil.svl.corp.google.com ([2620:15c:2d4:203:4a6a:d1f4:9cf7:d0fb]) by smtp.gmail.com with ESMTPSA id e27-20020a056a0000db00b0053ae6a3c51asm528931pfj.186.2022.08.31.14.04.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Aug 2022 14:04:05 -0700 (PDT) Sender: Namhyung Kim From: Namhyung Kim To: Arnaldo Carvalho de Melo , Jiri Olsa Cc: Ingo Molnar , Peter Zijlstra , LKML , Ian Rogers , linux-perf-users@vger.kernel.org, Adrian Hunter Subject: [PATCH 4/5] perf hist: Add nr_lost_samples to hist_stats Date: Wed, 31 Aug 2022 14:03:51 -0700 Message-Id: <20220831210352.145753-5-namhyung@kernel.org> X-Mailer: git-send-email 2.37.2.789.g6183377224-goog In-Reply-To: <20220831210352.145753-1-namhyung@kernel.org> References: <20220831210352.145753-1-namhyung@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" This is a preparation to display accurate lost sample counts for each evsel. Signed-off-by: Namhyung Kim --- tools/perf/util/events_stats.h | 1 + tools/perf/util/hist.c | 5 +++++ tools/perf/util/hist.h | 1 + 3 files changed, 7 insertions(+) diff --git a/tools/perf/util/events_stats.h b/tools/perf/util/events_stats.h index 040ab9d0a803..8fecc9fbaecc 100644 --- a/tools/perf/util/events_stats.h +++ b/tools/perf/util/events_stats.h @@ -47,6 +47,7 @@ struct hists_stats { u64 total_non_filtered_period; u32 nr_samples; u32 nr_non_filtered_samples; + u32 nr_lost_samples; }; =20 void events_stats__inc(struct events_stats *stats, u32 type); diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c index 698add038cec..8cab049f7119 100644 --- a/tools/perf/util/hist.c +++ b/tools/perf/util/hist.c @@ -2335,6 +2335,11 @@ void hists__inc_nr_samples(struct hists *hists, bool= filtered) hists->stats.nr_non_filtered_samples++; } =20 +void hists__inc_nr_lost_samples(struct hists *hists, u32 lost) +{ + hists->stats.nr_lost_samples +=3D lost; +} + static struct hist_entry *hists__add_dummy_entry(struct hists *hists, struct hist_entry *pair) { diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h index 508428b2c1b2..c7a7a3fa0b87 100644 --- a/tools/perf/util/hist.h +++ b/tools/perf/util/hist.h @@ -201,6 +201,7 @@ void hists__reset_stats(struct hists *hists); void hists__inc_stats(struct hists *hists, struct hist_entry *h); void hists__inc_nr_events(struct hists *hists); void hists__inc_nr_samples(struct hists *hists, bool filtered); +void hists__inc_nr_lost_samples(struct hists *hists, u32 lost); =20 size_t hists__fprintf(struct hists *hists, bool show_header, int max_rows, int max_cols, float min_pcnt, FILE *fp, --=20 2.37.2.789.g6183377224-goog From nobody Tue Apr 7 00:50:42 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D1D34ECAAD4 for ; Wed, 31 Aug 2022 21:04:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232154AbiHaVE1 (ORCPT ); Wed, 31 Aug 2022 17:04:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48794 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232176AbiHaVEO (ORCPT ); Wed, 31 Aug 2022 17:04:14 -0400 Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 64AB7F2C9D; Wed, 31 Aug 2022 14:04:10 -0700 (PDT) Received: by mail-pj1-x102d.google.com with SMTP id q3so12036349pjg.3; Wed, 31 Aug 2022 14:04:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date; bh=hAUVu7RE/ADqvMe9yAOUjVh/OtQCo3q1ijQHaDVsU6Y=; b=D6RhJ1V2uJFTfbqhN7M/toCoMcJ2HkLkImPNdiKohV8bW45oPKK9kiygAXl4oGvfYA 7PvRCxNey7Q6Gnk9IA8M0j+VoHeBDtzZ23CgjqBLfPiPi6JBDIUkVuwwKvXft3le5VG+ yA2jgsvmX3yp0zTJiuD2DkndXyuCVhgJ7cTrXm0OCxvUeYMLjEwL2kGSt6uUuFPschfI ZzdbJw8WbbIx7p0RNb4a0fz2RaOiFGtOyXfnMSMF2jhytZE7AmyI3kQv88zayt/vAhnD J2bFVdau2a6NgeUwgx31loANNycczvisyl5GDqIq4g8sGMgMlonhntRfFv5OPkpFajdu XcXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date; bh=hAUVu7RE/ADqvMe9yAOUjVh/OtQCo3q1ijQHaDVsU6Y=; b=Q4LsoOyHwmSDfUo+maowjtrjBj1P98bXARNi6cZawgIuII5tLK8iiKunW/E5wsFEP0 6o/HOQh0gnHI86xOPuqOln0mjredS3CAkcn2Q9+XOG8jzXwFuZNcC9nBGr2Vx5DV63gT AF+cdAyXqkOnsWYhxN+UPc3WZVezbEl9Iw3g66uSIBG0zK4oQG2X8bGY/KXJ0DV//xsI ifaMS6RluxpVy1Opw1a1JOzfkrrXt4W1/HDhEZTeElubYlyL2m0g6wjoJBTaCuh0WQqg RcZxRObwYKvH/El3CisbChmBjVv19V1GmYNmImCuIJcq1sGwtNCIYoCjNYPttyfb8z1I RtUQ== X-Gm-Message-State: ACgBeo3KtjMLtiwQxn83KoTQvy2WLuX7R+GiuOnuaFv6q4WTIWlUPllG S2Zu9OOVFb5SJogGSGBqaFY= X-Google-Smtp-Source: AA6agR4Lxz5AEf0C0bKsNycuDy2jJUh2paatG7b34QrHS0hpbQ2ALMBZ4uMc9h1nprPpjEAJWThKZg== X-Received: by 2002:a17:90a:5988:b0:1fd:6a33:abf with SMTP id l8-20020a17090a598800b001fd6a330abfmr5036285pji.69.1661979848817; Wed, 31 Aug 2022 14:04:08 -0700 (PDT) Received: from youngsil.svl.corp.google.com ([2620:15c:2d4:203:4a6a:d1f4:9cf7:d0fb]) by smtp.gmail.com with ESMTPSA id e27-20020a056a0000db00b0053ae6a3c51asm528931pfj.186.2022.08.31.14.04.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Aug 2022 14:04:07 -0700 (PDT) Sender: Namhyung Kim From: Namhyung Kim To: Arnaldo Carvalho de Melo , Jiri Olsa Cc: Ingo Molnar , Peter Zijlstra , LKML , Ian Rogers , linux-perf-users@vger.kernel.org, Adrian Hunter Subject: [PATCH 5/5] perf report: Show per-event LOST SAMPLES stat Date: Wed, 31 Aug 2022 14:03:52 -0700 Message-Id: <20220831210352.145753-6-namhyung@kernel.org> X-Mailer: git-send-email 2.37.2.789.g6183377224-goog In-Reply-To: <20220831210352.145753-1-namhyung@kernel.org> References: <20220831210352.145753-1-namhyung@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Display lost samples with --stat (if not zero): $ perf report --stat Aggregated stats: TOTAL events: 64 COMM events: 2 ( 3.1%) EXIT events: 1 ( 1.6%) SAMPLE events: 26 (40.6%) MMAP2 events: 4 ( 6.2%) LOST_SAMPLES events: 1 ( 1.6%) ATTR events: 2 ( 3.1%) FINISHED_ROUND events: 1 ( 1.6%) ID_INDEX events: 1 ( 1.6%) THREAD_MAP events: 1 ( 1.6%) CPU_MAP events: 1 ( 1.6%) EVENT_UPDATE events: 2 ( 3.1%) TIME_CONV events: 1 ( 1.6%) FEATURE events: 20 (31.2%) FINISHED_INIT events: 1 ( 1.6%) cycles:uH stats: SAMPLE events: 14 LOST_SAMPLES events: 1 instructions:uH stats: SAMPLE events: 12 Signed-off-by: Namhyung Kim --- tools/perf/builtin-report.c | 17 +++++++++++++++++ tools/perf/util/hist.c | 3 +++ 2 files changed, 20 insertions(+) diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index 91ed41cc7d88..8361890176c2 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c @@ -752,6 +752,22 @@ static int count_sample_event(struct perf_tool *tool _= _maybe_unused, return 0; } =20 +static int count_lost_samples_event(struct perf_tool *tool, + union perf_event *event, + struct perf_sample *sample, + struct machine *machine __maybe_unused) +{ + struct report *rep =3D container_of(tool, struct report, tool); + struct evsel *evsel; + + evsel =3D evlist__id2evsel(rep->session->evlist, sample->id); + if (evsel) { + hists__inc_nr_lost_samples(evsel__hists(evsel), + event->lost_samples.lost); + } + return 0; +} + static int process_attr(struct perf_tool *tool __maybe_unused, union perf_event *event, struct evlist **pevlist); @@ -761,6 +777,7 @@ static void stats_setup(struct report *rep) memset(&rep->tool, 0, sizeof(rep->tool)); rep->tool.attr =3D process_attr; rep->tool.sample =3D count_sample_event; + rep->tool.lost_samples =3D count_lost_samples_event; rep->tool.no_warn =3D true; } =20 diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c index 8cab049f7119..cc363ba20c73 100644 --- a/tools/perf/util/hist.c +++ b/tools/perf/util/hist.c @@ -2689,6 +2689,9 @@ size_t evlist__fprintf_nr_events(struct evlist *evlis= t, FILE *fp, ret +=3D fprintf(fp, "%s stats:\n", evsel__name(pos)); ret +=3D fprintf(fp, "%16s events: %10d\n", "SAMPLE", hists->stats.nr_samples); + if (hists->stats.nr_lost_samples) + ret +=3D fprintf(fp, "%16s events: %10d\n", + "LOST_SAMPLES", hists->stats.nr_lost_samples); } =20 return ret; --=20 2.37.2.789.g6183377224-goog