Received: by 10.192.165.148 with SMTP id m20csp82458imm; Fri, 20 Apr 2018 03:27:35 -0700 (PDT) X-Google-Smtp-Source: AIpwx49lwE1NgVKo8r8s1sHDTze6JGixx3E6EEfhIcjtL7DYtilh33zEfux4q61ZucuCQSZVZqSW X-Received: by 2002:a17:902:b709:: with SMTP id d9-v6mr8728728pls.188.1524220055931; Fri, 20 Apr 2018 03:27:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524220055; cv=none; d=google.com; s=arc-20160816; b=rZYR/9RNOYABesXOqAbioTFk5TcfFw8k9/YObDKKTHkI73c2kcPjZG9taD/DiWNVpN 9yDTUcEGUTiebGgAsW1N2r5+nrnRnivuO/6njPqQilNMdXlMLYHNjj3K/6XzMZL9kA+5 z6QP1qkGPu4iEUbcQRZpcnj/OL4LpTVaC8zqxDtkLrwNtQbDO30VQVXRCk0X+NKQO9KG 1PQzpk6L/qd6Z98L9dL5jFFxoSMHCohe0c/gML4UP9SXkw7gFTWVqU8N0eocLZfcuMEK p2p8Oqrk/Vh9CmSLhhYXYxW+8FSaO7OoBej87PwUaXvZyDCemneBOwJBN416ICJNnPDG ELxg== 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=HZiVWDDayNSwLQCW14EkDj6NeBKWAtqrZlBRxAqcqjc=; b=TiFuUsCyrR8utDsjejl/1zufkGj90tDbawKTLc+Jl2eB8UrqjVH5kio84dfNOq/Czc BA7ww91VvrSWgvIfXdKVq5/42aiUKfNPK3bBlAxdPIiNfVxTh6ev8wf+kEZrXd2dA65j 28jFM8D8smw9eo7O0i4OaiYPhEK+LTQlsiUMXnotpUUrv8usJFf/P2r5eGsWuQZmefmX Wt+PEVcIEkti2IeOQcRQy8bnEVqkftgnuhqY7V9PJHagrYwROSySmAzijFiEPWXnWgCk tW2JCbrmtkdhfOXeH2gNDxdW7UJ9qaXwR5CupV2OaP7+US7AAVkYBGZxRUpVCe6Afvg+ a6Jg== 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 g17si5158166pfj.349.2018.04.20.03.27.20; Fri, 20 Apr 2018 03:27:35 -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 S1754586AbeDTK0J (ORCPT + 99 others); Fri, 20 Apr 2018 06:26:09 -0400 Received: from 9pmail.ess.barracuda.com ([64.235.154.211]:53944 "EHLO 9pmail.ess.barracuda.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754458AbeDTK0I (ORCPT ); Fri, 20 Apr 2018 06:26:08 -0400 Received: from MIPSMAIL01.mipstec.com (mailrelay.mips.com [12.201.5.28]) by mx1401.ess.rzc.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NO); Fri, 20 Apr 2018 10:25:47 +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; Fri, 20 Apr 2018 03:25:04 -0700 From: Matt Redfearn To: James Hogan , Ralf Baechle , Florian Fainelli CC: , Matt Redfearn , Namhyung Kim , Peter Zijlstra , , Ingo Molnar , Jiri Olsa , Alexander Shishkin , Arnaldo Carvalho de Melo Subject: [PATCH v3 3/7] MIPS: perf: Use correct VPE ID when setting up VPE tracing Date: Fri, 20 Apr 2018 11:23:05 +0100 Message-ID: <1524219789-31241-4-git-send-email-matt.redfearn@mips.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1524219789-31241-1-git-send-email-matt.redfearn@mips.com> References: <1524219789-31241-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: 1524219945-321457-10557-42113-2 X-BESS-VER: 2018.5-r1804181636 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.192194 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 --- Changes in v3: None Changes in v2: None 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 0595a974bc81..7e2b7d38a774 100644 --- a/arch/mips/kernel/perf_event_mipsxx.c +++ b/arch/mips/kernel/perf_event_mipsxx.c @@ -135,12 +135,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 */ @@ -1277,11 +1273,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