Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp341818rwb; Mon, 26 Sep 2022 13:11:09 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4yvceLHlM6oZuKCh2FqbaMvWClcgyhiZku0Au3Yd3HsdNzazz5IhlB/2oWv94CeSkyassh X-Received: by 2002:a63:1d22:0:b0:439:3e7c:8af7 with SMTP id d34-20020a631d22000000b004393e7c8af7mr21692966pgd.78.1664223069428; Mon, 26 Sep 2022 13:11:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664223069; cv=none; d=google.com; s=arc-20160816; b=OOnIvGWA5RZ3JychJNf4kKglH6TpxfSo2eh9EiLimqQR+MHRzk+3jb4Ks7ktdsaRsm efRp+Qm03GnKDyOjh4Q4QMR2ZFReGZ7OwoBM63cUh5wca5wGOimGRvFV20pT+68NGeRl mJ/f8qjkLHH5dtRO+JIcrPBuNgbUP8MsLjhU865yHvCD1w7fNGMNfOkbWotltaEH5m/X qq+xkNrA8OZnEYjZJ7mfKbcm25WXTgHKGGYVNKaKt9efEQ/1ByXVwT6+THxPgtCy6v6f TvrR9YTzpwpM95W30lHhvTWJTOauroCDFJKOt6UU43xI+3T/hwbh7yk0VttZceTrGMd/ JQBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=BQ5as2AAcfi4hyzulo0E4Wh4jL6UZJxD3nXLkPwkA0g=; b=Dqd5hZ0MAEPnZKsDD6rnpKFIJBj/o47ugnMqRwV7+rr44o8C/apHrGB7H4P7FNMMvL FsqBNRFD/ydbULIBNUcs2lcyhFeOqdjjd7ROzjpE284DT6SxLVlpmPokU0d0gLr3fZrd Ctw54o7ca5+SK33KybzmRPxjhkTcfleU0ROcT+X2dB83I/jftsh2iB78Yb/TNGTRjGCc z3NXS0OabKEekpftqP5NMZ/WSQBYmDJF2drVh3xvJ3vgbSAApvgMZ2HqDUaKIPKMHsoy kfoGLRsc6xmFbRyDQnkBCLwRy408eFY357FB0vyrUDwupcoVhVRDHhI2bI7/NafkOJy5 /sbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="SRkCt+/D"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 126-20020a630084000000b0043c5fa4c118si11109200pga.814.2022.09.26.13.10.57; Mon, 26 Sep 2022 13:11:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="SRkCt+/D"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S230123AbiIZTqV (ORCPT + 99 others); Mon, 26 Sep 2022 15:46:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42090 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230004AbiIZTp4 (ORCPT ); Mon, 26 Sep 2022 15:45:56 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 887311EC49; Mon, 26 Sep 2022 12:45:53 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 0FAFFB80DFA; Mon, 26 Sep 2022 19:45:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 78CA4C433D7; Mon, 26 Sep 2022 19:45:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1664221550; bh=MNeBI45oFNpk0bJm4bTOEibWr854TsU8hMwcCFMgC1M=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=SRkCt+/DiuV5u8aJnb4Lo/H8IqidTDwYQchwL+tSHijnMdpY4jmYpLxQCdpkQVT5l DJZCG/7KbMsNVRteV6Egr3eVanJvSJxOeFxnVzBY62MnzeS0cj7hGeiWX8vUISlmnR /6NeaswEvOy+SME52iPEyTgQPy9qUuopJYJwY9QzzWKBC1ZpSkORx63YvTlUZKi4TZ vYFvCq7KhnQD/FTdjx+g7H4HxXl4OPfVORgW2UVf8DM/GGeZA/RRQn3oCLnELOxduC lDDrhtMifJRVkjwBY6QlVSxa8lQKsMLX3mcWQzM1yiPwmJcwrOr/ktjvy3j1WVHp2D EsXLBn7JJuyFw== Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id 0CA74403B0; Mon, 26 Sep 2022 20:45:48 +0100 (IST) Date: Mon, 26 Sep 2022 20:45:48 +0100 From: Arnaldo Carvalho de Melo To: Namhyung Kim Cc: Jiri Olsa , Ingo Molnar , Peter Zijlstra , LKML , Ian Rogers , Adrian Hunter , linux-perf-users@vger.kernel.org Subject: Re: [PATCH 1/3] perf lock: Add -E/--entries option Message-ID: References: <20220924004221.841024-1-namhyung@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220924004221.841024-1-namhyung@kernel.org> X-Url: http://acmel.wordpress.com X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Fri, Sep 23, 2022 at 05:42:19PM -0700, Namhyung Kim escreveu: > Like perf top, the -E option can limit number of entries to print. > It can be useful when users want to see top N contended locks only. Thanks, applied. - Arnaldo > Signed-off-by: Namhyung Kim > --- > tools/perf/Documentation/perf-lock.txt | 10 ++++++++++ > tools/perf/builtin-lock.c | 20 +++++++++++++++----- > 2 files changed, 25 insertions(+), 5 deletions(-) > > diff --git a/tools/perf/Documentation/perf-lock.txt b/tools/perf/Documentation/perf-lock.txt > index 5f2dc634258e..b23e76200ac2 100644 > --- a/tools/perf/Documentation/perf-lock.txt > +++ b/tools/perf/Documentation/perf-lock.txt > @@ -94,6 +94,11 @@ REPORT OPTIONS > EventManager_De 1845 1 636 > futex-default-S 1609 0 0 > > +-E:: > +--entries=:: > + Display this many entries. > + > + > INFO OPTIONS > ------------ > > @@ -105,6 +110,7 @@ INFO OPTIONS > --map:: > dump map of lock instances (address:name table) > > + > CONTENTION OPTIONS > -------------- > > @@ -154,6 +160,10 @@ CONTENTION OPTIONS > --stack-skip > Number of stack depth to skip when finding a lock caller (default: 3). > > +-E:: > +--entries=:: > + Display this many entries. > + > > SEE ALSO > -------- > diff --git a/tools/perf/builtin-lock.c b/tools/perf/builtin-lock.c > index 25d75fa09b90..1c0d52384d9e 100644 > --- a/tools/perf/builtin-lock.c > +++ b/tools/perf/builtin-lock.c > @@ -58,6 +58,7 @@ static bool use_bpf; > static unsigned long bpf_map_entries = 10240; > static int max_stack_depth = CONTENTION_STACK_DEPTH; > static int stack_skip = CONTENTION_STACK_SKIP; > +static int print_nr_entries = INT_MAX / 2; > > static enum { > LOCK_AGGR_ADDR, > @@ -1266,14 +1267,14 @@ static void print_result(void) > struct lock_stat *st; > struct lock_key *key; > char cut_name[20]; > - int bad, total; > + int bad, total, printed; > > pr_info("%20s ", "Name"); > list_for_each_entry(key, &lock_keys, list) > pr_info("%*s ", key->len, key->header); > pr_info("\n\n"); > > - bad = total = 0; > + bad = total = printed = 0; > while ((st = pop_from_result())) { > total++; > if (st->broken) > @@ -1311,6 +1312,9 @@ static void print_result(void) > pr_info(" "); > } > pr_info("\n"); > + > + if (++printed >= print_nr_entries) > + break; > } > > print_bad_events(bad, total); > @@ -1476,7 +1480,7 @@ static void print_contention_result(struct lock_contention *con) > { > struct lock_stat *st; > struct lock_key *key; > - int bad, total; > + int bad, total, printed; > > list_for_each_entry(key, &lock_keys, list) > pr_info("%*s ", key->len, key->header); > @@ -1486,7 +1490,7 @@ static void print_contention_result(struct lock_contention *con) > else > pr_info(" %10s %s\n\n", "type", "caller"); > > - bad = total = 0; > + bad = total = printed = 0; > if (use_bpf) > bad = bad_hist[BROKEN_CONTENDED]; > > @@ -1507,7 +1511,7 @@ static void print_contention_result(struct lock_contention *con) > /* st->addr contains tid of thread */ > t = perf_session__findnew(session, pid); > pr_info(" %10d %s\n", pid, thread__comm_str(t)); > - continue; > + goto next; > } > > pr_info(" %10s %s\n", get_type_str(st), st->name); > @@ -1527,6 +1531,10 @@ static void print_contention_result(struct lock_contention *con) > pr_info("\t\t\t%#lx %s\n", (unsigned long)ip, buf); > } > } > + > +next: > + if (++printed >= print_nr_entries) > + break; > } > > print_bad_events(bad, total); > @@ -1878,6 +1886,7 @@ int cmd_lock(int argc, const char **argv) > "combine locks in the same class"), > OPT_BOOLEAN('t', "threads", &show_thread_stats, > "show per-thread lock stats"), > + OPT_INTEGER('E', "entries", &print_nr_entries, "display this many functions"), > OPT_PARENT(lock_options) > }; > > @@ -1905,6 +1914,7 @@ int cmd_lock(int argc, const char **argv) > OPT_INTEGER(0, "stack-skip", &stack_skip, > "Set the number of stack depth to skip when finding a lock caller, " > "Default: " __stringify(CONTENTION_STACK_SKIP)), > + OPT_INTEGER('E', "entries", &print_nr_entries, "display this many functions"), > OPT_PARENT(lock_options) > }; > > -- > 2.37.3.998.g577e59143f-goog -- - Arnaldo