Received: by 10.213.65.68 with SMTP id h4csp4230744imn; Tue, 10 Apr 2018 11:19:41 -0700 (PDT) X-Google-Smtp-Source: AIpwx48fD0vneerwm1f3tCyjoJz2Ptyf0UfSKysZ+led7uSlUtUQfRte19rLWYMukiVe7WASB8Jc X-Received: by 2002:a17:902:7201:: with SMTP id ba1-v6mr1482246plb.283.1523384381431; Tue, 10 Apr 2018 11:19:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523384381; cv=none; d=google.com; s=arc-20160816; b=CUrOKQ1gyeTgkdEULmLwxTdvEfsksJYUU8sM1WnGwGR6EWt2yZga1pli0TTRYVH1XG VQH5Yc580hz1VJ0e7jH/b3OFs6EEc1wU35FrpSnLwA3YSrSEhW1/FAcGW8n2WqtDBfOf XHYFBTdpT2qDhVbgvDbWksCk7nq2SxQ32vfx3d9yXOXC5Hqo8WxjAoxeICZq9s/04xs5 E8wpRsrk1M/rg0T2UmrlUxOiSjbVMWhnlsdd/q5gk6x08HE6egfbNPdKM3cnDeqo8zUT IhhvQD7f9U1kKfp1IUA2spl14q3ZoP1EH+uPfOcbyooJEiONJBLAd5cwIW1lnmaCmVkL raJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=pU+OpsSFbl4YFpLefiCI/NG2oOpmdOBajsRhpRGnbg8=; b=vcK5ox6Tf0SuJWsn35FoPUFZDGcqc/crz3d7aM9JfkXAQZsXDJ/lhWF3rsD0GubmAY w43C1vVuVLiDvYXcT2neBlUoUbEu1Dl8m/MF72gCWmnj7OArzEKeoRIWNO0al0YqmLAP 5EdJtENv0QFaK57F4CEMOOSaLK0QHHgDBOo1DwIeIo8txO8Wqvf+FnS3cv6spJ/uJ3I6 Zh2cZpYIUo9XmU47bKMz7th9SDO2M8OBAstxRN/w52Rk/5IKjyrnqytYWufJPR4g2wjc i1ldBps0Hs/+mgavB03ttnq/le2NDGg8uqAHW2476oNCgi9OY0b3qPsxpOZWInuTOXkr YisA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=UEM2dUl6; 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 z5si2506924pff.380.2018.04.10.11.19.04; Tue, 10 Apr 2018 11:19:41 -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=@sifive.com header.s=google header.b=UEM2dUl6; 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 S1751983AbeDJSPq (ORCPT + 99 others); Tue, 10 Apr 2018 14:15:46 -0400 Received: from mail-wr0-f196.google.com ([209.85.128.196]:41589 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751916AbeDJSPn (ORCPT ); Tue, 10 Apr 2018 14:15:43 -0400 Received: by mail-wr0-f196.google.com with SMTP id s12so13717296wrc.8 for ; Tue, 10 Apr 2018 11:15:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=pU+OpsSFbl4YFpLefiCI/NG2oOpmdOBajsRhpRGnbg8=; b=UEM2dUl6Nl1EbV711bfQi5Oti/iVjmyPXxq23FeHtOodhfmXKLn0RY8QwVV6iHeOxJ +fDIbPi+f0AiXhsSl1y1TDLwKpEKGtDN/HnbanjN0trnYUFg1Sefk+UAjmzPZXU3cPWh hFfp61N5AWPbXq20imhWUsqqVf1mEfjwnZ6nhvb5tsviq0WUJMOkLCoZV4bIUFEdmFvF RpTjrOEz9hK8Wc114D+zZiCrbmoPnbsNQzG4JQokx7NVvZ7G/kY3mqsDFsan3oTBqbE/ zxqm/yRc1AkUMqibZuOhT0YF97nvlln/3bVHBV6vzVJ9tVlqEcMp0Dfc5QAeUk0KE66Q dNGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=pU+OpsSFbl4YFpLefiCI/NG2oOpmdOBajsRhpRGnbg8=; b=HzbEy/BSXtsYM/yBySIYh40GICSI4oUlqgnDtKecKaFN6yTVWNNZ3Q9hJF0be4xFyc OFpe0WIwSHpoFuDZ7gfd8Wj7Ih5u62a9m6esZMRmSAaJbsEVIzh93PR2qzWS+FO2mUlq xx7rM/nJ8nO7CwMReJJ9fggo7yhvcz2x8gzh21cqdDRMno7at3z5QCgTw89XdLyKIJ78 vANKNXWSLez3pKElfUZLvb2k8N9iFtMd6GEwERYkA4UQrttXD7RdDMz98/egpk+QclRc fSSY0E1G4RJbAZ04v+db7ALvc2NleAtMEP5HSRSYS6NyTkkJPKbpgUbAV7UXgyoRXCJ4 dkVQ== X-Gm-Message-State: ALQs6tBG+onfM4AKMjjGxC48Sp3Wz6VMKtgNcpESapxDsBL4whzMoEvB ZPq204qTukyB41azVqxi6BzlcsXGmPtfj1fKqFBjxg== X-Received: by 10.223.170.72 with SMTP id q8mr1093456wrd.140.1523384142180; Tue, 10 Apr 2018 11:15:42 -0700 (PDT) MIME-Version: 1.0 Received: by 10.28.58.209 with HTTP; Tue, 10 Apr 2018 11:15:41 -0700 (PDT) In-Reply-To: <20180409070710.GA3844@andestech.com> References: <1522051075-6442-2-git-send-email-alankao@andestech.com> <20180409070710.GA3844@andestech.com> From: Alex Solomatnikov Date: Tue, 10 Apr 2018 11:15:41 -0700 Message-ID: Subject: Re: [PATCH 1/2] perf: riscv: preliminary RISC-V support To: Alan Kao Cc: Palmer Dabbelt , Albert Ou , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Jonathan Corbet , linux-riscv@lists.infradead.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Nick Hu , Greentime Hu Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Alan, I merged SBI emulation for perf counters and config: https://github.com/riscv/riscv-pk/pull/98 You should be able to write these CSRs. Thanks, Alex On Mon, Apr 9, 2018 at 12:07 AM, Alan Kao wrote: > On Thu, Apr 05, 2018 at 09:47:50AM -0700, Palmer Dabbelt wrote: >> On Mon, 26 Mar 2018 00:57:54 PDT (-0700), alankao@andestech.com wrote: >> >This patch provide a basic PMU, riscv_base_pmu, which supports two >> >general hardware event, instructions and cycles. Furthermore, this >> >PMU serves as a reference implementation to ease the portings in >> >the future. >> > >> >riscv_base_pmu should be able to run on any RISC-V machine that >> >conforms to the Priv-Spec. Note that the latest qemu model hasn't >> >fully support a proper behavior of Priv-Spec 1.10 yet, but work >> >around should be easy with very small fixes. Please check >> >https://github.com/riscv/riscv-qemu/pull/115 for future updates. >> > >> >Cc: Nick Hu >> >Cc: Greentime Hu >> >Signed-off-by: Alan Kao >> >> We should really be able to detect PMU types at runtime (via a device tree >> entry) rather than requiring that a single PMU is built in to the kernel. >> This will require a handful of modifications to how this patch works, which >> I'll try to list below. > >> >+menu "PMU type" >> >+ depends on PERF_EVENTS >> >+ >> >+config RISCV_BASE_PMU >> >+ bool "Base Performance Monitoring Unit" >> >+ def_bool y >> >+ help >> >+ A base PMU that serves as a reference implementation and has limited >> >+ feature of perf. >> >+ >> >+endmenu >> >+ >> >> Rather than a menu where a single PMU can be selected, there should be >> options to enable or disable support for each PMU type -- this is just like >> how all our other drivers work. >> > > I see. Sure. The descriptions and implementation will be refined in v3. > >> >+struct pmu * __weak __init riscv_init_platform_pmu(void) >> >+{ >> >+ riscv_pmu = &riscv_base_pmu; >> >+ return riscv_pmu->pmu; >> >+} >> >> Rather than relying on a weak symbol that gets overridden by other PMU >> types, this should look through the device tree for a compatible PMU (in the >> case of just the base PMU it could be any RISC-V hart) and install a PMU >> handler for it. There'd probably be some sort of priority scheme here, like >> there are for other driver subsystems, where we'd pick the best PMU driver >> that's compatible with the PMUs on every hart. >> >> >+ >> >+int __init init_hw_perf_events(void) >> >+{ >> >+ struct pmu *pmu = riscv_init_platform_pmu(); >> >+ >> >+ perf_irq = NULL; >> >+ perf_pmu_register(pmu, "cpu", PERF_TYPE_RAW); >> >+ return 0; >> >+} >> >+arch_initcall(init_hw_perf_events); >> >> Since we only have a single PMU type right now this isn't critical to handle >> right away, but we will have to refactor this before adding another PMU. > > I see. My rough plan is to do the device tree parsing here, and if no specific > PMU string is found then just register the base PMU proposed in this patch. > How about this idea? > > Thanks.