Received: by 10.213.65.68 with SMTP id h4csp3467664imn; Tue, 3 Apr 2018 05:35:28 -0700 (PDT) X-Google-Smtp-Source: AIpwx48f2MPhxhylTEIxc4yW9/f6NMwvZf2unVqIMt8n1g2IKwzNEn+3zEDcukXf+a87hWb3yx0X X-Received: by 2002:a17:902:b611:: with SMTP id b17-v6mr13863550pls.27.1522758928762; Tue, 03 Apr 2018 05:35:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522758928; cv=none; d=google.com; s=arc-20160816; b=xwIxXhQm27AHBceynItBf6rvwWCIKHKmbMKPiXLSZ7hzMUNFpvMqzJVHUFlkclW889 xES6P7CS572q8OOZ21As4FKfhTB1ubYJE+WqrmF0CJw+wMh6RY+akeZ52YEsPjv4/7BZ JeVu0LZzoSXl9b4qMDCj76VyNQA1AThYpkAjeAJX0xohKgYD79G+YM8iZa4+KlLiBeCX d1gEGmCJm/sruo8xFTqAeB1aie3xunLLVRSHMbHCsJ24SA/s96T/XYDqjo44HfAvbknd 6YXIFM2OzlRw4VQZhc6wmDU6j4EZsZzAhBudYlQY7B9c4tw/8YkEB/0U3+qU1gHG02Gv /F9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=X/ytvzB/FNhGHWdDoILsW/Ljy11AZIx7mV1YN75MTdc=; b=mZIiWPU1f6KB9MZv//WzpUJ1D9KfghsUj2q8ayl8pXAncYuboGLd94RGQNZXeJOAQd yQ87aMEjTYn7SHiuH658jmLmF/jTpVwuHzW4ECIHhdahhjZB9S7sK/7+HYnsJaajQywA EaOLiaXVJvkptyq0/swJ5wtGsfaDfVOEnWoOh3zc5TIXvEsuFJkf4kaaYY6z9CxfXm27 5eGl1vYAAZhJvmpFUuUteedqSBCswsad5RfHRsSg9KaFNshh+Jke+VsJxPoIco/9ZE2I NJjHHcOWNBwZn+Pn1BUp0322PHtVJe+eMo5EolTxzStgbKDeaa7KmpMnxrDaS4rue6lD W+Fw== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d65si1936065pga.307.2018.04.03.05.35.14; Tue, 03 Apr 2018 05:35:28 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932234AbeDCMdg (ORCPT + 99 others); Tue, 3 Apr 2018 08:33:36 -0400 Received: from 9pmail.ess.barracuda.com ([64.235.154.211]:43975 "EHLO 9pmail.ess.barracuda.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932081AbeDCMdc (ORCPT ); Tue, 3 Apr 2018 08:33:32 -0400 Received: from MIPSMAIL01.mipstec.com (mailrelay.mips.com [12.201.5.28]) by mx1411.ess.rzc.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NO); Tue, 03 Apr 2018 12:33:06 +0000 Received: from mredfearn-linux.mipstec.com (192.168.155.41) by MIPSMAIL01.mipstec.com (10.20.43.31) with Microsoft SMTP Server (TLS) id 14.3.361.1; Tue, 3 Apr 2018 05:33:01 -0700 From: Matt Redfearn To: James Hogan , Ralf Baechle CC: , Matt Redfearn , Namhyung Kim , Peter Zijlstra , , Ingo Molnar , Jiri Olsa , Alexander Shishkin , Arnaldo Carvalho de Melo Subject: [PATCH 2/5] MIPS: perf: Use correct VPE ID when setting up VPE tracing Date: Tue, 3 Apr 2018 13:31:28 +0100 Message-ID: <1522758691-17003-3-git-send-email-matt.redfearn@mips.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1522758691-17003-1-git-send-email-matt.redfearn@mips.com> References: <1522758691-17003-1-git-send-email-matt.redfearn@mips.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [192.168.155.41] X-BESS-ID: 1522758734-452059-13817-58425-12 X-BESS-VER: 2018.4.1-r1803302241 X-BESS-Apparent-Source-IP: 12.201.5.28 X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.191653 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------- 0.00 BSF_BESS_OUTBOUND META: BESS Outbound X-BESS-Outbound-Spam-Status: SCORE=0.00 using account:ESS59374 scores of KILL_LEVEL=7.0 tests=BSF_BESS_OUTBOUND X-BESS-BRTS-Status: 1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There are a couple of FIXME's in the perf code which state that cpu_data[event->cpu].vpe_id reports 0 for both CPUs. This is no longer the case, since the vpe_id is used extensively by SMP CPS. VPE local counting gets around this by using smp_processor_id() instead. As it happens this does work correctly to count events on the right VPE, but relies on 2 assumptions: a) Always having 2 VPEs / core. b) The hardware only paying attention to the least significant bit of the PERFCTL.VPEID field. If either of these assumptions change then the incorrect VPEs events will be counted. Fix this by replacing smp_processor_id() with cpu_vpe_id(¤t_cpu_data), in the vpe_id() macro, and pass vpe_id() to M_PERFCTL_VPEID() when setting up PERFCTL.VPEID. The FIXME's can also be removed since they no longer apply. Signed-off-by: Matt Redfearn --- arch/mips/kernel/perf_event_mipsxx.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/arch/mips/kernel/perf_event_mipsxx.c b/arch/mips/kernel/perf_event_mipsxx.c index 3308b35d6680..bb8c6783e9a5 100644 --- a/arch/mips/kernel/perf_event_mipsxx.c +++ b/arch/mips/kernel/perf_event_mipsxx.c @@ -137,12 +137,8 @@ static DEFINE_RWLOCK(pmuint_rwlock); #define vpe_id() (cpu_has_mipsmt_pertccounters ? \ 0 : (smp_processor_id() & MIPS_CPUID_TO_COUNTER_MASK)) #else -/* - * FIXME: For VSMP, vpe_id() is redefined for Perf-events, because - * cpu_data[cpuid].vpe_id reports 0 for _both_ CPUs. - */ #define vpe_id() (cpu_has_mipsmt_pertccounters ? \ - 0 : smp_processor_id()) + 0 : cpu_vpe_id(¤t_cpu_data)) #endif /* Copied from op_model_mipsxx.c */ @@ -1279,11 +1275,7 @@ static void check_and_calc_range(struct perf_event *event, */ hwc->config_base |= M_TC_EN_ALL; } else { - /* - * FIXME: cpu_data[event->cpu].vpe_id reports 0 - * for both CPUs. - */ - hwc->config_base |= M_PERFCTL_VPEID(event->cpu); + hwc->config_base |= M_PERFCTL_VPEID(vpe_id()); hwc->config_base |= M_TC_EN_VPE; } } else -- 2.7.4