Received: by 10.192.165.156 with SMTP id m28csp1742229imm; Thu, 12 Apr 2018 02:43:10 -0700 (PDT) X-Google-Smtp-Source: AIpwx49nsU9aLO4T7AOPxkbu+P93kjjlANNvfejukPKH4sx0LliipwKXCC+9a3/Q2ClHQXIcKmem X-Received: by 10.98.69.217 with SMTP id n86mr7023789pfi.41.1523526189996; Thu, 12 Apr 2018 02:43:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523526189; cv=none; d=google.com; s=arc-20160816; b=VCK4Gkb12LJas44AVQrIfbyLoWqMA+xK/2h2k5UATvga+mLY5BSaq1Zi38Y1xdR042 xBT3nlz2vCxfPXuwhIQq1TqhCyeei/mbqLvSIoBrmmsObMO0dfNno72djU/3k2eRdY41 pUmv+tamqP+FITgPrLnBCKb7pdhuSKBTl60cXt5f7pVYIvDR96fvVB1O+d3FwaIRg6+G PTO7U8KqLIq5VZ6AJHIs4ceB7ng6A1vFGkdRDdRrAtNjuv+PNeqnWEeMi/raJlfeq+6B Jtb/1RwENrXVPjKGQzCXmk1BezQ5+yghsiKyhpD3W6AQI1SlPRWvcE27f+1gawiGaGUt Tf9g== 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=u2zMzDGfjUrPcydzOutDpLXs16xncLI0QEUmM1wBmQc=; b=rIWfhV6Yz/+q4tHvRjCSUifZCBS0kZJIV55mFDgjGu/l9o3j94DSDNHtk+bbNKMR2x QV5IYb+qx1Aw3D16J0imdg19YzCo5WumtEfszoY1bZeQbSZL4NtXjCXDBRrqt3Kg/xgA eUveGK36J48cqVqW5nATbOX1+scUCK2DJvz1tbJY9yFt6rrzEMEYK2/qCK0Wqa66jWC3 irWOAMjRgANjN8mhUQyJGN0dh+L/q/EjO+nnCOX+QPRqyaDjUx9t9kOK1GoPJYp4GFwJ qn5/u2kgmL3L2UOj6yemxcbDd+lEeVg1TkHMStadPna+r8+7UfHm+MgEbikq7Orbicfo RY9Q== 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 r17si2254324pfh.15.2018.04.12.02.42.33; Thu, 12 Apr 2018 02:43:09 -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 S1752824AbeDLJiI (ORCPT + 99 others); Thu, 12 Apr 2018 05:38:08 -0400 Received: from 9pmail.ess.barracuda.com ([64.235.154.210]:53027 "EHLO 9pmail.ess.barracuda.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751920AbeDLJiH (ORCPT ); Thu, 12 Apr 2018 05:38:07 -0400 Received: from MIPSMAIL01.mipstec.com (mailrelay.mips.com [12.201.5.28]) by mx1412.ess.rzc.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NO); Thu, 12 Apr 2018 09:37:45 +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; Thu, 12 Apr 2018 02:37:44 -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 v2 2/6] MIPS: perf: Use correct VPE ID when setting up VPE tracing Date: Thu, 12 Apr 2018 10:36:22 +0100 Message-ID: <1523525786-29153-3-git-send-email-matt.redfearn@mips.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1523525786-29153-1-git-send-email-matt.redfearn@mips.com> References: <1523525786-29153-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: 1523525812-452060-21719-24429-4 X-BESS-VER: 2018.4.1-r1804052329 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.191914 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 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 f3ec4a36921d..239c4ca89fb0 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