Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp805341img; Mon, 18 Mar 2019 14:47:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqyuoJZ9trb9LunZ15DMgBbK9bkrIiSb5jSLlnBGs+bEtNhMvJDM2WnSUfUFes9XepmtPv81 X-Received: by 2002:a17:902:29ca:: with SMTP id h68mr22216211plb.297.1552945673082; Mon, 18 Mar 2019 14:47:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552945673; cv=none; d=google.com; s=arc-20160816; b=faTyihvQS8gyCDB/Z/GvSMPXmwEsQDSnhU1YNaDOpwu9t3Qi4B3M1STlR9WIFuSsa6 V+/i5smqg2KtawRr4fZAI3JWvKyLtwPf7pIv71wR67OHBO8MfOxp63+bqKR+Kz6NQFzj i+5jfrK0wV6fst4PpiMzjsBGF1qdSDtadj/QPr4KcdOB3gqm2TnVghckESoKn7HB8Dlq V/4JRL4m4ajywxE8v7416/85uAjS0TYAvyyKkhcBJaTI3MWCZ8XiMpNDw4QHtXAkDc4i UkiDYTGzKLu4Hx9w2HP2gQ/4KWT+0vF00svwDIryJ1LI3Et8flyyRwrqsEB7Q03x8qhj KUaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=gBkZMM6kUve38PrWTQOEnlpSeiKdiDCM5JrZ3Wufh9I=; b=MhmBYA9a04USDbqCcsr4jmUkfnoOiF9o+lIi6i5bS20hIIaD0+eTSFlWlMHiqwtI3c W22TvmWBxFLXn2PZokvxM/lf3U7IkOryek8NtFE7yISSzh37syjuDRaH18JMI3nyB+VY dQrYtniyBMog/ZtoLpcKsFyrLgLcW8kUuTJ5xcWORurjJK1ShF9Dq6MPTYEw+d+Wubxt szuNq4BJX5cQ7UKUhOzgL4GwGKfJJXGHHS+oihV/9NFOhP6CsRJd11b8qDqCGdcBWqSF avEZPHuAvkfQ68gvjYBapMfbGUibga9/SbXkfpAs9c04ZvmuEfyJI3Unv2yVwGg+8/gj Pcrg== 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 g127si9816651pgc.313.2019.03.18.14.47.37; Mon, 18 Mar 2019 14:47:53 -0700 (PDT) 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 S1727992AbfCRVpT (ORCPT + 99 others); Mon, 18 Mar 2019 17:45:19 -0400 Received: from mga04.intel.com ([192.55.52.120]:57599 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727817AbfCRVoY (ORCPT ); Mon, 18 Mar 2019 17:44:24 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Mar 2019 14:44:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,495,1544515200"; d="scan'208";a="308301820" Received: from otc-icl-cdi187.jf.intel.com ([10.54.55.103]) by orsmga005.jf.intel.com with ESMTP; 18 Mar 2019 14:44:23 -0700 From: kan.liang@linux.intel.com To: peterz@infradead.org, acme@kernel.org, mingo@redhat.com, linux-kernel@vger.kernel.org Cc: tglx@linutronix.de, jolsa@kernel.org, eranian@google.com, alexander.shishkin@linux.intel.com, ak@linux.intel.com, Kan Liang Subject: [PATCH 13/22] perf/x86/intel: Support overflows on SLOTS Date: Mon, 18 Mar 2019 14:41:35 -0700 Message-Id: <20190318214144.4639-14-kan.liang@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190318214144.4639-1-kan.liang@linux.intel.com> References: <20190318214144.4639-1-kan.liang@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Andi Kleen The internal counters used for the metrics can overflow. If this happens an overflow is triggered on the SLOTS fixed counter. Add special code that resets all the slave metric counters in this case. Signed-off-by: Andi Kleen Signed-off-by: Kan Liang --- arch/x86/events/intel/core.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/arch/x86/events/intel/core.c b/arch/x86/events/intel/core.c index f1cb0155c79a..545db8da24de 100644 --- a/arch/x86/events/intel/core.c +++ b/arch/x86/events/intel/core.c @@ -2198,12 +2198,35 @@ static void intel_pmu_add_event(struct perf_event *event) intel_pmu_lbr_add(event); } +/* When SLOTS overflowed update all the active topdown-* events */ +static void intel_pmu_update_metrics(struct perf_event *event) +{ + struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events); + int idx; + u64 slots_events; + + slots_events = *(u64 *)cpuc->enabled_events & INTEL_PMC_MSK_ANY_SLOTS; + + for_each_set_bit(idx, (unsigned long *)&slots_events, 64) { + struct perf_event *ev = cpuc->events[idx]; + + if (ev == event) + continue; + x86_perf_event_update(event); + } +} + /* * Save and restart an expired event. Called by NMI contexts, * so it has to be careful about preempting normal event ops: */ int intel_pmu_save_and_restart(struct perf_event *event) { + struct hw_perf_event *hwc = &event->hw; + + if (unlikely(hwc->reg_idx == INTEL_PMC_IDX_FIXED_SLOTS)) + intel_pmu_update_metrics(event); + x86_perf_event_update(event); /* * For a checkpointed counter always reset back to 0. This -- 2.17.1