Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1896920ybv; Fri, 21 Feb 2020 05:19:33 -0800 (PST) X-Google-Smtp-Source: APXvYqxive3wGrNeyDSZ5bIh9+2CqMhTZFwMwSOfLSEg8n6z8aazFuhELkZ/byIW6TGkciqItgd9 X-Received: by 2002:aca:2114:: with SMTP id 20mr1984100oiz.9.1582291172937; Fri, 21 Feb 2020 05:19:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582291172; cv=none; d=google.com; s=arc-20160816; b=efIRxdsqi1UeATHGCWOD9F2FIgF/vBbavLwLk+n+6FFSZ9+N6IKdlPb8IcTCgVEMgV KzOqluecS6qK884DemVYVlNw7IAaP5U+My+5fYJgMk1pu2QFbyNkCgQ6qXZcYztS7QsF evb8lh6JcRdbVW6FUf9Oxq9gwYFbEngTyeu4nXx+6FLyuebwFqYkJNwztoXdZ/637tyH bEtP09DGP6YXZ/mnmEuJO3YTTZquj/r0x5DnyNfrxyf82LAYtXnXbqC0H4rIzFR/X/4x YUCB8lBFPRvIWEl87eORop6Mao6Al/I2w62UiZCru9J6Niv5+dB7Gjr7Ud9vxPRovt+e t+oA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=a0FcCqHS+SsZ9EJ1weUha6tWG4MB8XxMgHUD9opc+PY=; b=iE5a19xBDoU1kgMwWhzDNvlzTaW1eRFDr6yUhTDjOSv6iTkTAqhk4jFktrsagL3+5D sORQwqFCNGaraHQS8ANCF1qhre+i8qOnG/goGorB+l9Z2a2gChRYFhT2Q0oW3hJdX07H mdJe0zV1jYvXnHqP0a90pbmPx8j09VKsMVJB5E9W0JKJSJWMppR/bb4aOG7hg8Hv87D6 ffDw20vKExRABe5PJQEYiMIbWgMGksEnuk0CzMt2mVqFwFt397uImnuqKDX9+oHyEKNx Xo6NvYbnD2q0sJ4pba3QLavgxM4Y4brKTO8y2d5jzHlVq0r0hDiAxbwbLQLv7tx6PpY5 FiLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Uvt0uLhW; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p23si1572743otk.119.2020.02.21.05.19.19; Fri, 21 Feb 2020 05:19:32 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Uvt0uLhW; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728103AbgBUNTK (ORCPT + 99 others); Fri, 21 Feb 2020 08:19:10 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:32000 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727039AbgBUNTJ (ORCPT ); Fri, 21 Feb 2020 08:19:09 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582291148; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=a0FcCqHS+SsZ9EJ1weUha6tWG4MB8XxMgHUD9opc+PY=; b=Uvt0uLhWmtTapuXkSm+Nfo9Z/1krpAnVacvG8l1xNam7nsao5SFKbr45LagTXgFFyy/dhU Aejfkf1ZN/hN87aqwscYIaYM/qAtTmjSqe5JVg/+oziupZnbmqQ54DGAxKNOTqqNqqXSMU aw8wkwkhznqCR8NZpulyqlNHXq6hE3s= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-113-OG6LAM9BPzShNlx0_SVM6A-1; Fri, 21 Feb 2020 08:19:01 -0500 X-MC-Unique: OG6LAM9BPzShNlx0_SVM6A-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3696718AB2F4; Fri, 21 Feb 2020 13:18:59 +0000 (UTC) Received: from krava (unknown [10.43.17.9]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0D63C84BCC; Fri, 21 Feb 2020 13:18:56 +0000 (UTC) Date: Fri, 21 Feb 2020 14:18:54 +0100 From: Jiri Olsa To: "Liang, Kan" Cc: acme@kernel.org, mingo@redhat.com, peterz@infradead.org, linux-kernel@vger.kernel.org, mark.rutland@arm.com, namhyung@kernel.org, ravi.bangoria@linux.ibm.com, yao.jin@linux.intel.com, ak@linux.intel.com Subject: Re: [PATCH 0/5] Support metric group constraint Message-ID: <20200221131854.GD652992@krava> References: <1582139320-75181-1-git-send-email-kan.liang@linux.intel.com> <20200220113924.GB565976@krava> <534b4b99-466a-0a5b-e9f5-b4711abd8a4a@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <534b4b99-466a-0a5b-e9f5-b4711abd8a4a@linux.intel.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Feb 20, 2020 at 11:03:35AM -0500, Liang, Kan wrote: > > > On 2/20/2020 6:39 AM, Jiri Olsa wrote: > > On Wed, Feb 19, 2020 at 11:08:35AM -0800, kan.liang@linux.intel.com wrote: > > > 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. > > > > the problem is in the missing counter, that's taken by NMI watchdog, right? > > > > and it's problem for any metric that won't fit to the available > > counters.. shouldn't we rather do this workaround for any metric > > that wouldn't fit in available counters? > > I think current perf already did this. > All metric groups are weak group. Kernel (validate_group()) tells perf tool > whether a metric group fit to available counters. > If yes, the metric group will be scheduled as a group. > If no, perf tool will not using a group and re-try. The code is as below. > > try_again: > if (create_perf_stat_counter(counter, &stat_config, &target) < 0) { > > /* Weak group failed. Reset the group. */ > if ((errno == EINVAL || errno == EBADF) && > counter->leader != counter && > counter->weak_group) { > counter = perf_evlist__reset_weak_group(evsel_list, counter); > goto try_again; > } > > > This patch set is to workaroud the false-positives from the kernel. ah so validate_group will say the group can go on, but then the pmu add will fail because the countters are occupied thanks for explanation, looks good jirka