Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp582008lqo; Thu, 16 May 2024 15:22:21 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUVdWWO8DQetRiaI45Go5dCGVWdVJYC9NE8BRSzr0a/Mu0XFtaK9VNZgO1FlSkKegkdu6YTx5E+HZd1f3n0UrUF0Qmos08n8olVSQdmgQ== X-Google-Smtp-Source: AGHT+IEp6LxhITo4Aux6LtO8M9ixHMrY4Em66ahOgLQiasfpAk/pJVz1a0MZDJXIpjj+8ccgufpF X-Received: by 2002:a17:907:1b17:b0:a59:aa69:9791 with SMTP id a640c23a62f3a-a5a2d5eeb92mr1928213266b.34.1715898141196; Thu, 16 May 2024 15:22:21 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715898141; cv=pass; d=google.com; s=arc-20160816; b=WlrXxJ6K4C7ADUGjokw/G2dvAhPpR2QVOhWJyWgJjsO2wjbY3Ar4RspT0Ylx2fkpyN cXhjvkpbyzLbcD5gQouc2Z9eT2nEMrBirYGZZ13pOXoMACXEPs5YXGnPc9U8VF1VKh/v GF9uWb4KY7WW+dQNX3/Z5jdpbdE8mtdhMAaNZiFWMNSim/EPWjKzULDXaXOng1SQJRgf GNK2wL+xjvyoJRVlDKrLMSqLjfxNU3/fnZaUfW0JODth4IhOsUHVLvPu/uJVbOmqom7E +COV5+7ywAto02k6li2DcnMK+8ASwkuC/v3KQV41BeHSv3LoSfhn8gb4t/K8NtWMy2pp DTJw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=to:from:subject:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:message-id:date:dkim-signature; bh=kS1/X+BHtKjnwKrgy5/KCu8x6nUxO4PCq3/9gh0hd3E=; fh=CG4mDz9RfoS8c3oedX0sr6N6xYJzOyvymvNQr25Rsus=; b=O1Tt/YjTqyXdt5hYL7DEicSiEvgLSkq8dLZtLux+/KPeTmyC8Mv3x/ddHLNX6ZHPi7 7Lu+ht2QhQnIaayjH4wrz0xKAPTvscwEWfWQ2ZtJLbVdDjnTowop6omrea3Hz2JTCnb6 +Qw3B5pHuoNRtsv4AELKUDmcm/QKUXcC1+GXIDMUQqv2L6OTY7sN7+2N4FSBfAinV4V4 9EEu9IJBuZBJjUJ8Tqo8Kl1J2yBbF0Fhl8X4GJA1ZGBvexFvqBuz5t9WGXBgvurXxEmx Z/GCHUrqxsLYfGnP6ove2XZ5DkhZG5SiXYYjGsiVDFDqGJCYj2LQqQRUwIXvqGXHIbK+ PqjQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="D/T50K4X"; arc=pass (i=1 spf=pass spfdomain=flex--irogers.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-181606-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-181606-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a640c23a62f3a-a5ce039d311si140859666b.984.2024.05.16.15.22.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 May 2024 15:22:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-181606-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="D/T50K4X"; arc=pass (i=1 spf=pass spfdomain=flex--irogers.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-181606-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-181606-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id BB1F31F223F4 for ; Thu, 16 May 2024 22:22:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C23561586C3; Thu, 16 May 2024 22:22:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="D/T50K4X" Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 412C2157467 for ; Thu, 16 May 2024 22:22:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715898132; cv=none; b=flzfqCdBb7OpRvzE0+WAglVcOn34bmAWazf8RQl/1+/REDH2Vg8Wqw3EmuZjxNcMoE8Hz8jKQT9dxg37P/UV1+CHneR0btgeyBPt1hkxuYHRl1bNFdLNrtQR1Hr8v0VWfu7HDA+Y5BFZEnCPgPK+/9sk3KNvBSrSAHB4J0p0+U4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715898132; c=relaxed/simple; bh=xwIOMlHe1Z7kFcLRG1xSrIudTNqh7gDy2OljfsgpMm4=; h=Date:Message-Id:Mime-Version:Subject:From:To:Content-Type; b=m+VKuieOkrE4fitBkcHu/x6BPfTHRNi9j6/N8P9aBPffBHraUKI+NQ0V4vtbluRyO8/x4Q9IfizeuBrMLCfTa3vq/Mv+ZX3gDYx+TICDKAMUtr06OAWGAIqSgzRTsysdljNxUEbOXcQuxlijsncgt644JeG071yDelJNISI/7Lo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=D/T50K4X; arc=none smtp.client-ip=209.85.128.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-61be621bd84so136029137b3.1 for ; Thu, 16 May 2024 15:22:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1715898130; x=1716502930; darn=vger.kernel.org; h=to:from:subject:mime-version:message-id:date:from:to:cc:subject :date:message-id:reply-to; bh=kS1/X+BHtKjnwKrgy5/KCu8x6nUxO4PCq3/9gh0hd3E=; b=D/T50K4XwyucJec1muEoNjdc5G1xUSodYcmBBBuyKGHJBAlEPvOCg6HPB550GE62B4 68Nm0Y3cHfXmKXoGQ1CKLoiykPYcjFOt5fOqTVsvuqc7xyc1EmquXryMTrVZR7RnEorH kiZR5boKkAntdLQ2mdJorXxg5EHzLHmsILsdQGGj8puBSsnQJnn8hS2cvCP9u7AfDV8w b1JsSOp5hS2CHSeBcfZpooQ2vswAeZkrDtGrEDR14khsPWvOei4dOZIX2gQ54R2cBHfy kQ9kOr8qN14n6SN2uEr9H1j5++RI0EKccg9t2/Qw+gGZDRKoSdTozEtjNEOkNWc+Tu93 0psw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715898130; x=1716502930; h=to:from:subject:mime-version:message-id:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=kS1/X+BHtKjnwKrgy5/KCu8x6nUxO4PCq3/9gh0hd3E=; b=JI59vng3Jw6ZmY6MBPRTu39nz03Ciu0a/ogrugbNuDwxAiYS6YIoDq6AGLRxom555x 7sxLBt6hAQrOQUVBqnKXrJ5Mfx4ke74rY44SCvT0oJS8cSCLvcdUzyGf9UJr7tZI1QDD s0mISTGp/f0dsUvwhMLf5fngeNGxNefNAyCKxdBTAeh3P8yDjJLIm6+kLaACnec1dlUw bmc2WzcrQPvGuB+z8/WrZeKkiYmE0LxX3lQKUr/9TQLJdEcx1NWjrCqiHyojFouZ8Bhp XqkbAu6IBVpww+iwt4nAogNZH98f2oJd6Pc+nad7fFO7wHPwfUrjFuxgbc5lxXbIT3a+ WGpw== X-Forwarded-Encrypted: i=1; AJvYcCWisdjhKUVXYl3RSWTsi/L/myip29ArouYez9Ey2uIt6NFlyhWnte2kI9mk0lIldbierSicqXtM8aGeyWRFqznQtHpWtaWl9W4lylO7 X-Gm-Message-State: AOJu0YyDg77Nv6x5hiyIS/yAF3wR/uiZcIWcWisM3JV+pkfkJqTOPNNb hVkTaJdpcc4EB97EVUN7eaFtP0FQAL4nz6mzm8e/rrEe7zSUiwprwUthped7Rm8AdQXXKKooHyj QEQlt3g== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:9eab:1b1c:e1cb:27f7]) (user=irogers job=sendgmr) by 2002:a05:690c:360a:b0:61b:e253:31ad with SMTP id 00721157ae682-622b014b7a6mr42075857b3.8.1715898130260; Thu, 16 May 2024 15:22:10 -0700 (PDT) Date: Thu, 16 May 2024 15:21:59 -0700 Message-Id: <20240516222159.3710131-1-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.45.0.rc1.225.g2a3ae87e7f-goog Subject: [PATCH v1] perf top: Make zeroing histogram on refresh the default From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , Changbin Du , John Fastabend , Andrii Nakryiko , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Stephane Eranian Content-Type: text/plain; charset="UTF-8" Instead of decaying histograms over time change it so that they are zero-ed on each perf top refresh. Previously the option '-z', or pressing 'z' in tui mode, would enable this behavior. Decaying samples is non-intuitive as it isn't how "top" works. Make zeroing on refresh the default and rename the command line options from 'z' to 'Z' and 'zero' to 'decay'. Signed-off-by: Ian Rogers --- tools/perf/Documentation/perf-top.txt | 6 +++--- tools/perf/builtin-top.c | 23 +++++++++++++---------- tools/perf/ui/browsers/hists.c | 7 ++++--- tools/perf/util/top.h | 2 +- 4 files changed, 21 insertions(+), 17 deletions(-) diff --git a/tools/perf/Documentation/perf-top.txt b/tools/perf/Documentation/perf-top.txt index 667e5102075e..f1524cc0d409 100644 --- a/tools/perf/Documentation/perf-top.txt +++ b/tools/perf/Documentation/perf-top.txt @@ -124,9 +124,9 @@ Default is to monitor all CPUS. --verbose:: Be more verbose (show counter open errors, etc). --z:: ---zero:: - Zero history across display updates. +-Z:: +--decay:: + Decay rather than zero history across display updates. -s:: --sort:: diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index e8cbbf10d361..8f06635cb7cd 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c @@ -266,10 +266,10 @@ static void perf_top__show_details(struct perf_top *top) more = symbol__annotate_printf(&he->ms, top->sym_evsel); if (top->evlist->enabled) { - if (top->zero) - symbol__annotate_zero_histogram(symbol, top->sym_evsel->core.idx); - else + if (top->decay_samples) symbol__annotate_decay_histogram(symbol, top->sym_evsel->core.idx); + else + symbol__annotate_zero_histogram(symbol, top->sym_evsel->core.idx); } if (more != 0) printf("%d lines not displayed, maybe increase display entries [e]\n", more); @@ -292,11 +292,11 @@ static void perf_top__resort_hists(struct perf_top *t) hists__unlink(hists); if (evlist->enabled) { - if (t->zero) { - hists__delete_entries(hists); - } else { + if (t->decay_samples) { hists__decay_entries(hists, t->hide_user_symbols, t->hide_kernel_symbols); + } else { + hists__delete_entries(hists); } } @@ -460,7 +460,9 @@ static void perf_top__print_mapped_keys(struct perf_top *top) fprintf(stdout, "\t[U] hide user symbols. \t(%s)\n", top->hide_user_symbols ? "yes" : "no"); - fprintf(stdout, "\t[z] toggle sample zeroing. \t(%d)\n", top->zero ? 1 : 0); + fprintf(stdout, + "\t[z] toggle sample zeroing/decaying. \t(%s)\n", + top->decay_samples ? "decay" : "zero"); fprintf(stdout, "\t[qQ] quit.\n"); } @@ -583,7 +585,7 @@ static bool perf_top__handle_keypress(struct perf_top *top, int c) top->hide_user_symbols = !top->hide_user_symbols; break; case 'z': - top->zero = !top->zero; + top->decay_samples = !top->decay_samples; break; default: break; @@ -648,7 +650,7 @@ static void *display_thread_tui(void *arg) ret = evlist__tui_browse_hists(top->evlist, help, &hbt, top->min_percent, &top->session->header.env, !top->record_opts.overwrite); if (ret == K_RELOAD) { - top->zero = true; + top->decay_samples = false; goto repeat; } else stop_top(); @@ -1502,7 +1504,8 @@ int cmd_top(int argc, const char **argv) "child tasks do not inherit counters"), OPT_STRING(0, "sym-annotate", &top.sym_filter, "symbol name", "symbol to annotate"), - OPT_BOOLEAN('z', "zero", &top.zero, "zero history across updates"), + OPT_BOOLEAN('Z', "decay", &top.decay_samples, + "decay rather than zero history across updates"), OPT_CALLBACK('F', "freq", &top.record_opts, "freq or 'max'", "profile at this frequency", record__parse_freq), diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c index b7219df51236..bcc4720f8198 100644 --- a/tools/perf/ui/browsers/hists.c +++ b/tools/perf/ui/browsers/hists.c @@ -2305,8 +2305,8 @@ static int hists_browser__scnprintf_title(struct hist_browser *browser, char *bf " drop: %" PRIu64 "/%" PRIu64, top->drop, top->drop_total); - if (top->zero) - printed += scnprintf(bf + printed, size - printed, " [z]"); + if (top->decay_samples) + printed += scnprintf(bf + printed, size - printed, " [decay]"); perf_top__reset_sample_counters(top); } @@ -3209,9 +3209,10 @@ static int evsel__hists_browse(struct evsel *evsel, int nr_events, const char *h continue; case 'z': if (!is_report_browser(hbt)) { + /* Toggle between zeroing and decaying samples. */ struct perf_top *top = hbt->arg; - top->zero = !top->zero; + top->decay_samples = !top->decay_samples; } continue; case 'L': diff --git a/tools/perf/util/top.h b/tools/perf/util/top.h index 4c5588dbb131..b2c199925b36 100644 --- a/tools/perf/util/top.h +++ b/tools/perf/util/top.h @@ -32,7 +32,7 @@ struct perf_top { u64 guest_us_samples, guest_kernel_samples; int print_entries, count_filter, delay_secs; int max_stack; - bool hide_kernel_symbols, hide_user_symbols, zero; + bool hide_kernel_symbols, hide_user_symbols, decay_samples; #ifdef HAVE_SLANG_SUPPORT bool use_tui; #endif -- 2.45.0.rc1.225.g2a3ae87e7f-goog