Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp882990ybv; Wed, 19 Feb 2020 11:12:37 -0800 (PST) X-Google-Smtp-Source: APXvYqy5DKGV61r702L190n4kvDMFdqZm4Y9dTBfwbfLxgtio2GfUwdcrWnibRoAM7FCCxPg2xvp X-Received: by 2002:aca:4a84:: with SMTP id x126mr5268434oia.99.1582139557784; Wed, 19 Feb 2020 11:12:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582139557; cv=none; d=google.com; s=arc-20160816; b=AyBMquVNeOw+/fuAE0EirGkquypzGzg1tVLlDLlKn3j3wj1cJiw1Kr7132OjwPFvKG YMwbCw7O0cjaR+EA/wap/1mI7aJ9lFkkHEqQGxtd7eal0FZnA5ym1KAESvzeS47yZFQu ReX9Z7Xar1Fyxjgd9id8/UF4h+LOiuZLvemyrkrZStVSZ2yTIXGVWHUz08xVSPWee5OE 0Pj035gtaQg5UJ5gOtuEug5AzH3tlWt64lUWrbbfME83+tyHgfu2Jf6AH9InpY3vpbYD eYsvtDab2lepnJ2Q/qigt5QMJQnVtxKA1XtjKStgl0Zz8Dc360Jz6GLk00KQbnBqlOWU vQBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=gVPeYdYoBIBLqKs4zaiMs3r41TsQq6LbmeDQaCcp2dQ=; b=YpuwTJfBfBj2pB+oiGPw6s5FO86QLHQlKa+cbb6dJWML0Ov/JWXMpstYrB+FTSWKAG 15PvaBzlKn2BgKZeUYgUuekibejnxueTY0C8OK0qHMLNcEqEBH9K1Nj2ZIyDWY89riFL 39so1C/YTu1thxV40sGiVqI/AzwHiK/8r2qbXYvBdhl4T1TXVoWtubBqwm635yRFkwJ/ Y7wVaEbVcb2oCV6x1sxINlPzE3nFuHwfTkGk5EtkreSoOuIglqj23puS2KVQi548NZFK hYCUvFKrdJDYdG0uUh9jBcX/Jehf51i9Vm3aEJKV8H29lZsz3IfqgFLGVCZHcqBK3PqI hTNw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a14si857576oid.102.2020.02.19.11.12.26; Wed, 19 Feb 2020 11:12:37 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726761AbgBSTKc (ORCPT + 99 others); Wed, 19 Feb 2020 14:10:32 -0500 Received: from mga05.intel.com ([192.55.52.43]:7642 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726634AbgBSTKc (ORCPT ); Wed, 19 Feb 2020 14:10:32 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Feb 2020 11:10:31 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,461,1574150400"; d="scan'208";a="408536204" Received: from otc-lr-04.jf.intel.com ([10.54.39.48]) by orsmga005.jf.intel.com with ESMTP; 19 Feb 2020 11:10:31 -0800 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 Subject: [PATCH 0/5] Support metric group constraint Date: Wed, 19 Feb 2020 11:08:35 -0800 Message-Id: <1582139320-75181-1-git-send-email-kan.liang@linux.intel.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Kan Liang 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': itlb_misses.walk_pending (0.00%) dtlb_load_misses.walk_pending (0.00%) dtlb_store_misses.walk_pending (0.00%) ept.walk_pending (0.00%) 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 | 97 ++++++++++++++++------ tools/perf/util/stat-display.c | 6 +- tools/perf/util/util.c | 18 ++++ tools/perf/util/util.h | 2 + 10 files changed, 116 insertions(+), 38 deletions(-) -- 2.7.4