linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: kan.liang@linux.intel.com
To: acme@kernel.org, jolsa@redhat.com, mingo@redhat.com,
	peterz@infradead.org, linux-kernel@vger.kernel.org
Cc: mark.rutland@arm.com, namhyung@kernel.org,
	ravi.bangoria@linux.ibm.com, yao.jin@linux.intel.com,
	ak@linux.intel.com, Kan Liang <kan.liang@linux.intel.com>
Subject: [PATCH V2 0/5] Support metric group constraint
Date: Mon, 24 Feb 2020 13:59:19 -0800	[thread overview]
Message-ID: <1582581564-184429-1-git-send-email-kan.liang@linux.intel.com> (raw)

From: Kan Liang <kan.liang@linux.intel.com>

Changes since V1:
- Remove global static flag violate_nmi_constraint, and add a new
  function metricgroup___watchdog_constraint_hint() for all
  watchdog constraint hints in patch 4.
  The rest of the patches are not changed.

Some metric groups, e.g. Page_Walks_Utilization, will never count when
NMI watchdog is enabled.

 $echo 1 > /proc/sys/kernel/nmi_watchdog
 $perf stat -M Page_Walks_Utilization

 Performance counter stats for 'system wide':

 <not counted>      itlb_misses.walk_pending       (0.00%)
 <not counted>      dtlb_load_misses.walk_pending  (0.00%)
 <not counted>      dtlb_store_misses.walk_pending (0.00%)
 <not counted>      ept.walk_pending               (0.00%)
 <not counted>      cycles                         (0.00%)

       2.343460588 seconds time elapsed

 Some events weren't counted. Try disabling the NMI watchdog:
        echo 0 > /proc/sys/kernel/nmi_watchdog
        perf stat ...
        echo 1 > /proc/sys/kernel/nmi_watchdog
 The events in group usually have to be from the same PMU. Try
 reorganizing the group.

A metric group is a weak group, which relies on group validation
code in the kernel to determine whether to be opened as a group or
a non-group. However, group validation code may return false-positives,
especially when NMI watchdog is enabled. (The metric group is allowed
as a group but will never be scheduled.)

The attempt to fix the group validation code has been rejected.
https://lore.kernel.org/lkml/20200117091341.GX2827@hirez.programming.kicks-ass.net/
Because we cannot accurately predict whether the group can be scheduled
as a group, only by checking current status.

This patch set provides another solution to mitigate the issue.
Add "MetricConstraint" in event list, which provides a hint for perf tool,
e.g. "MetricConstraint": "NO_NMI_WATCHDOG". Perf tool can change the
metric group to non-group (standalone metrics) if NMI watchdog is enabled.

After applying the patch,

 $echo 1 > /proc/sys/kernel/nmi_watchdog
 $perf stat -M Page_Walks_Utilization
  Splitting metric group Page_Walks_Utilization into standalone metrics.
  Try disabling the NMI watchdog to comply NO_NMI_WATCHDOG metric constraint:
        echo 0 > /proc/sys/kernel/nmi_watchdog
        perf stat ...
        echo 1 > /proc/sys/kernel/nmi_watchdog

 Performance counter stats for 'system wide':

        18,253,454      itlb_misses.walk_pending  #      0.0
                              Page_Walks_Utilization   (50.55%)
        78,051,525      dtlb_load_misses.walk_pending  (50.55%)
        29,213,063      dtlb_store_misses.walk_pending (50.55%)
                 0      ept.walk_pending               (50.55%)
     2,542,132,364      cycles                         (49.92%)

       1.037095993 seconds time elapsed

Kan Liang (5):
  perf jevents: Support metric constraint
  perf metricgroup: Factor out metricgroup__add_metric_weak_group()
  perf util: Factor out sysctl__nmi_watchdog_enabled()
  perf metricgroup: Support metric constraint
  perf vendor events: Add NO_NMI_WATCHDOG metric constraint

 .../arch/x86/cascadelakex/clx-metrics.json         |   3 +-
 .../pmu-events/arch/x86/skylake/skl-metrics.json   |   3 +-
 .../pmu-events/arch/x86/skylakex/skx-metrics.json  |   3 +-
 tools/perf/pmu-events/jevents.c                    |  19 ++--
 tools/perf/pmu-events/jevents.h                    |   2 +-
 tools/perf/pmu-events/pmu-events.h                 |   1 +
 tools/perf/util/metricgroup.c                      | 109 ++++++++++++++++-----
 tools/perf/util/stat-display.c                     |   6 +-
 tools/perf/util/util.c                             |  18 ++++
 tools/perf/util/util.h                             |   2 +
 10 files changed, 128 insertions(+), 38 deletions(-)

-- 
2.7.4


             reply	other threads:[~2020-02-24 22:00 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-24 21:59 kan.liang [this message]
2020-02-24 21:59 ` [PATCH V2 1/5] perf jevents: Support metric constraint kan.liang
2020-03-19 14:10   ` [tip: perf/core] " tip-bot2 for Kan Liang
2020-02-24 21:59 ` [PATCH V2 2/5] perf metricgroup: Factor out metricgroup__add_metric_weak_group() kan.liang
2020-03-10 17:45   ` Arnaldo Carvalho de Melo
2020-03-19 14:10   ` [tip: perf/core] " tip-bot2 for Kan Liang
2020-02-24 21:59 ` [PATCH V2 3/5] perf util: Factor out sysctl__nmi_watchdog_enabled() kan.liang
2020-03-19 14:10   ` [tip: perf/core] " tip-bot2 for Kan Liang
2020-02-24 21:59 ` [PATCH V2 4/5] perf metricgroup: Support metric constraint kan.liang
2020-03-19 14:10   ` [tip: perf/core] " tip-bot2 for Kan Liang
2020-02-24 21:59 ` [PATCH V2 5/5] perf vendor events: Add NO_NMI_WATCHDOG " kan.liang
2020-03-19 14:10   ` [tip: perf/core] perf vendor events intel: " tip-bot2 for Kan Liang
2020-02-26 15:35 ` [PATCH V2 0/5] Support metric group constraint Jiri Olsa
2020-03-10 18:04   ` Arnaldo Carvalho de Melo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1582581564-184429-1-git-send-email-kan.liang@linux.intel.com \
    --to=kan.liang@linux.intel.com \
    --cc=acme@kernel.org \
    --cc=ak@linux.intel.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=ravi.bangoria@linux.ibm.com \
    --cc=yao.jin@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).