Received: by 2002:ac0:e34a:0:0:0:0:0 with SMTP id g10csp116088imn; Wed, 27 Jul 2022 17:08:28 -0700 (PDT) X-Google-Smtp-Source: AGRyM1ue/t/RNn7Pt8mM6Z/qyaN00ZOOwsJsrnpt/7826VHix/OHiLQ8hIBUeE6ulpSx0xeeRbfd X-Received: by 2002:a05:6a02:18b:b0:415:c9d:4e3c with SMTP id bj11-20020a056a02018b00b004150c9d4e3cmr20440046pgb.580.1658966908419; Wed, 27 Jul 2022 17:08:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658966908; cv=none; d=google.com; s=arc-20160816; b=m3fynbp7gTE+S+6dTdwBULCPaQfCJdcvQP48i8ox+++rQxaCWjQC5K2arpG1EIxEbg a2kGvVpjC3nTAxqCyQd/U0idy8wnOKdHSCh/8LGpRIbHRr2g4YYsyTCbB0DtkcBVr8du LCSgB6/wFEKri2oKK77MQLl08OaXVijJm0mipEEtLzEei9Voqsdy2xQfpUVwsk4Oh8vH ckKwLfMnWAt0KAhIq8bfnXndgcH+PauDzwtZMDKHbgyAR3fJIGz63ksx7+9UFTlfGS82 9ynVEOTabxCK0YR7sFvkKIB2iP3zWhmGenb/D/fCIXSoLXXh3DMXYQXl+ezP5Tk83zUw IPpQ== 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=X+oQUWY05StzsJvhE+BaApcn8j4FoC6AtwezEzT7oX0=; b=MymH3zjOPeCAl9RgRQ2ESE//xMEMwXKJHHUDVa8EZ/4CtkhBZhmSFIDG0Dwe6MG0dC 7iS/y5Ca/2yi6hotxeMPSnGNUZE+I3wGC3yqf34uv/JIMi98DMjhov4Ste7Ii8PM4Wu+ fFZvh7SqTK0IGspy8hJ8EI6sV449bK1qiu7rn3VA9aBIIfAjcfekBqBEeC5bk5Yz4h/m EG94A7S9snqKD8r8kSve2QEUAgvXy2odtu9A5RjKiJ0rXF7iEjDyPZiuYaXILf9YzoNi UivMeYXV+43LLDEJMDxZf5HEpF8Eg94DJubh8kLbGN5ivPKgGvUVAqK+J/EQ21PdMNHo GXRw== ARC-Authentication-Results: i=1; mx.google.com; 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 o24-20020a17090a421800b001f21fed39basi3370271pjg.119.2022.07.27.17.08.11; Wed, 27 Jul 2022 17:08:28 -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; 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 S234293AbiG1AAx (ORCPT + 99 others); Wed, 27 Jul 2022 20:00:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46682 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234253AbiG1AAv (ORCPT ); Wed, 27 Jul 2022 20:00:51 -0400 Received: from mail-oa1-f54.google.com (mail-oa1-f54.google.com [209.85.160.54]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DF773BE06; Wed, 27 Jul 2022 17:00:47 -0700 (PDT) Received: by mail-oa1-f54.google.com with SMTP id 586e51a60fabf-10e49d9a59bso480174fac.5; Wed, 27 Jul 2022 17:00:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=X+oQUWY05StzsJvhE+BaApcn8j4FoC6AtwezEzT7oX0=; b=rWkjMr9Sa7TN0ybcv5H4lp5PBUrfb6s5tWC00sWKLmwpx3yir/8gMKAYZDlb0KcyTE gwslKIeMPb2/cWg+nndgYQq76qlPIRXD4kNUcMLejUJ0YiTFerPk/UCgHQy6mu0xpqwz p/fhMEHc+aAanMMboaKHngt0pH1UvFueq/wkCRWwoy5b8AMbP54mTck4Xa5a6LBlvn5m R2EgDtPzswp3ReZnU1qUq0/AQ7xl7aI6XzOWz3xor2vaK+FscII4hPiuy54BuBhAOhPl aL0IAtyfhMFZ53WpH8ox9zoyhDvannOiV7aJ1Bm81/FgK15zgwF4cV317wIbi3+0ptLJ R/Bw== X-Gm-Message-State: AJIora+3lPSIeM/dagvQV/lTPheigsHvO5GAYFXa9kn1TMC8+etl38a1 00RGB0kfW98eZwj7p8u92ydU38wAlyZvl3B/Jls= X-Received: by 2002:a05:6870:a182:b0:10b:efbe:e65d with SMTP id a2-20020a056870a18200b0010befbee65dmr3466726oaf.5.1658966447128; Wed, 27 Jul 2022 17:00:47 -0700 (PDT) MIME-Version: 1.0 References: <20220709015033.38326-1-yangjihong1@huawei.com> <20220709015033.38326-7-yangjihong1@huawei.com> In-Reply-To: <20220709015033.38326-7-yangjihong1@huawei.com> From: Namhyung Kim Date: Wed, 27 Jul 2022 17:00:36 -0700 Message-ID: Subject: Re: [RFC v3 06/17] perf kwork: Implement perf kwork report To: Yang Jihong Cc: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Paul Clarke , linux-kernel , linux-perf-users Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS autolearn=no 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 On Fri, Jul 8, 2022 at 6:53 PM Yang Jihong wrote: > > Implements framework of perf kwork report, which is used to report time > properties such as run time and frequency: > > Test cases: > > # perf kwork > > Usage: perf kwork [] {record|report} > > -D, --dump-raw-trace dump raw trace in ASCII > -f, --force don't complain, do it > -k, --kwork list of kwork to profile (irq, softirq, workqueue, etc) > -v, --verbose be more verbose (show symbol address, etc) > > # perf kwork report -h > > Usage: perf kwork report [] > > -C, --cpu list of cpus to profile > -i, --input input file name > -n, --name event name to profile > -s, --sort > sort by key(s): runtime, max, count > -S, --with-summary Show summary with statistics > --time Time span for analysis (start,stop) > > # perf kwork report > > Kwork Name | Cpu | Total Runtime | Count | Max runtime | Max runtime start | Max runtime end | > -------------------------------------------------------------------------------------------------------------------------------- > -------------------------------------------------------------------------------------------------------------------------------- > > # perf kwork report -S > > Kwork Name | Cpu | Total Runtime | Count | Max runtime | Max runtime start | Max runtime end | > -------------------------------------------------------------------------------------------------------------------------------- > -------------------------------------------------------------------------------------------------------------------------------- > Total count : 0 > Total runtime (msec) : 0.000 (0.000% load average) > Total time span (msec) : 0.000 > -------------------------------------------------------------------------------------------------------------------------------- > > # perf kwork report -C 0,100 > Requested CPU 100 too large. Consider raising MAX_NR_CPUS > Invalid cpu bitmap > > # perf kwork report -s runtime1 > Error: Unknown --sort key: `runtime1' > > Usage: perf kwork report [] > > -C, --cpu list of cpus to profile > -i, --input input file name > -n, --name event name to profile > -s, --sort > sort by key(s): runtime, max, count > -S, --with-summary Show summary with statistics > --time Time span for analysis (start,stop) > > # perf kwork report -i perf_no_exist.data > failed to open perf_no_exist.data: No such file or directory > > # perf kwork report --time 00FFF, > Invalid time span > > Since there are no report supported events, the output is empty. > > Briefly describe the data structure: > 1. "class" indicates event type. For example, irq and softiq correspond > to different types. > 2. "cluster" refers to a specific event corresponding to a type. For > example, RCU and TIMER in softirq correspond to different clusters, > which contains three types of events: raise, entry, and exit. Maybe I'm too late... but it's now "work", right? > 3. "atom" includes time of each sample and sample of the previous phase. > (For example, exit corresponds to entry, which is used for timehist.) > > Signed-off-by: Yang Jihong > --- > tools/perf/Documentation/perf-kwork.txt | 33 + > tools/perf/builtin-kwork.c | 859 +++++++++++++++++++++++- > tools/perf/util/kwork.h | 161 +++++ > 3 files changed, 1051 insertions(+), 2 deletions(-) > > diff --git a/tools/perf/Documentation/perf-kwork.txt b/tools/perf/Documentation/perf-kwork.txt > index c5b52f61da99..b79b2c0d047e 100644 > --- a/tools/perf/Documentation/perf-kwork.txt > +++ b/tools/perf/Documentation/perf-kwork.txt > @@ -17,8 +17,11 @@ There are several variants of 'perf kwork': > 'perf kwork record ' to record the kernel work > of an arbitrary workload. > > + 'perf kwork report' to report the per kwork runtime. > + > Example usage: > perf kwork record -- sleep 1 > + perf kwork report > > OPTIONS > ------- > @@ -38,6 +41,36 @@ OPTIONS > --verbose:: > Be more verbose. (show symbol address, etc) > > +OPTIONS for 'perf kwork report' > +---------------------------- > + > +-C:: > +--cpu:: > + Only show events for the given CPU(s) (comma separated list). > + > +-i:: > +--input:: > + Input file name. (default: perf.data unless stdin is a fifo) > + > +-n:: > +--name:: > + Only show events for the given name. > + > +-s:: > +--sort:: > + Sort by key(s): runtime, max, count > + > +-S:: > +--with-summary:: > + Show summary with statistics > + > +--time:: > + Only analyze samples within given time window: ,. Times > + have the format seconds.microseconds. If start is not given (i.e., time > + string is ',x.y') then analysis starts at the beginning of the file. If > + stop time is not given (i.e, time string is 'x.y,') then analysis goes > + to end of file. > + > SEE ALSO > -------- > linkperf:perf-record[1] > diff --git a/tools/perf/builtin-kwork.c b/tools/perf/builtin-kwork.c > index 8086236b7513..9c488d647995 100644 > --- a/tools/perf/builtin-kwork.c > +++ b/tools/perf/builtin-kwork.c > @@ -25,6 +25,460 @@ > #include > #include > > +/* > + * report header elements width > + */ > +#define PRINT_CPU_WIDTH 4 > +#define PRINT_COUNT_WIDTH 9 > +#define PRINT_RUNTIME_WIDTH 10 > +#define PRINT_TIMESTAMP_WIDTH 17 > +#define PRINT_KWORK_NAME_WIDTH 30 > +#define RPINT_DECIMAL_WIDTH 3 > +#define PRINT_TIME_UNIT_SEC_WIDTH 2 > +#define PRINT_TIME_UNIT_MESC_WIDTH 3 MSEC ? Thanks, Namhyung > +#define PRINT_RUNTIME_HEADER_WIDTH (PRINT_RUNTIME_WIDTH + PRINT_TIME_UNIT_MESC_WIDTH) > +#define PRINT_TIMESTAMP_HEADER_WIDTH (PRINT_TIMESTAMP_WIDTH + PRINT_TIME_UNIT_SEC_WIDTH) > +