Received: by 10.192.165.148 with SMTP id m20csp778792imm; Fri, 20 Apr 2018 15:54:56 -0700 (PDT) X-Google-Smtp-Source: AIpwx48Q8wlkL2bL4CTBQxnjh4a9ZQQZ8jW6SLFktMJY4Z+mJybamTtsUyHmWBzi4Zu89wWPE0Ea X-Received: by 2002:a17:902:564:: with SMTP id 91-v6mr11702085plf.63.1524264896463; Fri, 20 Apr 2018 15:54:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524264896; cv=none; d=google.com; s=arc-20160816; b=YamigkrxR66HicPSFP6bq28r/zmi8/9XSUrpSKQrXxcUjh+wTJtabSH1ALATIgBXRp qMXbHzk5Pwn1TVIyhaAyuAFI7BY+eAFlICGDqTdbTtQ+j/0lA5N8DskETbFCAmUjGu+T 4D7UzkS/m4HwcG2nhrErITbm8Km5hNvG9+T+RkAdZ8jhF32nEiqQv97U8OT2i4/RCYKJ O4mkINuD9NFFQsDNMvFPAnqnId6JlrvI0rvq6HZxbfZeUaK4qNTLIZjDGu4Ge94bBMuy G/zNLUSRqx+m7t9JCdHkUodZx228KMGCDszo3P1J3zn8UXJ6q0sq1Qt7mtCncgSs6Bvb Ig9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:autocrypt:openpgp:from:references:cc:to:subject :dkim-signature:arc-authentication-results; bh=35o9di8S5zWUmDY8dj/xDgMD1QcG3gkwuWeoTI80AqQ=; b=IUMvJdM7sW8aAH/xNaKDfLxbRUxuVMQi1TUk1q85TpFxvMvWC1MsxnWZussSGWvnaa JQUGgGLpazXD2gis43Sj4nPbRzonr3zlsp4XEM19dYOW+mrAbj14r9Khwcen2aAiZf9I 6XfQvB0OSmi0krTjOXHo45ZGAenrJVrfIvN5C3EZUMn7NFof4vLYpew1M0uTyubaILp3 DBog5sT3jvPQlVhGAGLT5jcjoD76FM6m+wp0wlREXhSIlAbaMbZ6weicXp6P3cDOnzxN G/yyLRgPegRU1kK7sSHtWzMn8CIdtTJNlamf6ne1GjeWTs7XGoKv5Rh1+TJXbY+HoJQ+ tOBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=aSt4bL1T; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s1si5477715pgb.281.2018.04.20.15.54.18; Fri, 20 Apr 2018 15:54:56 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=aSt4bL1T; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752628AbeDTWva (ORCPT + 99 others); Fri, 20 Apr 2018 18:51:30 -0400 Received: from mail-qk0-f194.google.com ([209.85.220.194]:36246 "EHLO mail-qk0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751325AbeDTWv2 (ORCPT ); Fri, 20 Apr 2018 18:51:28 -0400 Received: by mail-qk0-f194.google.com with SMTP id a202so10334274qkg.3 for ; Fri, 20 Apr 2018 15:51:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:openpgp:autocrypt:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=35o9di8S5zWUmDY8dj/xDgMD1QcG3gkwuWeoTI80AqQ=; b=aSt4bL1TlbJIfDd0OGK+lORF77/vgro4JI8IcX8DSofUTzA1eA4VlCeSDWJJsnzCQa 9dWF2H7wEBVSmr4lTmtm2T5zVax5EAdpVV30Fai06YJZh1vNhlgGYm7tzkz4OM5EXJqf CLrFzNeYirtQME15a0z4VPZIP4WnpoY76OVpib+yVX0tigV+LhQz/5bjVbB84yLq8QKq sWUUkQLYDeTPdC2pEA9GHNoVPsE+LWX+mye2afzz+pxj9MftyNf74RwBvLFpxRR9AsJn QBiWyjN3KNbOX9f7RyJmIn99HKBOcNHrbWHtPqy4iHSI2sPfNbvv3CheUr3i70CMtGq+ E1jQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:openpgp:autocrypt :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=35o9di8S5zWUmDY8dj/xDgMD1QcG3gkwuWeoTI80AqQ=; b=EJE0wcIymNHuAGPYHOaCHNgZQbvMmdk+SBhuVALB13wpwmjq4besykWiROKqJdSpL6 rz7Psn4fRyZMkjIXkP/kb9pgc6UVEqTo5G37UMyIpa1ruRyS3ge6XUe5DKo8cbBNt59n S6ost+8DPG9XUnKvn06rMNpeR41sa4/5ZEgVVUzSL3s9Xx262v+SSKmF/0jdfdAbmrD7 CasB5OB1up7aizKj/zdEiXrj3qZzvQupbadZrg31IyGNd1gf/yxmG4R1ZNsa3ZPHFWWn p53IJIhPHx91lHbM5Ax/9BioJAHERU+ZCXzi5Z/j1ATtIvIANJX9wIlbzvy+sXF0INM/ bSog== X-Gm-Message-State: ALQs6tCYe4jBio6rTauUQ91Z5UXOBLiY2oZ2agaaZ9TJsFrr7BUz5u79 +o8v0Ba2C6HUbSY0FbZWK+I= X-Received: by 10.55.6.145 with SMTP id 139mr12148993qkg.232.1524264687684; Fri, 20 Apr 2018 15:51:27 -0700 (PDT) Received: from [10.69.41.93] ([192.19.223.250]) by smtp.googlemail.com with ESMTPSA id i45-v6sm1222372qta.12.2018.04.20.15.51.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 20 Apr 2018 15:51:26 -0700 (PDT) Subject: Re: [PATCH v3 0/7] MIPS: perf: MT fixes and improvements To: Matt Redfearn , James Hogan , Ralf Baechle Cc: linux-mips@linux-mips.org, Peter Zijlstra , oprofile-list@lists.sf.net, Huacai Chen , linux-kernel@vger.kernel.org, Paul Burton , Robert Richter , Jiri Olsa , Kate Stewart , Ingo Molnar , Greg Kroah-Hartman , "Maciej W. Rozycki" , Namhyung Kim , Alexander Shishkin , Arnaldo Carvalho de Melo References: <1524219789-31241-1-git-send-email-matt.redfearn@mips.com> From: Florian Fainelli Openpgp: preference=signencrypt Autocrypt: addr=f.fainelli@gmail.com; prefer-encrypt=mutual; keydata= xsDiBEjPuBIRBACW9MxSJU9fvEOCTnRNqG/13rAGsj+vJqontvoDSNxRgmafP8d3nesnqPyR xGlkaOSDuu09rxuW+69Y2f1TzjFuGpBk4ysWOR85O2Nx8AJ6fYGCoeTbovrNlGT1M9obSFGQ X3IzRnWoqlfudjTO5TKoqkbOgpYqIo5n1QbEjCCwCwCg3DOH/4ug2AUUlcIT9/l3pGvoRJ0E AICDzi3l7pmC5IWn2n1mvP5247urtHFs/uusE827DDj3K8Upn2vYiOFMBhGsxAk6YKV6IP0d ZdWX6fqkJJlu9cSDvWtO1hXeHIfQIE/xcqvlRH783KrihLcsmnBqOiS6rJDO2x1eAgC8meAX SAgsrBhcgGl2Rl5gh/jkeA5ykwbxA/9u1eEuL70Qzt5APJmqVXR+kWvrqdBVPoUNy/tQ8mYc nzJJ63ng3tHhnwHXZOu8hL4nqwlYHRa9eeglXYhBqja4ZvIvCEqSmEukfivk+DlIgVoOAJbh qIWgvr3SIEuR6ayY3f5j0f2ejUMYlYYnKdiHXFlF9uXm1ELrb0YX4GMHz80nRmxvcmlh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Hbxr4tb6YkhkO6shjXhQh7nQb33FjGO4P WU11Nr9i/qoV8QCo12MQEo244RRA6VMud06y/E449rWZFSTwGqb0FS0seTcYNvxt8PB2izX+ HZA8SL54j479ubxhfuoTu5nXdtFYFj5Lj5x34LKPx7MpgAmj0H7SDhpFWF2FzcC1bjiW9mjW HaKaX23Awt97AqQZXegbfkJwX2Y53ufq8Np3e1542lh3/mpiGSilCsaTahEGrHK+lIusl6mz Joil+u3k01ofvJMK0ZdzGUZ/aPMZ16LofjFA+MNxWrZFrkYmiGdv+LG45zSlZyIvzSiG2lKy kuVag+IijCIom78P9jRtB1q1Q5lwZp2TLAJlz92DmFwBg1hyFzwDADjZ2nrDxKUiybXIgZp9 aU2d++ptEGCVJOfEW4qpWCCLPbOT7XBr+g/4H3qWbs3j/cDDq7LuVYIe+wchy/iXEJaQVeTC y5arMQorqTFWlEOgRA8OP47L9knl9i4xuR0euV6DChDrguup2aJVU8JPBBgRAgAPAhsMBQJU X9LxBQkeXB3fAAoJEGFXmRW1Y3YOj4UAn3nrFLPZekMeqX5aD/aq/dsbXSfyAKC45Go0YyxV HGuUuzv+GKZ6nsysJw== Message-ID: Date: Fri, 20 Apr 2018 15:51:18 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <1524219789-31241-1-git-send-email-matt.redfearn@mips.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 04/20/2018 03:23 AM, Matt Redfearn wrote: > This series addresses a few issues with how the MIPS performance > counters code supports the hardware multithreading MT ASE. > > Firstly, implementations of the MT ASE may implement performance > counters > per core or per thread(TC). MIPS Techologies implementations signal this > via a bit in the implmentation specific CONFIG7 register. Since this > register is implementation specific, checking it should be guarded by a > PRID check. This also replaces a bit defined by a magic number. > > Secondly, the code currently uses vpe_id(), defined as > smp_processor_id(), divided by 2, to share core performance counters > between VPEs. This relies on a couple of assumptions of the hardware > implementation to function correctly (always 2 VPEs per core, and the > hardware reading only the least significant bit). > > Finally, the method of sharing core performance counters between VPEs is > suboptimal since it does not allow one process running on a VPE to use > all of the performance counters available to it, because the kernel will > reserve half of the coutners for the other VPE even if it may never use > them. This reservation at counter probe is replaced with an allocation > on use strategy. > > Tested on a MIPS Creator CI40 (2C2T MIPS InterAptiv with per-TC > counters, though for the purposes of testing the per-TC availability was > hardcoded to allow testing both paths). > > Series applies to v4.16 Sorry it took so long to get that tested. Sounds like you need to build test this on a BMIPS5000 configuration (bmips_stb_defconfig should provide that): In file included from ./arch/mips/include/asm/mach-generic/spaces.h:15:0, from ./arch/mips/include/asm/mach-bmips/spaces.h:16, from ./arch/mips/include/asm/addrspace.h:13, from ./arch/mips/include/asm/barrier.h:11, from ./include/linux/compiler.h:245, from ./include/linux/kernel.h:10, from ./include/linux/cpumask.h:10, from arch/mips/kernel/perf_event_mipsxx.c:18: arch/mips/kernel/perf_event_mipsxx.c: In function 'mipsxx_pmu_enable_event': ./arch/mips/include/asm/mipsregs.h:738:52: error: suggest parentheses around '+' in operand of '&' [-Werror=parentheses] #define BRCM_PERFCTRL_VPEID(v) (_ULCAST_(1) << (12 + v)) arch/mips/kernel/perf_event_mipsxx.c:385:10: note: in expansion of macro 'BRCM_PERFCTRL_VPEID' ctrl = BRCM_PERFCTRL_VPEID(cpu & MIPS_CPUID_TO_COUNTER_MASK); ^~~~~~~~~~~~~~~~~~~ CC drivers/of/fdt_addres after fixing that, I tried the following to see whether this would be a good test case to exercise against: perf record -a -C 0 taskset -c 1 /bin/true perf record -a -C 1 taskset -c 0 /bin/true and would not see anything related to /bin/true running in either case, which seems like it does the right thing? Tested-by: Florian Fainelli BTW, for some reason not specifying -a -C does lead to lockups, consistently and for pretty much any perf command, this could be BMIPS specific, did not get a chance to cross test on a different machine. > > > Changes in v3: > New patch to detect feature presence in cpu-probe.c > Use flag in cpu_data set by cpu_probe.c to indicate feature presence. > - rebase on new feature detection > > Changes in v2: > Fix mipsxx_pmu_enable_event for !#ifdef CONFIG_MIPS_MT_SMP > - Fix !#ifdef CONFIG_MIPS_PERF_SHARED_TC_COUNTERS build > - re-use cpuc variable in mipsxx_pmu_alloc_counter, > mipsxx_pmu_free_counter rather than having sibling_ version. > Since BMIPS5000 does not implement per TC counters, we can remove the > check on cpu_has_mipsmt_pertccounters. > New patch to fix BMIPS5000 system mode perf. > > Matt Redfearn (7): > MIPS: Probe for MIPS MT perf counters per TC > MIPS: perf: More robustly probe for the presence of per-tc counters > MIPS: perf: Use correct VPE ID when setting up VPE tracing > MIPS: perf: Fix perf with MT counting other threads > MIPS: perf: Allocate per-core counters on demand > MIPS: perf: Fold vpe_id() macro into it's one last usage > MIPS: perf: Fix BMIPS5000 system mode counting > > arch/mips/include/asm/cpu-features.h | 7 ++ > arch/mips/include/asm/cpu.h | 2 + > arch/mips/include/asm/mipsregs.h | 6 + > arch/mips/kernel/cpu-probe.c | 12 ++ > arch/mips/kernel/perf_event_mipsxx.c | 232 +++++++++++++++++++---------------- > arch/mips/oprofile/op_model_mipsxx.c | 2 - > 6 files changed, 150 insertions(+), 111 deletions(-) > -- Florian