Received: by 2002:a05:7412:6592:b0:d7:7d3a:4fe2 with SMTP id m18csp1095975rdg; Fri, 11 Aug 2023 09:32:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGNxYlO5yQP0EMRBHXNbrWmBzl4atkheqP9OgRI+alrqTrHtA3TyW6UK6VRaMpglMpN7CpQ X-Received: by 2002:ac2:5b1c:0:b0:4fe:d0f:1f1b with SMTP id v28-20020ac25b1c000000b004fe0d0f1f1bmr1675053lfn.65.1691771524259; Fri, 11 Aug 2023 09:32:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691771524; cv=none; d=google.com; s=arc-20160816; b=cMn+WP/NXCN5WParf7Zno9/M5Ph7kjst85HUriLuv/0e6b/20LuQhe3abEif5kgvAL fXPxU7WcOG+BhsMM6qFYIg4jNVHY44iU+fAzjjsNnhhCSligrceR3TUM1I0TLcZek0X6 tOs4Z0eVPb8c0v6qdbsHhW6KjJMPQYJ82QWr0CJB1fiy8QeLy5ARmD0l1SifS8SFZIE0 qmKVOyGkNux84vjEo70errV/ku64xlt0UsO5z6YyZAG71uLEBcOC7C1aDovcKxTpap90 DHBCpti7gdsWLd9h/WasrETL5lFycO7SCdX/d7L8VxMoA/7ZRDbfObrJKvi03Ss2CXsv zWQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=zADELGUWpGyqS4NPi0hC5rU83b70YaTQQPW65NChPlI=; fh=v6F0fNNmD6UkIBhL+HIy1+GKiYbtzyRTZWjVFHV54Ww=; b=lmhsPeTe275pGvUfVfO2u0HGLW8UJkvXOEGeEHeYqdivFCKx7khDNIRafKCL4ZNBf/ UOTswIUjVsrE/WFoiYFCMGKULK0sndwRlz1mnTQp5p5dt/ZMqMbabPXfXkZOH7dTOV/O dRWN9G5PZMQhRKWfAmbtpC8ke2i9ieQ6tK6sMZn6xa1iGRbji0KHUVxGoWOB02uH8v5i MQbxVhU66kfK1Ep1aJ+/qCmXej9yEkIeIPEZP4w5pEhW6ppn2VRhcCDUE5vvDC0nY5QS Zvv5rgWdO4I8VlzFvbGjToPrkXO6pUlV0j8eYOWaKcudTkb8bzjWQhn67Lvg8RHEUdNS oLyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rivosinc-com.20221208.gappssmtp.com header.s=20221208 header.b=PpOJJvvo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b23-20020aa7df97000000b005231ebef9aasi3459065edy.581.2023.08.11.09.31.35; Fri, 11 Aug 2023 09:32:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20221208.gappssmtp.com header.s=20221208 header.b=PpOJJvvo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236577AbjHKPTi (ORCPT + 99 others); Fri, 11 Aug 2023 11:19:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49092 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236416AbjHKPTX (ORCPT ); Fri, 11 Aug 2023 11:19:23 -0400 Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 33C8C3593 for ; Fri, 11 Aug 2023 08:19:16 -0700 (PDT) Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-3179ed1dfbbso1876724f8f.1 for ; Fri, 11 Aug 2023 08:19:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20221208.gappssmtp.com; s=20221208; t=1691767155; x=1692371955; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=zADELGUWpGyqS4NPi0hC5rU83b70YaTQQPW65NChPlI=; b=PpOJJvvoZpHsn8jNHPEvN1nxCGms1gOAeA/MFe/y/MFBJC1k+8GHowKIfl2C661sWV Oj4csFcuW/OF0LpQ7tVVRV5X3PfQnx11ALct0kqhzNIVb+qQ1PDy8brCBGTvCCt/6BSy R1BPlxoc090EhGp8CeBhDwLVfUDSzemXaw3/9w2TLLI2xTeaqY8yri4zCXDjI3se0J98 VwRIEMn3C01rkdVmAfQsmnbW0Aib/IWD9iWEsVQPElZuyH059lYcjrJcJilPApbcz+Y9 n/xJGgmLgJ19EuCoRfmld0AUlanWpuf01WR1vAViEsa1d0ZNXOhVrBqAScsj6ZGAd7Nr JRLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691767155; x=1692371955; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zADELGUWpGyqS4NPi0hC5rU83b70YaTQQPW65NChPlI=; b=MWJHeec7zL0zpIS+cn8bTPxtt/KtCmEMGHl9ZeqCVaMEqS0Pz0diHIt3O4a81F+MiG 2GvjCSZBYI/o9qBDPG/0u+4PmY/U5Dz7g+stzeMan0wHapfPb5rD+WFZBYgN/+xKYZrk GyVC8VCBi6ziryy8clDpEPnj/VCM8mtYC7PDniqKPQPBMxYJ+RQUUSJRF3Rq2EyLCtLD Ckdj+yr5tXExNiBaUfRBdlsYXZbwvdyLGlyzhmejlhSKLgErb8hHTwc+Y7zeQndNdnf7 HIV13u8O0K1BqEZLurcgt3QcSUKqsnTYFVHQ7htk19f36vesAFAhTuZq7dmssN+tDuA+ D5tw== X-Gm-Message-State: AOJu0YyhXIf+Aegqp0fQg7Mt1qV023rj/sh6a95sDs/OOTrZlP/tRUcD SY3ZC2Cj9WQQezfzACTptteH3kCX1/EGgNhrf3YtEw== X-Received: by 2002:a05:6000:507:b0:317:de6f:22cb with SMTP id a7-20020a056000050700b00317de6f22cbmr1834346wrf.2.1691767154667; Fri, 11 Aug 2023 08:19:14 -0700 (PDT) MIME-Version: 1.0 References: <20230802080328.1213905-1-alexghiti@rivosinc.com> <20230802080328.1213905-10-alexghiti@rivosinc.com> <20230802-7c19a712ae071f68030ab5f2@orel> In-Reply-To: <20230802-7c19a712ae071f68030ab5f2@orel> From: Alexandre Ghiti Date: Fri, 11 Aug 2023 17:19:03 +0200 Message-ID: Subject: Re: [PATCH v6 09/10] tools: lib: perf: Implement riscv mmap support To: Andrew Jones Cc: Jonathan Corbet , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , Paul Walmsley , Palmer Dabbelt , Albert Ou , Atish Patra , Anup Patel , Will Deacon , Rob Herring , =?UTF-8?Q?R=C3=A9mi_Denis=2DCourmont?= , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-riscv@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Atish Patra Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Andrew, On Wed, Aug 2, 2023 at 11:32=E2=80=AFAM Andrew Jones wrote: > > On Wed, Aug 02, 2023 at 10:03:27AM +0200, Alexandre Ghiti wrote: > > riscv now supports mmaping hardware counters so add what's needed to > > take advantage of that in libperf. > > > > Signed-off-by: Alexandre Ghiti > > Reviewed-by: Andrew Jones > > Reviewed-by: Atish Patra > > --- > > tools/lib/perf/mmap.c | 66 +++++++++++++++++++++++++++++++++++++++++++ > > 1 file changed, 66 insertions(+) > > > > diff --git a/tools/lib/perf/mmap.c b/tools/lib/perf/mmap.c > > index 0d1634cedf44..2184814b37dd 100644 > > --- a/tools/lib/perf/mmap.c > > +++ b/tools/lib/perf/mmap.c > > @@ -392,6 +392,72 @@ static u64 read_perf_counter(unsigned int counter) > > > > static u64 read_timestamp(void) { return read_sysreg(cntvct_el0); } > > > > +/* __riscv_xlen contains the witdh of the native base integer, here 64= -bit */ > > +#elif defined(__riscv) && __riscv_xlen =3D=3D 64 > > + > > +/* TODO: implement rv32 support */ > > + > > +#define CSR_CYCLE 0xc00 > > +#define CSR_TIME 0xc01 > > + > > +#define csr_read(csr) \ > > +({ \ > > + register unsigned long __v; \ > > + __asm__ __volatile__ ("csrr %0, %1" \ > > + : "=3Dr" (__v) \ > > + : "i" (csr) : ); \ > > + __v; \ > > nit: no need for the indentation or line wrap, > > ({ > register unsigned long __v; > __asm__ __volatile__ ("csrr %0, %1" : "=3Dr" (__v) : "i" (csr)); > __v; > }) > > Thanks, > drew Sorry I didn't answer sooner, I was busy finishing everything before my holidays :) I won't have time to implement what you proposed, and more importantly I don't have a setup for rv32 to test quickly. I'll let Palmer decide if we can keep the TODO so that someone can do that later on top of this series. Thanks anyway for your reviews! Alex